diff options
Diffstat (limited to 'src/libs/7zip/unix/CPP/7zip/UI/Common')
5 files changed, 0 insertions, 832 deletions
diff --git a/src/libs/7zip/unix/CPP/7zip/UI/Common/CompressCall.cpp b/src/libs/7zip/unix/CPP/7zip/UI/Common/CompressCall.cpp deleted file mode 100644 index fdc6c66f1..000000000 --- a/src/libs/7zip/unix/CPP/7zip/UI/Common/CompressCall.cpp +++ /dev/null @@ -1,470 +0,0 @@ -// CompressCall.cpp - -#include "StdAfx.h" - -// For compilers that support precompilation, includes "wx/wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -#undef _WIN32 - -#include "CompressCall.h" - -// FIXME #include "Common/Random.h" -#include "Common/IntToString.h" -#include "Common/MyCom.h" -#include "Common/StringConvert.h" - -#include "Windows/Synchronization.h" -// FIXME #include "Windows/FileMapping.h" -#include "Windows/FileDir.h" - -#include "../FileManager/ProgramLocation.h" -#include "../FileManager/RegistryUtils.h" - -#define NEED_NAME_WINDOWS_TO_UNIX -#include "myPrivate.h" - -#ifndef _UNICODE -extern bool g_IsNT; -#endif // _UNICODE - -using namespace NWindows; - -static LPCWSTR kShowDialogSwitch = L" -ad"; -static LPCWSTR kEmailSwitch = L" -seml."; -static LPCWSTR kMapSwitch = L" -i#"; -static LPCWSTR kArchiveNoNameSwitch = L" -an"; -static LPCWSTR kArchiveTypeSwitch = L" -t"; -static LPCWSTR kArchiveMapSwitch = L" -ai#"; -static LPCWSTR kStopSwitchParsing = L" --"; -static LPCWSTR kLargePagesDisable = L" -slp-"; - -static void AddLagePagesSwitch(UString ¶ms) -{ -#ifdef _WIN32 - if (!ReadLockMemoryEnable()) - params += kLargePagesDisable; -#endif -} - -HRESULT MyCreateProcess(const UString ¶ms, - LPCWSTR curDir, bool waitFinish, - NWindows::NSynchronization::CBaseEvent *event) -{ - printf("MyCreateProcess: waitFinish=%d event=%p\n",(unsigned)waitFinish,event); - printf("\tparams : %ls\n",(const wchar_t*)params); - printf("\tcurDir : %ls\n",(const wchar_t*)curDir); - - wxString cmd(params); - wxString memoCurDir = wxGetCwd(); - - if (curDir) { // FIXME - wxSetWorkingDirectory(wxString(curDir)); - - - // under MacOSX, a bundle does not keep the current directory - // between 7zFM and 7zG ... - // So, try to use the environment variable P7ZIP_CURRENT_DIR - - char p7zip_current_dir[MAX_PATH]; - - AString aCurPath = GetAnsiString(curDir); - - const char *dir2 = nameWindowToUnix((const char *)aCurPath); - - snprintf(p7zip_current_dir,sizeof(p7zip_current_dir),"P7ZIP_CURRENT_DIR=%s/",dir2); - - p7zip_current_dir[sizeof(p7zip_current_dir)-1] = 0; - - putenv(p7zip_current_dir); - - printf("putenv(%s)\n",p7zip_current_dir); - - } - - - printf("MyCreateProcess: cmd='%ls'\n",(const wchar_t *)cmd); - long pid = 0; - if (waitFinish) pid = wxExecute(cmd, wxEXEC_SYNC); // FIXME process never ends and stays zombie ... - else pid = wxExecute(cmd, wxEXEC_ASYNC); - - if (curDir) wxSetWorkingDirectory(memoCurDir); - - - // FIXME if (pid == 0) return E_FAIL; - - return S_OK; -#ifdef _WIN32 // FIXME - const UString params2 = params; - BOOL result; - { - STARTUPINFOW startupInfo; - startupInfo.cb = sizeof(startupInfo); - startupInfo.lpReserved = 0; - startupInfo.lpDesktop = 0; - startupInfo.lpTitle = 0; - startupInfo.dwFlags = 0; - startupInfo.cbReserved2 = 0; - startupInfo.lpReserved2 = 0; - - result = ::CreateProcessW(NULL, (LPWSTR)(LPCWSTR)params, - NULL, NULL, FALSE, 0, NULL, - curDir, - &startupInfo, &processInformation); - } - if (result == 0) - return ::GetLastError(); - else - { - ::CloseHandle(processInformation.hThread); - if (waitFinish) - WaitForSingleObject(processInformation.hProcess, INFINITE); - else if (event != NULL) - { - HANDLE handles[] = {processInformation.hProcess, *event }; - ::WaitForMultipleObjects(sizeof(handles) / sizeof(handles[0]), - handles, FALSE, INFINITE); - } - ::CloseHandle(processInformation.hProcess); - } - return S_OK; -#endif -} - -UString GetQuotedString(const UString &s) -{ - return UString(L"\"") + s + UString(L"\""); -} - -static UString Get7zGuiPath() -{ - UString path; - UString folder; - if (GetProgramFolderPath(folder)) - path += folder; -#ifdef _WIN32 - path += L"7zG.exe"; -#else - path += L"7zG"; -#endif - return GetQuotedString(path); -} - -#ifdef _WIN32 -static HRESULT CreateTempEvent(const wchar_t *name, - NSynchronization::CManualResetEvent &event, UString &eventName) -{ - CRandom random; - random.Init(GetTickCount()); - for (;;) - { - int number = random.Generate(); - wchar_t temp[32]; - ConvertUInt64ToString((UInt32)number, temp); - eventName = name; - eventName += temp; - RINOK(event.CreateWithName(false, GetSystemString(eventName))); - if (::GetLastError() != ERROR_ALREADY_EXISTS) - return S_OK; - event.Close(); - } -} - -static HRESULT CreateMap(const UStringVector &names, - const UString &id, - CFileMapping &fileMapping, NSynchronization::CManualResetEvent &event, - UString ¶ms) -{ - UInt32 extraSize = 2; - UInt32 dataSize = 0; - for (int i = 0; i < names.Size(); i++) - dataSize += (names[i].Length() + 1) * sizeof(wchar_t); - UInt32 totalSize = extraSize + dataSize; - - UString mappingName; - - CRandom random; - random.Init(GetTickCount()); - for (;;) - { - int number = random.Generate(); - wchar_t temp[32]; - ConvertUInt64ToString(UInt32(number), temp); - mappingName = id; - mappingName += L"Mapping"; - mappingName += temp; - if (!fileMapping.Create(INVALID_HANDLE_VALUE, NULL, - PAGE_READWRITE, totalSize, GetSystemString(mappingName))) - return E_FAIL; - if (::GetLastError() != ERROR_ALREADY_EXISTS) - break; - fileMapping.Close(); - } - - UString eventName; - RINOK(CreateTempEvent(id + L"MappingEndEvent", event, eventName)); - - params += mappingName; - params += L":"; - wchar_t string[10]; - ConvertUInt64ToString(totalSize, string); - params += string; - - params += L":"; - params += eventName; - - LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_WRITE, 0, totalSize); - if (data == NULL) - return E_FAIL; - { - wchar_t *curData = (wchar_t *)data; - *curData = 0; - curData++; - for (int i = 0; i < names.Size(); i++) - { - const UString &s = names[i]; - memcpy(curData, (const wchar_t *)s, s.Length() * sizeof(wchar_t)); - curData += s.Length(); - *curData++ = L'\0'; - } - } - return S_OK; -} -#endif - -HRESULT CompressFiles( - const UString &curDir, - const UString &archiveName, - const UString &archiveType, - const UStringVector &names, - // const UString &outFolder, - bool email, - bool showDialog, - bool waitFinish) -{ - /* - UString curDir; - if (names.Size() > 0) - { - NFile::NDirectory::GetOnlyDirPrefix(names[0], curDir); - } - */ - UString params; - params = Get7zGuiPath(); - params += L" a"; -#ifdef _WIN32 - params += kMapSwitch; - // params += _fileNames[0]; - - UInt32 extraSize = 2; - UInt32 dataSize = 0; - for (int i = 0; i < names.Size(); i++) - dataSize += (names[i].Length() + 1) * sizeof(wchar_t); - UInt32 totalSize = extraSize + dataSize; - - UString mappingName; - - CFileMapping fileMapping; - CRandom random; - random.Init(GetTickCount()); - for (;;) - { - int number = random.Generate(); - wchar_t temp[32]; - ConvertUInt64ToString(UInt32(number), temp); - mappingName = L"7zCompressMapping"; - mappingName += temp; - if (!fileMapping.Create(INVALID_HANDLE_VALUE, NULL, - PAGE_READWRITE, totalSize, GetSystemString(mappingName))) - { - // MyMessageBox(IDS_ERROR, 0x02000605); - return E_FAIL; - } - if (::GetLastError() != ERROR_ALREADY_EXISTS) - break; - fileMapping.Close(); - } - - NSynchronization::CManualResetEvent event; - UString eventName; - RINOK(CreateTempEvent(L"7zCompressMappingEndEvent", event, eventName)); - - params += mappingName; - params += L":"; - wchar_t string[10]; - ConvertUInt64ToString(totalSize, string); - params += string; - - params += L":"; - params += eventName; -#else - char tempFile[256]; - static int count = 1000; - - sprintf(tempFile,"/tmp/7zCompress_%d_%d.tmp",(int)getpid(),count++); - - FILE * file = fopen(tempFile,"w"); - if (file) - { - for (int i = 0; i < names.Size(); i++) { - fprintf(file,"%ls\n",(const wchar_t *)names[i]); - printf(" TMP_%d : '%ls'\n",i,(const wchar_t *)names[i]); - } - - fclose(file); - } - params += L" -i@"; - params += GetUnicodeString(tempFile); -#endif - - if (!archiveType.IsEmpty()) - { - params += kArchiveTypeSwitch; - params += archiveType; - } - - if (email) - params += kEmailSwitch; - - if (showDialog) - params += kShowDialogSwitch; - - AddLagePagesSwitch(params); - - params += kStopSwitchParsing; - params += L" "; - - params += GetQuotedString(archiveName); - -#ifdef _WIN32 - LPVOID data = fileMapping.MapViewOfFile(FILE_MAP_WRITE, 0, totalSize); - if (data == NULL) - { - // MyMessageBox(IDS_ERROR, 0x02000605); - return E_FAIL; - } - try - { - wchar_t *curData = (wchar_t *)data; - *curData = 0; - curData++; - for (int i = 0; i < names.Size(); i++) - { - const UString &unicodeString = names[i]; - memcpy(curData, (const wchar_t *)unicodeString , - unicodeString .Length() * sizeof(wchar_t)); - curData += unicodeString.Length(); - *curData++ = L'\0'; - } - // MessageBox(0, params, 0, 0); - RINOK(MyCreateProcess(params, - (curDir.IsEmpty()? 0: (LPCWSTR)curDir), - waitFinish, &event)); - } - catch(...) - { - UnmapViewOfFile(data); - throw; - } - UnmapViewOfFile(data); - - - /* - CThreadCompressMain *compressor = new CThreadCompressMain();; - compressor->FileNames = _fileNames; - CThread thread; - if (!thread.Create(CThreadCompressMain::MyThreadFunction, compressor)) - throw 271824; - */ -#else - printf("CompressFiles : -%ls-\n",(const wchar_t *)params); - HRESULT res = MyCreateProcess(params, - (curDir.IsEmpty()? 0: (LPCWSTR)curDir), - true, /* &event FIXME */ 0); - printf("CompressFiles : END\n"); - - remove(tempFile); -#endif - return S_OK; -} - -static HRESULT ExtractGroupCommand(const UStringVector &archivePaths, - const UString ¶ms) -{ - UString params2 = params; - AddLagePagesSwitch(params2); - params2 += kArchiveNoNameSwitch; -#ifdef _WIN32 - params2 += kArchiveMapSwitch; - CFileMapping fileMapping; - NSynchronization::CManualResetEvent event; - RINOK(CreateMap(archivePaths, L"7zExtract", fileMapping, event, params2)); - return MyCreateProcess(params2, 0, false, &event); -#else - char tempFile[256]; - static int count = 1000; - - sprintf(tempFile,"/tmp/7zExtract_%d_%d.tmp",(int)getpid(),count++); - - FILE * file = fopen(tempFile,"w"); - if (file) - { - for (int i = 0; i < archivePaths.Size(); i++) { - fprintf(file,"%ls\n",(const wchar_t *)archivePaths[i]); - printf(" TMP_%d : '%ls'\n",i,(const wchar_t *)archivePaths[i]); - } - - fclose(file); - } - params2 += L" -ai@"; - params2 += GetUnicodeString(tempFile); - printf("ExtractGroupCommand : -%ls-\n",(const wchar_t *)params2); - HRESULT res = MyCreateProcess(params2, 0, true, /* &event FIXME */ 0); - printf("ExtractGroupCommand : END\n"); - - remove(tempFile); - - return res; -#endif -} - -HRESULT ExtractArchives(const UStringVector &archivePaths, - const UString &outFolder, bool showDialog) -{ - UString params; - params = Get7zGuiPath(); - params += L" x"; - if (!outFolder.IsEmpty()) - { - params += L" \"-o"; - params += outFolder; - params += L"\""; - } - if (showDialog) - params += kShowDialogSwitch; - return ExtractGroupCommand(archivePaths, params); -} - -HRESULT TestArchives(const UStringVector &archivePaths) -{ - UString params; - params = Get7zGuiPath(); - params += L" t"; - return ExtractGroupCommand(archivePaths, params); -} - -HRESULT Benchmark() -{ - UString params; - params = Get7zGuiPath(); - params += L" b"; - return MyCreateProcess(params, 0, false, NULL); -} diff --git a/src/libs/7zip/unix/CPP/7zip/UI/Common/CompressCall.h b/src/libs/7zip/unix/CPP/7zip/UI/Common/CompressCall.h deleted file mode 100644 index fc18df57c..000000000 --- a/src/libs/7zip/unix/CPP/7zip/UI/Common/CompressCall.h +++ /dev/null @@ -1,24 +0,0 @@ -// CompressCall.h - -#ifndef __COMPRESS_CALL_H -#define __COMPRESS_CALL_H - -#include "Common/MyString.h" - -UString GetQuotedString(const UString &s); - -extern HWND g_HWND; -UString HResultToMessage(HRESULT errorCode); - -HRESULT CompressFiles( - const UString &arcPathPrefix, - const UString &arcName, - const UString &arcType, - const UStringVector &names, - bool email, bool showDialog, bool waitFinish); - -HRESULT ExtractArchives(const UStringVector &arcPaths, const UString &outFolder, bool showDialog); -HRESULT TestArchives(const UStringVector &arcPaths); -HRESULT Benchmark(); - -#endif diff --git a/src/libs/7zip/unix/CPP/7zip/UI/Common/HandlerLoader.h b/src/libs/7zip/unix/CPP/7zip/UI/Common/HandlerLoader.h deleted file mode 100644 index 4c7e1a8f4..000000000 --- a/src/libs/7zip/unix/CPP/7zip/UI/Common/HandlerLoader.h +++ /dev/null @@ -1,38 +0,0 @@ -// HandlerLoader.h - -#ifndef __HANDLERLOADER_H -#define __HANDLERLOADER_H - -#include "../../ICoder.h" -#include "Windows/DLL.h" - -typedef UInt32 (WINAPI * CreateObjectFunc)( - const GUID *clsID, - const GUID *interfaceID, - void **outObject); - -class CHandlerLoader: public NWindows::NDLL::CLibrary -{ -public: - HRESULT CreateHandler(LPCWSTR filepath, REFGUID clsID, - void **archive, bool outHandler) - { - if (!Load(filepath)) - return GetLastError(); - CreateObjectFunc createObject = (CreateObjectFunc) - GetProcAddress("CreateObject"); - if (createObject == NULL) - { - HRESULT res = ::GetLastError(); - Free(); - return res; - } - HRESULT res = createObject(&clsID, - outHandler ? &IID_IOutArchive : &IID_IInArchive, (void **)archive); - if (res != 0) - Free(); - return res; - } -}; - -#endif diff --git a/src/libs/7zip/unix/CPP/7zip/UI/Common/UpdatePair.cpp b/src/libs/7zip/unix/CPP/7zip/UI/Common/UpdatePair.cpp index a43a9e770..d9396a583 100644 --- a/src/libs/7zip/unix/CPP/7zip/UI/Common/UpdatePair.cpp +++ b/src/libs/7zip/unix/CPP/7zip/UI/Common/UpdatePair.cpp @@ -28,13 +28,6 @@ static int MyCompareTime(NFileTimeType::EEnum fileTimeType, const FILETIME &time FileTimeToUnixTime(time2, unixTime2); return MyCompare(unixTime1, unixTime2); } - case NFileTimeType::kDOS: - { - UInt32 dosTime1, dosTime2; - FileTimeToDosTime(time1, dosTime1); - FileTimeToDosTime(time2, dosTime2); - return MyCompare(dosTime1, dosTime2); - } } throw 4191618; } diff --git a/src/libs/7zip/unix/CPP/7zip/UI/Common/ZipRegistry.cpp b/src/libs/7zip/unix/CPP/7zip/UI/Common/ZipRegistry.cpp deleted file mode 100644 index ac178078a..000000000 --- a/src/libs/7zip/unix/CPP/7zip/UI/Common/ZipRegistry.cpp +++ /dev/null @@ -1,293 +0,0 @@ -// ZipRegistry.cpp - -#include "StdAfx.h" - -#include "Common/IntToString.h" -#include "Common/StringConvert.h" - -#include "Windows/FileDir.h" -#include "Windows/Registry.h" -#include "Windows/Synchronization.h" - -#include "ZipRegistry.h" - -using namespace NWindows; -using namespace NRegistry; - -static NSynchronization::CCriticalSection g_CS; -#define CS_LOCK NSynchronization::CCriticalSectionLock lock(g_CS); - -static const TCHAR *kCuPrefix = TEXT("Software") TEXT(STRING_PATH_SEPARATOR) TEXT("7-Zip") TEXT(STRING_PATH_SEPARATOR); - -static CSysString GetKeyPath(const CSysString &path) { return kCuPrefix + path; } - -static LONG OpenMainKey(CKey &key, LPCTSTR keyName) -{ - return key.Open(HKEY_CURRENT_USER, GetKeyPath(keyName), KEY_READ); -} - -static LONG CreateMainKey(CKey &key, LPCTSTR keyName) -{ - return key.Create(HKEY_CURRENT_USER, GetKeyPath(keyName)); -} - -namespace NExtract -{ - -static const TCHAR *kKeyName = TEXT("Extraction"); - -static const TCHAR *kExtractMode = TEXT("ExtractMode"); -static const TCHAR *kOverwriteMode = TEXT("OverwriteMode"); -static const TCHAR *kShowPassword = TEXT("ShowPassword"); -static const TCHAR *kPathHistory = TEXT("PathHistory"); - -void CInfo::Save() const -{ - CS_LOCK - CKey key; - CreateMainKey(key, kKeyName); - key.SetValue(kExtractMode, (UInt32)PathMode); - key.SetValue(kOverwriteMode, (UInt32)OverwriteMode); - key.SetValue(kShowPassword, ShowPassword); - key.RecurseDeleteKey(kPathHistory); - key.SetValue_Strings(kPathHistory, Paths); -} - - -void CInfo::Load() -{ - PathMode = NPathMode::kCurrentPathnames; - OverwriteMode = NOverwriteMode::kAskBefore; - ShowPassword = false; - Paths.Clear(); - - CS_LOCK - CKey key; - if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS) - return; - - key.GetValue_Strings(kPathHistory, Paths); - UInt32 v; - if (key.QueryValue(kExtractMode, v) == ERROR_SUCCESS && v <= NPathMode::kNoPathnames) - PathMode = (NPathMode::EEnum)v; - if (key.QueryValue(kOverwriteMode, v) == ERROR_SUCCESS && v <= NOverwriteMode::kAutoRenameExisting) - OverwriteMode = (NOverwriteMode::EEnum)v; - key.GetValue_IfOk(kShowPassword, ShowPassword); -} - -} - -namespace NCompression -{ - -static const TCHAR *kKeyName = TEXT("Compression"); - -static const TCHAR *kArcHistory = TEXT("ArcHistory"); -static const WCHAR *kArchiver = L"Archiver"; -static const TCHAR *kShowPassword = TEXT("ShowPassword"); -static const TCHAR *kEncryptHeaders = TEXT("EncryptHeaders"); - -static const TCHAR *kOptionsKeyName = TEXT("Options"); - -static const TCHAR *kLevel = TEXT("Level"); -static const TCHAR *kDictionary = TEXT("Dictionary"); -static const TCHAR *kOrder = TEXT("Order"); -static const TCHAR *kBlockSize = TEXT("BlockSize"); -static const TCHAR *kNumThreads = TEXT("NumThreads"); -static const WCHAR *kMethod = L"Method"; -static const WCHAR *kOptions = L"Options"; -static const WCHAR *kEncryptionMethod = L"EncryptionMethod"; - -static void SetRegString(CKey &key, const WCHAR *name, const UString &value) -{ - if (value.IsEmpty()) - key.DeleteValue(name); - else - key.SetValue(name, value); -} - -static void SetRegUInt32(CKey &key, const TCHAR *name, UInt32 value) -{ - if (value == (UInt32)-1) - key.DeleteValue(name); - else - key.SetValue(name, value); -} - -static void GetRegString(CKey &key, const WCHAR *name, UString &value) -{ - if (key.QueryValue(name, value) != ERROR_SUCCESS) - value.Empty(); -} - -static void GetRegUInt32(CKey &key, const TCHAR *name, UInt32 &value) -{ - if (key.QueryValue(name, value) != ERROR_SUCCESS) - value = (UInt32)-1; -} - -void CInfo::Save() const -{ - CS_LOCK - - CKey key; - CreateMainKey(key, kKeyName); - key.SetValue(kLevel, (UInt32)Level); - key.SetValue(kArchiver, ArcType); - key.SetValue(kShowPassword, ShowPassword); - key.SetValue(kEncryptHeaders, EncryptHeaders); - key.RecurseDeleteKey(kArcHistory); - key.SetValue_Strings(kArcHistory, ArcPaths); - - key.RecurseDeleteKey(kOptionsKeyName); - { - CKey optionsKey; - optionsKey.Create(key, kOptionsKeyName); - for (int i = 0; i < Formats.Size(); i++) - { - const CFormatOptions &fo = Formats[i]; - CKey fk; - fk.Create(optionsKey, fo.FormatID); - - SetRegUInt32(fk, kLevel, fo.Level); - SetRegUInt32(fk, kDictionary, fo.Dictionary); - SetRegUInt32(fk, kOrder, fo.Order); - SetRegUInt32(fk, kBlockSize, fo.BlockLogSize); - SetRegUInt32(fk, kNumThreads, fo.NumThreads); - - SetRegString(fk, kMethod, fo.Method); - SetRegString(fk, kOptions, fo.Options); - SetRegString(fk, kEncryptionMethod, fo.EncryptionMethod); - } - } -} - -void CInfo::Load() -{ - ArcPaths.Clear(); - Formats.Clear(); - - Level = 5; - ArcType = L"7z"; - ShowPassword = false; - EncryptHeaders = false; - - CS_LOCK - CKey key; - - if (OpenMainKey(key, kKeyName) != ERROR_SUCCESS) - return; - - key.GetValue_Strings(kArcHistory, ArcPaths); - - { - CKey optionsKey; - if (optionsKey.Open(key, kOptionsKeyName, KEY_READ) == ERROR_SUCCESS) - { - CSysStringVector formatIDs; - optionsKey.EnumKeys(formatIDs); - for (int i = 0; i < formatIDs.Size(); i++) - { - CKey fk; - CFormatOptions fo; - fo.FormatID = formatIDs[i]; - if (fk.Open(optionsKey, fo.FormatID, KEY_READ) == ERROR_SUCCESS) - { - GetRegString(fk, kOptions, fo.Options); - GetRegString(fk, kMethod, fo.Method); - GetRegString(fk, kEncryptionMethod, fo.EncryptionMethod); - - GetRegUInt32(fk, kLevel, fo.Level); - GetRegUInt32(fk, kDictionary, fo.Dictionary); - GetRegUInt32(fk, kOrder, fo.Order); - GetRegUInt32(fk, kBlockSize, fo.BlockLogSize); - GetRegUInt32(fk, kNumThreads, fo.NumThreads); - - Formats.Add(fo); - } - } - } - } - - UString a; - if (key.QueryValue(kArchiver, a) == ERROR_SUCCESS) - ArcType = a; - key.GetValue_IfOk(kLevel, Level); - key.GetValue_IfOk(kShowPassword, ShowPassword); - key.GetValue_IfOk(kEncryptHeaders, EncryptHeaders); -} - -} - -static const TCHAR *kOptionsInfoKeyName = TEXT("Options"); - -namespace NWorkDir -{ -static const TCHAR *kWorkDirType = TEXT("WorkDirType"); -static const WCHAR *kWorkDirPath = L"WorkDirPath"; -static const TCHAR *kTempRemovableOnly = TEXT("TempRemovableOnly"); - - -void CInfo::Save()const -{ - CS_LOCK - CKey key; - CreateMainKey(key, kOptionsInfoKeyName); - key.SetValue(kWorkDirType, (UInt32)Mode); - key.SetValue(kWorkDirPath, Path); - key.SetValue(kTempRemovableOnly, ForRemovableOnly); -} - -void CInfo::Load() -{ - SetDefault(); - - CS_LOCK - CKey key; - if (OpenMainKey(key, kOptionsInfoKeyName) != ERROR_SUCCESS) - return; - - UInt32 dirType; - if (key.QueryValue(kWorkDirType, dirType) != ERROR_SUCCESS) - return; - switch (dirType) - { - case NMode::kSystem: - case NMode::kCurrent: - case NMode::kSpecified: - Mode = (NMode::EEnum)dirType; - } - if (key.QueryValue(kWorkDirPath, Path) != ERROR_SUCCESS) - { - Path.Empty(); - if (Mode == NMode::kSpecified) - Mode = NMode::kSystem; - } - key.GetValue_IfOk(kTempRemovableOnly, ForRemovableOnly); -} - -} - -static const TCHAR *kCascadedMenu = TEXT("CascadedMenu"); -static const TCHAR *kContextMenu = TEXT("ContextMenu"); - -void CContextMenuInfo::Save() const -{ - CS_LOCK - CKey key; - CreateMainKey(key, kOptionsInfoKeyName); - key.SetValue(kCascadedMenu, Cascaded); - key.SetValue(kContextMenu, Flags); -} - -void CContextMenuInfo::Load() -{ - Cascaded = true; - Flags = (UInt32)-1; - CS_LOCK - CKey key; - if (OpenMainKey(key, kOptionsInfoKeyName) != ERROR_SUCCESS) - return; - key.GetValue_IfOk(kCascadedMenu, Cascaded); - key.GetValue_IfOk(kContextMenu, Flags); -} |