#!/usr/bin/python3

import shutil
import os
import subprocess
from GuestFS import GuestFS
from enum import IntEnum

# libguestFS enum
class hive_type(IntEnum):
   #/* Just a key without a value */
   hive_t_REG_NONE = 0,
   #/* A Windows string (encoding is unknown, but often UTF16-LE) */
   hive_t_REG_SZ = 1,
   #/* A Windows string that contains %env% (environment variable expansion) */
   hive_t_REG_EXPAND_SZ = 2,
   #/* A blob of binary */
   hive_t_REG_BINARY = 3,
   #/* DWORD (32 bit integer), little endian */
   hive_t_REG_DWORD = 4,
   #/* DWORD (32 bit integer), big endian */
   hive_t_REG_DWORD_BIG_ENDIAN = 5,
   #/* Symbolic link to another part of the registry tree */
   hive_t_REG_LINK = 6,
   #/* Multiple Windows strings.  See http://blogs.msdn.com/oldnewthing/archive/2009/10/08/9904646.aspx */
   hive_t_REG_MULTI_SZ = 7,
   #/* Resource list */
   hive_t_REG_RESOURCE_LIST = 8,
   #/* Resource descriptor */
   hive_t_REG_FULL_RESOURCE_DESCRIPTOR = 9,
   #/* Resouce requirements list */
   hive_t_REG_RESOURCE_REQUIREMENTS_LIST = 10,
   #/* QWORD (64 bit integer), unspecified endianness but usually little endian */
   hive_t_REG_QWORD = 11


class GuestFS_Registry:
    def __init__(self, guestFS, rootLogger):
        self.guestFS = guestFS
        self.rootLogger = rootLogger
        self.regCache = dict()
        self.current_open_hive = None


    def clean_up(self):
        self.rootLogger.info('GuestFS_Registry::clean_up()')
        self.regCache.clear()
        self.close_hive()


    def open_hive(self, hiveName):
        try: