diff options
Diffstat (limited to 'CPP/7zip/UI/Far')
-rwxr-xr-x | CPP/7zip/UI/Far/ExtractEngine.cpp | 42 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/ExtractEngine.h | 31 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/Far.dsp | 4 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/FarUtils.cpp | 86 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/FarUtils.h | 34 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/Main.cpp | 248 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/Messages.h | 35 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/OverwriteDialog.cpp | 8 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/Plugin.cpp | 384 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/Plugin.h | 16 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/PluginCommon.cpp | 6 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/PluginDelete.cpp | 13 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/PluginRead.cpp | 65 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/PluginWrite.cpp | 98 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/ProgressBox.cpp | 142 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/ProgressBox.h | 27 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/UpdateCallback100.cpp | 21 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/UpdateCallback100.h | 31 | ||||
-rwxr-xr-x | CPP/7zip/UI/Far/makefile | 1 |
19 files changed, 738 insertions, 554 deletions
diff --git a/CPP/7zip/UI/Far/ExtractEngine.cpp b/CPP/7zip/UI/Far/ExtractEngine.cpp index 2ffb14c1..89dacf59 100755 --- a/CPP/7zip/UI/Far/ExtractEngine.cpp +++ b/CPP/7zip/UI/Far/ExtractEngine.cpp @@ -26,8 +26,8 @@ CExtractCallBackImp::~CExtractCallBackImp() void CExtractCallBackImp::Init( UINT codePage, - CProgressBox *progressBox, - bool passwordIsDefined, + CProgressBox *progressBox, + bool passwordIsDefined, const UString &password) { m_PasswordIsDefined = passwordIsDefined; @@ -36,28 +36,30 @@ void CExtractCallBackImp::Init( m_ProgressBox = progressBox; } -STDMETHODIMP CExtractCallBackImp::SetTotal(UINT64 size) +STDMETHODIMP CExtractCallBackImp::SetTotal(UInt64 size) { - if (m_ProgressBox != 0) - { - m_ProgressBox->SetTotal(size); - m_ProgressBox->PrintCompeteValue(0); - } + _total = size; + _totalIsDefined = true; return S_OK; } -STDMETHODIMP CExtractCallBackImp::SetCompleted(const UINT64 *completeValue) +STDMETHODIMP CExtractCallBackImp::SetCompleted(const UInt64 *completeValue) { - if(WasEscPressed()) + if (WasEscPressed()) return E_ABORT; - if (m_ProgressBox != 0 && completeValue != NULL) - m_ProgressBox->PrintCompeteValue(*completeValue); + _processedIsDefined = (completeValue != NULL); + if (_processedIsDefined) + _processed = *completeValue; + if (m_ProgressBox != 0) + m_ProgressBox->Progress( + _totalIsDefined ? &_total: NULL, + _processedIsDefined ? &_processed: NULL, AString()); return S_OK; } STDMETHODIMP CExtractCallBackImp::AskOverwrite( - const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize, - const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize, + const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize, + const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize, INT32 *answer) { NOverwriteDialog::CFileInfo oldFileInfo, newFileInfo; @@ -76,7 +78,7 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite( newFileInfo.Size = *newSize; newFileInfo.Name = GetSystemString(newName, m_CodePage); - NOverwriteDialog::NResult::EEnum result = + NOverwriteDialog::NResult::EEnum result = NOverwriteDialog::Execute(oldFileInfo, newFileInfo); switch(result) @@ -106,9 +108,9 @@ STDMETHODIMP CExtractCallBackImp::AskOverwrite( return S_OK; } -STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, bool /* isFolder */, INT32 /* askExtractMode */, const UINT64 * /* position */) +STDMETHODIMP CExtractCallBackImp::PrepareOperation(const wchar_t *name, bool /* isFolder */, INT32 /* askExtractMode */, const UInt64 * /* position */) { - if(WasEscPressed()) + if (WasEscPressed()) return E_ABORT; m_CurrentFilePath = name; return S_OK; @@ -137,12 +139,12 @@ STDMETHODIMP CExtractCallBackImp::SetOperationResult(INT32 operationResult, bool idMessage = NMessageID::kExtractUnsupportedMethod; break; case NArchive::NExtract::NOperationResult::kCRCError: - idMessage = encrypted ? + idMessage = encrypted ? NMessageID::kExtractCRCFailedEncrypted : NMessageID::kExtractCRCFailed; break; case NArchive::NExtract::NOperationResult::kDataError: - idMessage = encrypted ? + idMessage = encrypted ? NMessageID::kExtractDataErrorEncrypted : NMessageID::kExtractDataError; break; @@ -150,7 +152,7 @@ STDMETHODIMP CExtractCallBackImp::SetOperationResult(INT32 operationResult, bool return E_FAIL; } char buffer[512]; - const AString s = GetSystemString(m_CurrentFilePath, m_CodePage); + const AString s = UnicodeStringToMultiByte(m_CurrentFilePath, m_CodePage); sprintf(buffer, g_StartupInfo.GetMsgString(idMessage), (const char *)s); if (g_StartupInfo.ShowMessage(buffer) == -1) return E_ABORT; diff --git a/CPP/7zip/UI/Far/ExtractEngine.h b/CPP/7zip/UI/Far/ExtractEngine.h index 5cccf6ef..62486fb1 100755 --- a/CPP/7zip/UI/Far/ExtractEngine.h +++ b/CPP/7zip/UI/Far/ExtractEngine.h @@ -11,7 +11,7 @@ #include "ProgressBox.h" -class CExtractCallBackImp: +class CExtractCallBackImp: public IFolderArchiveExtractCallback, public ICryptoGetTextPassword, public CMyUnknownImp @@ -20,15 +20,15 @@ public: MY_UNKNOWN_IMP1(ICryptoGetTextPassword) // IProgress - STDMETHOD(SetTotal)(UINT64 size); - STDMETHOD(SetCompleted)(const UINT64 *completeValue); + STDMETHOD(SetTotal)(UInt64 size); + STDMETHOD(SetCompleted)(const UInt64 *completeValue); // IExtractCallBack STDMETHOD(AskOverwrite)( - const wchar_t *existName, const FILETIME *existTime, const UINT64 *existSize, - const wchar_t *newName, const FILETIME *newTime, const UINT64 *newSize, + const wchar_t *existName, const FILETIME *existTime, const UInt64 *existSize, + const wchar_t *newName, const FILETIME *newTime, const UInt64 *newSize, INT32 *result); - STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, INT32 askExtractMode, const UINT64 *position); + STDMETHOD (PrepareOperation)(const wchar_t *name, bool isFolder, INT32 askExtractMode, const UInt64 *position); STDMETHOD(MessageError)(const wchar_t *message); STDMETHOD(SetOperationResult)(INT32 resultEOperationResult, bool encrypted); @@ -36,14 +36,22 @@ public: STDMETHOD(CryptoGetTextPassword)(BSTR *password); private: + UInt64 _total; + UInt64 _processed; + + bool _totalIsDefined; + bool _processedIsDefined; + UString m_CurrentFilePath; + /* struct CProcessedFileInfo { - FILETIME UTCLastWriteTime; - bool IsDirectory; + FILETIME MTime; + bool isDir; UINT32 Attributes; } m_ProcessedFileInfo; + */ CProgressBox *m_ProgressBox; UINT m_CodePage; @@ -53,15 +61,16 @@ private: void CreateComplexDirectory(const UStringVector &dirPathParts); /* - void GetPropertyValue(LPITEMIDLIST anItemIDList, PROPID aPropId, + void GetPropertyValue(LPITEMIDLIST anItemIDList, PROPID aPropId, PROPVARIANT *aValue); bool IsEncrypted(LPITEMIDLIST anItemIDList); */ void AddErrorMessage(LPCTSTR message); public: + CExtractCallBackImp(): _totalIsDefined(false), _processedIsDefined(false) {} ~CExtractCallBackImp(); - void Init(UINT codePage, - CProgressBox *progressBox, + void Init(UINT codePage, + CProgressBox *progressBox, bool passwordIsDefined, const UString &password); }; diff --git a/CPP/7zip/UI/Far/Far.dsp b/CPP/7zip/UI/Far/Far.dsp index 17392f74..8c1d1357 100755 --- a/CPP/7zip/UI/Far/Far.dsp +++ b/CPP/7zip/UI/Far/Far.dsp @@ -336,6 +336,10 @@ SOURCE=..\..\..\Windows\Synchronization.cpp SOURCE=..\..\..\Windows\Synchronization.h # End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Time.cpp +# End Source File # End Group # Begin Group "UI Common" diff --git a/CPP/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp index c4a30524..e06bfe3e 100755 --- a/CPP/7zip/UI/Far/FarUtils.cpp +++ b/CPP/7zip/UI/Far/FarUtils.cpp @@ -15,7 +15,7 @@ namespace NFar { CStartupInfo g_StartupInfo; -void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo, +void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo, const CSysString &pliginNameForRegestry) { m_Data = pluginStartupInfo; @@ -29,18 +29,18 @@ const char *CStartupInfo::GetMsgString(int messageId) return (const char*)m_Data.GetMsg(m_Data.ModuleNumber, messageId); } -int CStartupInfo::ShowMessage(unsigned int flags, +int CStartupInfo::ShowMessage(unsigned int flags, const char *helpTopic, const char **items, int numItems, int numButtons) { - return m_Data.Message(m_Data.ModuleNumber, flags, (char *)helpTopic, + return m_Data.Message(m_Data.ModuleNumber, flags, (char *)helpTopic, (char **)items, numItems, numButtons); } namespace NMessageID { - enum + enum { - kOk, + kOk, kCancel, kWarning, kError @@ -49,10 +49,47 @@ namespace NMessageID int CStartupInfo::ShowMessage(const char *message) { - const char *messagesItems[]= { GetMsgString(NMessageID::kError), message, - GetMsgString(NMessageID::kOk) }; - return ShowMessage(FMSG_WARNING, NULL, messagesItems, - sizeof(messagesItems) / sizeof(messagesItems[0]), 1); + const char *items[]= { GetMsgString(NMessageID::kError), message, GetMsgString(NMessageID::kOk) }; + return ShowMessage(FMSG_WARNING, NULL, items, sizeof(items) / sizeof(items[0]), 1); +} + +static void SplitString(const AString &srcString, AStringVector &destStrings) +{ + destStrings.Clear(); + AString string; + int len = srcString.Length(); + if (len == 0) + return; + for (int i = 0; i < len; i++) + { + char c = srcString[i]; + if (c == '\n') + { + if (!string.IsEmpty()) + { + destStrings.Add(string); + string.Empty(); + } + } + else + string += c; + } + if (!string.IsEmpty()) + destStrings.Add(string); +} + +int CStartupInfo::ShowMessageLines(const char *message) +{ + AStringVector strings; + SplitString(message, strings); + const int kNumStringsMax = 20; + const char *items[kNumStringsMax + 1] = { GetMsgString(NMessageID::kError) }; + int pos = 1; + for (int i = 0; i < strings.Size() && pos < kNumStringsMax; i++) + items[pos++] = strings[i]; + items[pos++] = GetMsgString(NMessageID::kOk); + + return ShowMessage(FMSG_WARNING, NULL, items, pos, 1); } int CStartupInfo::ShowMessage(int messageId) @@ -60,10 +97,10 @@ int CStartupInfo::ShowMessage(int messageId) return ShowMessage(GetMsgString(messageId)); } -int CStartupInfo::ShowDialog(int X1, int Y1, int X2, int Y2, +int CStartupInfo::ShowDialog(int X1, int Y1, int X2, int Y2, const char *helpTopic, struct FarDialogItem *items, int numItems) { - return m_Data.Dialog(m_Data.ModuleNumber, X1, Y1, X2, Y2, (char *)helpTopic, + return m_Data.Dialog(m_Data.ModuleNumber, X1, Y1, X2, Y2, (char *)helpTopic, items, numItems); } @@ -75,7 +112,7 @@ int CStartupInfo::ShowDialog(int sizeX, int sizeY, inline static BOOL GetBOOLValue(bool v) { return (v? TRUE: FALSE); } -void CStartupInfo::InitDialogItems(const CInitDialogItem *srcItems, +void CStartupInfo::InitDialogItems(const CInitDialogItem *srcItems, FarDialogItem *destItems, int numItems) { for (int i = 0; i < numItems; i++) @@ -136,19 +173,19 @@ CSysString CStartupInfo::GetFullKeyName(const CSysString &keyName) const } -LONG CStartupInfo::CreateRegKey(HKEY parentKey, +LONG CStartupInfo::CreateRegKey(HKEY parentKey, const CSysString &keyName, NRegistry::CKey &destKey) const { return destKey.Create(parentKey, GetFullKeyName(keyName)); } -LONG CStartupInfo::OpenRegKey(HKEY parentKey, - const CSysString &keyName, NRegistry::CKey &destKey) const +LONG CStartupInfo::OpenRegKey(HKEY parentKey, + const CSysString &keyName, NRegistry::CKey &destKey) const { return destKey.Open(parentKey, GetFullKeyName(keyName)); } -void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, +void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, LPCTSTR valueName, LPCTSTR value) const { NRegistry::CKey regKey; @@ -156,7 +193,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, regKey.SetValue(valueName, value); } -void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, +void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, LPCTSTR valueName, UINT32 value) const { NRegistry::CKey regKey; @@ -164,7 +201,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, regKey.SetValue(valueName, value); } -void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, +void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, LPCTSTR valueName, bool value) const { NRegistry::CKey regKey; @@ -289,7 +326,7 @@ int CStartupInfo::Menu( struct FarMenuItem *items, int numItems) { - return m_Data.Menu(m_Data.ModuleNumber, x, y, maxHeight, flags, (char *)title, + return m_Data.Menu(m_Data.ModuleNumber, x, y, maxHeight, flags, (char *)title, (char *)aBottom, (char *)helpTopic, breakKeys, breakCode, items, numItems); } @@ -308,7 +345,7 @@ int CStartupInfo::Menu( unsigned int flags, const char *title, const char *helpTopic, - const CSysStringVector &items, + const CSysStringVector &items, int selectedItem) { CRecordVector<FarMenuItem> farMenuItems; @@ -368,9 +405,14 @@ void PrintErrorMessage(const char *message, int code) void PrintErrorMessage(const char *message, const char *text) { CSysString tmp = message; - tmp += ": "; + tmp += ":\n"; tmp += text; - g_StartupInfo.ShowMessage(tmp); + g_StartupInfo.ShowMessageLines(tmp); +} + +void PrintErrorMessage(const char *message, const wchar_t *text) +{ + PrintErrorMessage(message, UnicodeStringToMultiByte(text, CP_OEMCP)); } bool WasEscPressed() diff --git a/CPP/7zip/UI/Far/FarUtils.h b/CPP/7zip/UI/Far/FarUtils.h index 4e2f83cd..e0126cdc 100755 --- a/CPP/7zip/UI/Far/FarUtils.h +++ b/CPP/7zip/UI/Far/FarUtils.h @@ -49,37 +49,38 @@ class CStartupInfo CSysString m_RegistryPath; CSysString GetFullKeyName(const CSysString &keyName) const; - LONG CreateRegKey(HKEY parentKey, + LONG CreateRegKey(HKEY parentKey, const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const; - LONG OpenRegKey(HKEY parentKey, + LONG OpenRegKey(HKEY parentKey, const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const; public: - void Init(const PluginStartupInfo &pluginStartupInfo, + void Init(const PluginStartupInfo &pluginStartupInfo, const CSysString &pliginNameForRegestry); const char *GetMsgString(int messageId); - int ShowMessage(unsigned int flags, const char *helpTopic, + int ShowMessage(unsigned int flags, const char *helpTopic, const char **items, int numItems, int numButtons); int ShowMessage(const char *message); + int ShowMessageLines(const char *message); int ShowMessage(int messageId); - int ShowDialog(int X1, int Y1, int X2, int Y2, + int ShowDialog(int X1, int Y1, int X2, int Y2, const char *helpTopic, struct FarDialogItem *items, int numItems); int ShowDialog(int sizeX, int sizeY, const char *helpTopic, struct FarDialogItem *items, int numItems); - void InitDialogItems(const CInitDialogItem *srcItems, + void InitDialogItems(const CInitDialogItem *srcItems, FarDialogItem *destItems, int numItems); HANDLE SaveScreen(int X1, int Y1, int X2, int Y2); HANDLE SaveScreen(); void RestoreScreen(HANDLE handle); - void SetRegKeyValue(HKEY parentKey, const CSysString &keyName, + void SetRegKeyValue(HKEY parentKey, const CSysString &keyName, const LPCTSTR valueName, LPCTSTR value) const; - void SetRegKeyValue(HKEY hRoot, const CSysString &keyName, + void SetRegKeyValue(HKEY hRoot, const CSysString &keyName, const LPCTSTR valueName, UINT32 value) const; - void SetRegKeyValue(HKEY hRoot, const CSysString &keyName, + void SetRegKeyValue(HKEY hRoot, const CSysString &keyName, const LPCTSTR valueName, bool value) const; CSysString QueryRegKeyValue(HKEY parentKey, const CSysString &keyName, @@ -124,17 +125,17 @@ public: unsigned int flags, const char *title, const char *helpTopic, - const CSysStringVector &items, + const CSysStringVector &items, int selectedItem); - int Editor(const char *fileName, const char *title, + int Editor(const char *fileName, const char *title, int X1, int Y1, int X2, int Y2, DWORD flags, int startLine, int startChar) - { return m_Data.Editor((char *)fileName, (char *)title, X1, Y1, X2, Y2, + { return m_Data.Editor((char *)fileName, (char *)title, X1, Y1, X2, Y2, flags, startLine, startChar); } int Editor(const char *fileName) { return Editor(fileName, NULL, 0, 0, -1, -1, 0, -1, -1); } - int Viewer(const char *fileName, const char *title, + int Viewer(const char *fileName, const char *title, int X1, int Y1, int X2, int Y2, DWORD flags) { return m_Data.Viewer((char *)fileName, (char *)title, X1, Y1, X2, Y2, flags); } int Viewer(const char *fileName) @@ -157,7 +158,8 @@ public: extern CStartupInfo g_StartupInfo; void PrintErrorMessage(const char *message, int code); -void PrintErrorMessage(const char *message, const char *aText); +void PrintErrorMessage(const char *message, const char *text); +void PrintErrorMessage(const char *message, const wchar_t *text); #define MY_TRY_BEGIN try\ { @@ -170,8 +172,10 @@ void PrintErrorMessage(const char *message, const char *aText); #define MY_TRY_END2(x, y) }\ catch(int n) { PrintErrorMessage(x, n); return y; }\ - catch(const CSysString &s) { PrintErrorMessage(x, s); return y; }\ + catch(const AString &s) { PrintErrorMessage(x, s); return y; }\ catch(const char *s) { PrintErrorMessage(x, s); return y; }\ + catch(const UString &s) { PrintErrorMessage(x, s); return y; }\ + catch(const wchar_t *s) { PrintErrorMessage(x, s); return y; }\ catch(...) { g_StartupInfo.ShowMessage(x); return y; } bool WasEscPressed(); diff --git a/CPP/7zip/UI/Far/Main.cpp b/CPP/7zip/UI/Far/Main.cpp index 0409855d..39c84391 100755 --- a/CPP/7zip/UI/Far/Main.cpp +++ b/CPP/7zip/UI/Far/Main.cpp @@ -43,11 +43,11 @@ static const char *kHelpTopicConfig = "Config"; extern "C" { void WINAPI SetStartupInfo(struct PluginStartupInfo *info); - HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char *Data, + HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char *Data, unsigned int DataSize); HANDLE WINAPI OpenPlugin(int openFrom, int item); void WINAPI ClosePlugin(HANDLE plugin); - int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems, + int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelItems, int *itemsNumber, int OpMode); void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber); @@ -71,7 +71,7 @@ static bool IsItWindowsNT() { OSVERSIONINFO versionInfo; versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); - if (!::GetVersionEx(&versionInfo)) + if (!::GetVersionEx(&versionInfo)) return false; return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); } @@ -84,7 +84,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID) g_hInstance = hInstance; #ifndef _UNICODE g_IsNT = IsItWindowsNT(); - #endif + #endif } return TRUE; } @@ -96,19 +96,17 @@ static struct COptions static const char *kPliginNameForRegestry = "7-ZIP"; -// #define MY_TRY_BEGIN MY_TRY_BEGIN NCOM::CComInitializer aComInitializer; - void WINAPI SetStartupInfo(struct PluginStartupInfo *info) { MY_TRY_BEGIN; g_StartupInfo.Init(*info, kPliginNameForRegestry); g_Options.Enabled = g_StartupInfo.QueryRegKeyValue( - HKEY_CURRENT_USER, kRegisrtryMainKeyName, + HKEY_CURRENT_USER, kRegisrtryMainKeyName, kRegisrtryValueNameEnabled, kPluginEnabledDefault); MY_TRY_END1("SetStartupInfo"); } -class COpenArchiveCallback: +class COpenArchiveCallback: public IArchiveOpenCallback, public IArchiveOpenVolumeCallback, public IProgress, @@ -117,14 +115,20 @@ class COpenArchiveCallback: { DWORD m_StartTickValue; bool m_MessageBoxIsShown; - CMessageBox *m_MessageBox; - UINT64 m_NumFiles; - UINT64 m_NumFilesMax; - UINT64 m_NumFilesPrev; - bool m_NumFilesDefined; - UINT64 m_NumBytes; - bool m_NumBytesDefined; - UINT32 m_PrevTickCount; + + CProgressBox _progressBox; + + UInt64 _numFilesTotal; + UInt64 _numFilesCur; + UInt64 _numBytesTotal; + UInt64 _numBytesCur; + + bool _numFilesTotalDefined; + bool _numFilesCurDefined; + bool _numBytesTotalDefined; + bool _numBytesCurDefined; + + DWORD m_PrevTickCount; NWindows::NFile::NFind::CFileInfoW _fileInfo; public: @@ -141,12 +145,12 @@ public: ) // IProgress - STDMETHOD(SetTotal)(UINT64 total); - STDMETHOD(SetCompleted)(const UINT64 *aCompleteValue); + STDMETHOD(SetTotal)(UInt64 total); + STDMETHOD(SetCompleted)(const UInt64 *aCompleteValue); // IArchiveOpenCallback - STDMETHOD(SetTotal)(const UINT64 *numFiles, const UINT64 *numBytes); - STDMETHOD(SetCompleted)(const UINT64 *numFiles, const UINT64 *numBytes); + STDMETHOD(SetTotal)(const UInt64 *numFiles, const UInt64 *numBytes); + STDMETHOD(SetCompleted)(const UInt64 *numFiles, const UInt64 *numBytes); // IArchiveOpenVolumeCallback STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value); @@ -155,18 +159,21 @@ public: // ICryptoGetTextPassword STDMETHOD(CryptoGetTextPassword)(BSTR *password); - void Init(CMessageBox *messageBox) + void Init() { PasswordIsDefined = false; - m_NumFilesMax = 0; + _numFilesTotalDefined = false; + _numFilesCurDefined = false; + _numBytesTotalDefined = false; + _numBytesCurDefined = false; + m_MessageBoxIsShown = false; m_PrevTickCount = GetTickCount(); - m_MessageBox = messageBox; } - void ShowMessage(const UINT64 *completed); + void ShowMessage(); - void LoadFileInfo(const UString &folderPrefix, + void LoadFileInfo(const UString &folderPrefix, const UString &fileName) { _folderPrefix = folderPrefix; @@ -175,15 +182,17 @@ public: } }; -void COpenArchiveCallback::ShowMessage(const UINT64 *completed) +void COpenArchiveCallback::ShowMessage() { - UINT32 currentTime = GetTickCount(); + DWORD currentTime = GetTickCount(); if (!m_MessageBoxIsShown) { - if (currentTime - m_PrevTickCount < 400) + if (currentTime - m_PrevTickCount < 100) return; - m_MessageBox->Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), - g_StartupInfo.GetMsgString(NMessageID::kReading), 2, 30); + _progressBox.Init( + // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), + g_StartupInfo.GetMsgString(NMessageID::kReading), 48); + m_MessageBoxIsShown = true; } else @@ -192,72 +201,96 @@ void COpenArchiveCallback::ShowMessage(const UINT64 *completed) return; } m_PrevTickCount = currentTime; - char aMessage[256]; - sprintf(aMessage, "%5I64u", m_NumFilesMax); - char aMessage2[256]; - aMessage2[0] = '\0'; - if (completed != NULL) - sprintf(aMessage2, "%5I64u", *completed); - const char *aMessages[2] = - {aMessage, aMessage2 }; - m_MessageBox->ShowProcessMessages(aMessages); + + UInt64 total = 0, cur = 0; + bool curIsDefined = false, totalIsDefined = false; + + char message[256] = { 0 }; + if (_numFilesCurDefined) + ConvertUInt64ToStringAligned(_numFilesCur, message, 5); + + if (_numFilesTotalDefined) + { + strcat(message, " / "); + ConvertUInt64ToStringAligned(_numFilesTotal, message + strlen(message), 5); + total = _numFilesTotal; + totalIsDefined = true; + if (_numFilesCurDefined) + { + cur = _numFilesCur; + curIsDefined = true; + } + } + else if (_numBytesTotalDefined) + { + total = _numBytesTotal; + totalIsDefined = true; + if (_numBytesCurDefined) + { + cur = _numBytesCur; + curIsDefined = true; + } + } + _progressBox.Progress( + totalIsDefined ? &total: NULL, + curIsDefined ? &cur: NULL, + message); } -STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 *numFiles, const UINT64 *numBytes) +STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes) { if (WasEscPressed()) return E_ABORT; - m_NumFilesDefined = (numFiles != NULL); - if (m_NumFilesDefined) - m_NumFiles = *numFiles; - m_NumBytesDefined = (numBytes != NULL); - if (m_NumBytesDefined) - m_NumBytes = *numBytes; + + _numFilesTotalDefined = (numFiles != NULL); + if (_numFilesTotalDefined) + _numFilesTotal = *numFiles; + + _numBytesTotalDefined = (numBytes != NULL); + if (_numBytesTotalDefined) + _numBytesTotal = *numBytes; + return S_OK; } -STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 *numFiles, const UINT64 * /* numBytes */) +STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes) { if (WasEscPressed()) return E_ABORT; - if (numFiles == NULL) - return S_OK; - m_NumFilesMax = *numFiles; + + _numFilesCurDefined = (numFiles != NULL); + if (_numFilesCurDefined) + _numFilesCur = *numFiles; + + _numBytesCurDefined = (numBytes != NULL); + if (_numBytesCurDefined) + _numBytesCur = *numBytes; + // if (*numFiles % 100 != 0) // return S_OK; - ShowMessage(NULL); + ShowMessage(); return S_OK; } -STDMETHODIMP COpenArchiveCallback::SetTotal(const UINT64 /* total */) +STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 /* total */) { if (WasEscPressed()) return E_ABORT; - /* - aNumFilesDefined = (numFiles != NULL); - if (aNumFilesDefined) - aNumFiles = *numFiles; - aNumBytesDefined = (numBytes != NULL); - if (aNumBytesDefined) - aNumBytes = *numBytes; - */ return S_OK; } -STDMETHODIMP COpenArchiveCallback::SetCompleted(const UINT64 *completed) +STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed) { if (WasEscPressed()) return E_ABORT; if (completed == NULL) return S_OK; - // if (*completed % 100 != 0) - // return S_OK; - ShowMessage(completed); + ShowMessage(); return S_OK; } -STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, +STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream) { if (WasEscPressed()) @@ -266,7 +299,7 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, UString fullPath = _folderPrefix + name; if (!NWindows::NFile::NFind::FindFile(fullPath, _fileInfo)) return S_FALSE; - if (_fileInfo.IsDirectory()) + if (_fileInfo.IsDir()) return S_FALSE; CInFileStream *inFile = new CInFileStream; CMyComPtr<IInStream> inStreamTemp = inFile; @@ -279,32 +312,18 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value) { - NWindows::NCOM::CPropVariant propVariant; + NWindows::NCOM::CPropVariant prop; switch(propID) { - case kpidName: - propVariant = GetUnicodeString(_fileInfo.Name, CP_OEMCP); - break; - case kpidIsFolder: - propVariant = _fileInfo.IsDirectory(); - break; - case kpidSize: - propVariant = _fileInfo.Size; - break; - case kpidAttributes: - propVariant = (UINT32)_fileInfo.Attributes; - break; - case kpidLastAccessTime: - propVariant = _fileInfo.LastAccessTime; - break; - case kpidCreationTime: - propVariant = _fileInfo.CreationTime; - break; - case kpidLastWriteTime: - propVariant = _fileInfo.LastWriteTime; - break; + case kpidName: prop = GetUnicodeString(_fileInfo.Name, CP_OEMCP); break; + case kpidIsDir: prop = _fileInfo.IsDir(); break; + case kpidSize: prop = _fileInfo.Size; break; + case kpidAttrib: prop = (UInt32)_fileInfo.Attrib; break; + case kpidCTime: prop = _fileInfo.CTime; break; + case kpidATime: prop = _fileInfo.ATime; break; + case kpidMTime: prop = _fileInfo.MTime; break; } - propVariant.Detach(value); + prop.Detach(value); return S_OK; } @@ -315,7 +334,7 @@ HRESULT GetPassword(UString &password) password.Empty(); CInitDialogItem initItems[]= { - { DI_DOUBLEBOX, 3, 1, 72, 4, false, false, 0, false, NMessageID::kGetPasswordTitle, NULL, NULL }, + { DI_DOUBLEBOX, 3, 1, 72, 4, false, false, 0, false, NMessageID::kGetPasswordTitle, NULL, NULL }, { DI_TEXT, 5, 2, 0, 0, false, false, DIF_SHOWAMPERSAND, false, NMessageID::kEnterPasswordForFile, NULL, NULL }, { DI_PSWEDIT, 5, 3, 70, 3, true, false, 0, true, -1, "", NULL } }; @@ -329,7 +348,7 @@ HRESULT GetPassword(UString &password) return (E_ABORT); AString oemPassword = dialogItems[2].Data; - password = MultiByteToUnicodeString(oemPassword, CP_OEMCP); + password = MultiByteToUnicodeString(oemPassword, CP_OEMCP); return S_OK; } @@ -346,14 +365,14 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) } /* -HRESULT OpenArchive(const CSysString &fileName, - IInFolderArchive **archiveHandlerResult, +HRESULT OpenArchive(const CSysString &fileName, + IInFolderArchive **archiveHandlerResult, CArchiverInfo &archiverInfoResult, UString &defaultName, IArchiveOpenCallback *openArchiveCallback) { - HRESULT OpenArchive(const CSysString &fileName, - IInArchive **archive, + HRESULT OpenArchive(const CSysString &fileName, + IInArchive **archive, CArchiverInfo &archiverInfoResult, IArchiveOpenCallback *openArchiveCallback); } @@ -371,7 +390,7 @@ static HANDLE MyOpenFilePlugin(const char *name) NFile::NFind::CFileInfoW fileInfo; if (!NFile::NFind::FindFile(fullName, fileInfo)) return INVALID_HANDLE_VALUE; - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) return INVALID_HANDLE_VALUE; @@ -380,19 +399,18 @@ static HANDLE MyOpenFilePlugin(const char *name) // CArchiverInfo archiverInfoResult; // ::OutputDebugString("before OpenArchive\n"); - COpenArchiveCallback *openArchiveCallbackSpec = new COpenArchiveCallback; - - CMyComPtr<IArchiveOpenCallback> openArchiveCallback = openArchiveCallbackSpec; - - // if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0) CScreenRestorer screenRestorer; - CMessageBox m_MessageBox; { screenRestorer.Save(); } - openArchiveCallbackSpec->Init(&m_MessageBox); + + COpenArchiveCallback *openArchiveCallbackSpec = new COpenArchiveCallback; + CMyComPtr<IArchiveOpenCallback> openArchiveCallback = openArchiveCallbackSpec; + + // if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0) + openArchiveCallbackSpec->Init(); openArchiveCallbackSpec->LoadFileInfo( - fullName.Left(fileNamePartStartIndex), + fullName.Left(fileNamePartStartIndex), fullName.Mid(fileNamePartStartIndex)); // ::OutputDebugString("before OpenArchive\n"); @@ -402,7 +420,7 @@ static HANDLE MyOpenFilePlugin(const char *name) HRESULT result = archiveHandler->Open( GetUnicodeString(fullName, CP_OEMCP), &archiveType, openArchiveCallback); /* - HRESULT result = ::OpenArchive(fullName, &archiveHandler, + HRESULT result = ::OpenArchive(fullName, &archiveHandler, archiverInfoResult, defaultName, openArchiveCallback); */ if (result != S_OK) @@ -415,8 +433,8 @@ static HANDLE MyOpenFilePlugin(const char *name) // ::OutputDebugString("after OpenArchive\n"); CPlugin *plugin = new CPlugin( - fullName, - // defaultName, + fullName, + // defaultName, archiveHandler, (const wchar_t *)archiveType ); @@ -428,7 +446,7 @@ static HANDLE MyOpenFilePlugin(const char *name) return (HANDLE)(plugin); } -HANDLE WINAPI OpenFilePlugin(char *name, +HANDLE WINAPI OpenFilePlugin(char *name, const unsigned char * /* data */, unsigned int /* dataSize */) { MY_TRY_BEGIN; @@ -449,7 +467,7 @@ HANDLE WINAPI OpenPlugin(int openFrom, int item) CSysString fileName = (const char *)(UINT_PTR)item; if(fileName.IsEmpty()) return INVALID_HANDLE_VALUE; - if (fileName.Length() >= 2 && + if (fileName.Length() >= 2 && fileName[0] == '\"' && fileName[fileName.Length() - 1] == '\"') fileName = fileName.Mid(1, fileName.Length() - 2); @@ -509,13 +527,13 @@ void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, { MY_TRY_BEGIN; ((CPlugin *)plugin)->FreeFindData(panelItems, itemsNumber); - MY_TRY_END1("FreeFindData"); + MY_TRY_END1("FreeFindData"); } int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber, int move, char *destPath, int opMode) { - MY_TRY_BEGIN; + MY_TRY_BEGIN; return(((CPlugin *)plugin)->GetFiles(panelItems, itemsNumber, move, destPath, opMode)); MY_TRY_END2("GetFiles", NFileOperationReturnCode::kError); } @@ -546,7 +564,7 @@ void WINAPI GetPluginInfo(struct PluginInfo *info) info->PluginConfigStrings = (char **)pluginCfgStrings; info->PluginConfigStringsNumber = sizeof(pluginCfgStrings) / sizeof(pluginCfgStrings[0]); info->CommandPrefix = (char *)kCommandPrefix; - MY_TRY_END1("GetPluginInfo"); + MY_TRY_END1("GetPluginInfo"); } int WINAPI Configure(int /* itemNumber */) @@ -572,7 +590,7 @@ int WINAPI Configure(int /* itemNumber */) FarDialogItem dialogItems[kNumDialogItems]; g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems); - int askCode = g_StartupInfo.ShowDialog(76, kYSize, + int askCode = g_StartupInfo.ShowDialog(76, kYSize, kHelpTopicConfig, dialogItems, kNumDialogItems); if (askCode != kOkButtonIndex) @@ -590,7 +608,7 @@ void WINAPI GetOpenPluginInfo(HANDLE plugin,struct OpenPluginInfo *info) { MY_TRY_BEGIN; ((CPlugin *)plugin)->GetOpenPluginInfo(info); - MY_TRY_END1("GetOpenPluginInfo"); + MY_TRY_END1("GetOpenPluginInfo"); } int WINAPI PutFiles(HANDLE plugin, struct PluginPanelItem *panelItems, @@ -606,7 +624,7 @@ int WINAPI DeleteFiles(HANDLE plugin, PluginPanelItem *panelItems, { MY_TRY_BEGIN; return(((CPlugin *)plugin)->DeleteFiles(panelItems, itemsNumber, opMode)); - MY_TRY_END2("DeleteFiles", FALSE); + MY_TRY_END2("DeleteFiles", FALSE); } int WINAPI ProcessKey(HANDLE plugin, int key, unsigned int controlState) diff --git a/CPP/7zip/UI/Far/Messages.h b/CPP/7zip/UI/Far/Messages.h index 9d3060a1..1281b235 100755 --- a/CPP/7zip/UI/Far/Messages.h +++ b/CPP/7zip/UI/Far/Messages.h @@ -7,7 +7,7 @@ namespace NMessageID { enum EEnum { - kOk, + kOk, kCancel, kWarning, @@ -24,22 +24,22 @@ enum EEnum kExtension, kIsFolder, kSize, - kPackedSize, + kPackSize, kAttributes, - kCreationTime, - kLastAccessTime, - kLastWriteTime, - kSolid, - kCommented, - kEncrypted, - kSplitBefore, + kCTime, + kATime, + kMTime, + kSolid, + kCommented, + kEncrypted, + kSplitBefore, kSplitAfter, - kDictionarySize, - kCRC, + kDictionarySize, + kCRC, kType, kAnti, - kMethod, - kHostOS, + kMethod, + kHostOS, kFileSystem, kUser, kGroup, @@ -56,6 +56,15 @@ enum EEnum kNumBlocks, kNumVolumes, + kBit64, + kBigEndian, + kCpu, + kPhySize, + kHeadersSize, + kChecksum, + kCharacts, + kVa, + kGetPasswordTitle, kEnterPasswordForFile, diff --git a/CPP/7zip/UI/Far/OverwriteDialog.cpp b/CPP/7zip/UI/Far/OverwriteDialog.cpp index 9272942f..6935fa10 100755 --- a/CPP/7zip/UI/Far/OverwriteDialog.cpp +++ b/CPP/7zip/UI/Far/OverwriteDialog.cpp @@ -27,7 +27,7 @@ struct CFileInfoStrings }; void SetFileInfoStrings(const CFileInfo &fileInfo, - CFileInfoStrings &fileInfoStrings) + CFileInfoStrings &fileInfoStrings) { char buffer[256]; @@ -70,7 +70,7 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf { DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kOverwriteTitle, NULL, NULL }, { DI_TEXT, 5, 2, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessage1, NULL, NULL }, - { DI_TEXT, 3, 3, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, + { DI_TEXT, 3, 3, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, { DI_TEXT, 5, 4, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWouldYouLike, NULL, NULL }, @@ -84,7 +84,7 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf { DI_TEXT, 7, 13, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Size, NULL }, { DI_TEXT, 7, 14, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Time, NULL }, - { DI_TEXT, 3, kYSize - 5, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, + { DI_TEXT, 3, kYSize - 5, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, { DI_BUTTON, 0, kYSize - 4, 0, 0, true, false, DIF_CENTERGROUP, true, NMessageID::kOverwriteYes, NULL, NULL }, { DI_BUTTON, 0, kYSize - 4, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kOverwriteYesToAll, NULL, NULL }, @@ -97,7 +97,7 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf const int kNumDialogItems = sizeof(anInitItems) / sizeof(anInitItems[0]); FarDialogItem aDialogItems[kNumDialogItems]; g_StartupInfo.InitDialogItems(anInitItems, aDialogItems, kNumDialogItems); - int anAskCode = g_StartupInfo.ShowDialog(kXSize, kYSize, + int anAskCode = g_StartupInfo.ShowDialog(kXSize, kYSize, NULL, aDialogItems, kNumDialogItems); const int kButtonStartPos = kNumDialogItems - 6; if (anAskCode >= kButtonStartPos && anAskCode < kNumDialogItems) diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp index 40851c0c..65253f01 100755 --- a/CPP/7zip/UI/Far/Plugin.cpp +++ b/CPP/7zip/UI/Far/Plugin.cpp @@ -4,34 +4,24 @@ #include "Plugin.h" +#include "Common/IntToString.h" #include "Common/StringConvert.h" #include "Common/Wildcard.h" -#include "Windows/PropVariantConversions.h" -#include "Windows/FileName.h" #include "Windows/FileDir.h" +#include "Windows/FileName.h" +#include "Windows/PropVariantConversions.h" #include "../Common/PropIDUtils.h" -#include "Messages.h" #include "FarUtils.h" +#include "Messages.h" using namespace NWindows; using namespace NFar; -CSysString ConvertPropertyToString2(const PROPVARIANT &propVariant, PROPID propID) -{ - if (propVariant.vt == VT_BSTR) - return GetSystemString(propVariant.bstrVal, CP_OEMCP); - if (propVariant.vt != VT_BOOL) - return GetSystemString(ConvertPropertyToString(propVariant, propID), CP_OEMCP); - int messageID = VARIANT_BOOLToBool(propVariant.boolVal) ? - NMessageID::kYes : NMessageID::kNo; - return g_StartupInfo.GetMsgString(messageID); -} - -CPlugin::CPlugin(const UString &fileName, - // const UString &defaultName, +CPlugin::CPlugin(const UString &fileName, + // const UString &defaultName, IInFolderArchive *archiveHandler, UString archiveTypeName ): @@ -53,19 +43,19 @@ CPlugin::~CPlugin() static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex, PROPID propID, FILETIME &fileTime) { - NCOM::CPropVariant propVariant; - if (anArchiveFolder->GetProperty(itemIndex, propID, &propVariant) != S_OK) + NCOM::CPropVariant prop; + if (anArchiveFolder->GetProperty(itemIndex, propID, &prop) != S_OK) throw 271932; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) { fileTime.dwHighDateTime = 0; fileTime.dwLowDateTime = 0; } - else + else { - if (propVariant.vt != VT_FILETIME) + if (prop.vt != VT_FILETIME) throw 4191730; - fileTime = propVariant.filetime; + fileTime = prop.filetime; } } @@ -74,14 +64,14 @@ static void MyGetFileTime(IFolderFolder *anArchiveFolder, UInt32 itemIndex, void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) { - NCOM::CPropVariant propVariant; - if (_folder->GetProperty(itemIndex, kpidName, &propVariant) != S_OK) + NCOM::CPropVariant prop; + if (_folder->GetProperty(itemIndex, kpidName, &prop) != S_OK) throw 271932; - if (propVariant.vt != VT_BSTR) + if (prop.vt != VT_BSTR) throw 272340; - CSysString oemString = UnicodeStringToMultiByte(propVariant.bstrVal, CP_OEMCP); + CSysString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP); const int kFileNameSizeMax = (int)(sizeof(panelItem.FindData.cFileName) / sizeof(panelItem.FindData.cFileName[0]) - 1); if (oemString.Length() > kFileNameSizeMax) oemString = oemString.Left(kFileNameSizeMax); @@ -92,49 +82,49 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) MyStringCopy(panelItem.FindData.cFileName, (const char *)oemString); panelItem.FindData.cAlternateFileName[0] = 0; - if (_folder->GetProperty(itemIndex, kpidAttributes, &propVariant) != S_OK) + if (_folder->GetProperty(itemIndex, kpidAttrib, &prop) != S_OK) throw 271932; - if (propVariant.vt == VT_UI4) - panelItem.FindData.dwFileAttributes = propVariant.ulVal; - else if (propVariant.vt == VT_EMPTY) - panelItem.FindData.dwFileAttributes = m_FileInfo.Attributes; + if (prop.vt == VT_UI4) + panelItem.FindData.dwFileAttributes = prop.ulVal; + else if (prop.vt == VT_EMPTY) + panelItem.FindData.dwFileAttributes = m_FileInfo.Attrib; else throw 21631; - if (_folder->GetProperty(itemIndex, kpidIsFolder, &propVariant) != S_OK) + if (_folder->GetProperty(itemIndex, kpidIsDir, &prop) != S_OK) throw 271932; - if (propVariant.vt == VT_BOOL) + if (prop.vt == VT_BOOL) { - if (VARIANT_BOOLToBool(propVariant.boolVal)) + if (VARIANT_BOOLToBool(prop.boolVal)) panelItem.FindData.dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY; } - else if (propVariant.vt != VT_EMPTY) + else if (prop.vt != VT_EMPTY) throw 21632; - if (_folder->GetProperty(itemIndex, kpidSize, &propVariant) != S_OK) + if (_folder->GetProperty(itemIndex, kpidSize, &prop) != S_OK) throw 271932; UInt64 length; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) length = 0; else - length = ::ConvertPropVariantToUInt64(propVariant); + length = ::ConvertPropVariantToUInt64(prop); panelItem.FindData.nFileSizeLow = (UInt32)length; panelItem.FindData.nFileSizeHigh = (UInt32)(length >> 32); - MyGetFileTime(_folder, itemIndex, kpidCreationTime, panelItem.FindData.ftCreationTime); - MyGetFileTime(_folder, itemIndex, kpidLastAccessTime, panelItem.FindData.ftLastAccessTime); - MyGetFileTime(_folder, itemIndex, kpidLastWriteTime, panelItem.FindData.ftLastWriteTime); + MyGetFileTime(_folder, itemIndex, kpidCTime, panelItem.FindData.ftCreationTime); + MyGetFileTime(_folder, itemIndex, kpidATime, panelItem.FindData.ftLastAccessTime); + MyGetFileTime(_folder, itemIndex, kpidMTime, panelItem.FindData.ftLastWriteTime); - if (panelItem.FindData.ftLastWriteTime.dwHighDateTime == 0 && + if (panelItem.FindData.ftLastWriteTime.dwHighDateTime == 0 && panelItem.FindData.ftLastWriteTime.dwLowDateTime == 0) - panelItem.FindData.ftLastWriteTime = m_FileInfo.LastWriteTime; + panelItem.FindData.ftLastWriteTime = m_FileInfo.MTime; - if (_folder->GetProperty(itemIndex, kpidPackedSize, &propVariant) != S_OK) + if (_folder->GetProperty(itemIndex, kpidPackSize, &prop) != S_OK) throw 271932; - if (propVariant.vt == VT_EMPTY) + if (prop.vt == VT_EMPTY) length = 0; else - length = ::ConvertPropVariantToUInt64(propVariant); + length = ::ConvertPropVariantToUInt64(prop); panelItem.PackSize = UInt32(length); panelItem.PackSizeHigh = UInt32(length >> 32); @@ -151,7 +141,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) panelItem.Reserved[2] = 0; } -int CPlugin::GetFindData(PluginPanelItem **panelItems, +int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode) { // CScreenRestorer screenRestorer; @@ -221,12 +211,12 @@ int CPlugin::SetDirectory(const char *aszDir, int /* opMode */) if (path == L"\\") { _folder.Release(); - m_ArchiveHandler->BindToRootFolder(&_folder); + m_ArchiveHandler->BindToRootFolder(&_folder); } else if (path == L"..") { CMyComPtr<IFolderFolder> newFolder; - _folder->BindToParentFolder(&newFolder); + _folder->BindToParentFolder(&newFolder); if (newFolder == NULL) throw 40312; _folder = newFolder; @@ -238,7 +228,7 @@ int CPlugin::SetDirectory(const char *aszDir, int /* opMode */) if (path[0] == L'\\') { _folder.Release(); - m_ArchiveHandler->BindToRootFolder(&_folder); + m_ArchiveHandler->BindToRootFolder(&_folder); path = path.Mid(1); } UStringVector pathParts; @@ -257,7 +247,7 @@ void CPlugin::GetPathParts(UStringVector &pathParts) for (;;) { CMyComPtr<IFolderFolder> newFolder; - folderItem->BindToParentFolder(&newFolder); + folderItem->BindToParentFolder(&newFolder); if (newFolder == NULL) break; NCOM::CPropVariant prop; @@ -289,17 +279,17 @@ struct CPROPIDToName int PluginID; }; -static CPROPIDToName kPROPIDToName[] = +static CPROPIDToName kPROPIDToName[] = { { kpidName, NMessageID::kName }, { kpidExtension, NMessageID::kExtension }, - { kpidIsFolder, NMessageID::kIsFolder }, + { kpidIsDir, NMessageID::kIsFolder }, { kpidSize, NMessageID::kSize }, - { kpidPackedSize, NMessageID::kPackedSize }, - { kpidAttributes, NMessageID::kAttributes }, - { kpidCreationTime, NMessageID::kCreationTime }, - { kpidLastAccessTime, NMessageID::kLastAccessTime }, - { kpidLastWriteTime, NMessageID::kLastWriteTime }, + { kpidPackSize, NMessageID::kPackSize }, + { kpidAttrib, NMessageID::kAttributes }, + { kpidCTime, NMessageID::kCTime }, + { kpidATime, NMessageID::kATime }, + { kpidMTime, NMessageID::kMTime }, { kpidSolid, NMessageID::kSolid }, { kpidCommented, NMessageID::kCommented }, { kpidEncrypted, NMessageID::kEncrypted }, @@ -317,7 +307,7 @@ static CPROPIDToName kPROPIDToName[] = { kpidBlock, NMessageID::kBlock }, { kpidComment, NMessageID::kComment }, { kpidPosition, NMessageID::kPosition }, - { kpidNumSubFolders, NMessageID::kNumSubFolders }, + { kpidNumSubDirs, NMessageID::kNumSubFolders }, { kpidNumSubFiles, NMessageID::kNumSubFiles }, { kpidUnpackVer, NMessageID::kUnpackVer }, { kpidVolume, NMessageID::kVolume }, @@ -325,7 +315,16 @@ static CPROPIDToName kPROPIDToName[] = { kpidOffset, NMessageID::kOffset }, { kpidLinks, NMessageID::kLinks }, { kpidNumBlocks, NMessageID::kNumBlocks }, - { kpidNumVolumes, NMessageID::kNumVolumes } + { kpidNumVolumes, NMessageID::kNumVolumes }, + + { kpidBit64, NMessageID::kBit64 }, + { kpidBigEndian, NMessageID::kBigEndian }, + { kpidCpu, NMessageID::kCpu }, + { kpidPhySize, NMessageID::kPhySize }, + { kpidHeadersSize, NMessageID::kHeadersSize }, + { kpidChecksum, NMessageID::kChecksum }, + { kpidCharacts, NMessageID::kCharacts }, + { kpidVa, NMessageID::kVa } }; static const int kNumPROPIDToName = sizeof(kPROPIDToName) / sizeof(kPROPIDToName[0]); @@ -347,15 +346,15 @@ struct CPropertyIDInfo // char CharID; }; -static CPropertyIDInfo kPropertyIDInfos[] = +static CPropertyIDInfo kPropertyIDInfos[] = { { kpidName, "N", 0}, { kpidSize, "S", 8}, { kpidPackedSize, "P", 8}, - { kpidAttributes, "A", 0}, - { kpidCreationTime, "DC", 14}, - { kpidLastAccessTime, "DA", 14}, - { kpidLastWriteTime, "DM", 14}, + { kpidAttrib, "A", 0}, + { kpidCTime, "DC", 14}, + { kpidATime, "DA", 14}, + { kpidMTime, "DM", 14}, { kpidSolid, NULL, 0, 'S'}, { kpidEncrypted, NULL, 0, 'P'} @@ -368,7 +367,7 @@ static CPropertyIDInfo kPropertyIDInfos[] = // { kpidType, L"Type" } }; -static const int kNumPropertyIDInfos = sizeof(kPropertyIDInfos) / +static const int kNumPropertyIDInfos = sizeof(kPropertyIDInfos) / sizeof(kPropertyIDInfos[0]); static int FindPropertyInfo(PROPID propID) @@ -415,6 +414,88 @@ void CPlugin::AddColumn(PROPID propID) } */ +static AString GetNameOfProp(PROPID propID, const wchar_t *name) +{ + int index = FindPropertyToName(propID); + if (index < 0) + { + if (name) + return UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP); + char s[32]; + ConvertUInt64ToString(propID, s); + return s; + } + return g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID); +} + +static AString GetNameOfProp2(PROPID propID, const wchar_t *name) +{ + AString s = GetNameOfProp(propID, name); + if (s.Length() > (kInfoPanelLineSize - 1)) + s = s.Left(kInfoPanelLineSize - 1); + return s; +} + +static AString ConvertSizeToString(UInt64 value) +{ + char s[32]; + ConvertUInt64ToString(value, s); + int i = MyStringLen(s); + int pos = sizeof(s) / sizeof(s[0]); + s[--pos] = L'\0'; + while (i > 3) + { + s[--pos] = s[--i]; + s[--pos] = s[--i]; + s[--pos] = s[--i]; + s[--pos] = ' '; + } + while (i > 0) + s[--pos] = s[--i]; + return s + pos; +} + +static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID) +{ + AString s; + + if (prop.vt == VT_BSTR) + s = GetSystemString(prop.bstrVal, CP_OEMCP); + else if (prop.vt == VT_BOOL) + { + int messageID = VARIANT_BOOLToBool(prop.boolVal) ? + NMessageID::kYes : NMessageID::kNo; + return g_StartupInfo.GetMsgString(messageID); + } + else if (prop.vt != VT_EMPTY) + { + if (( + propID == kpidSize || + propID == kpidPackSize || + propID == kpidNumSubDirs || + propID == kpidNumSubFiles || + propID == kpidNumBlocks || + propID == kpidPhySize || + propID == kpidHeadersSize || + propID == kpidClusterSize + ) && (prop.vt == VT_UI8 || prop.vt == VT_UI4)) + s = ConvertSizeToString(ConvertPropVariantToUInt64(prop)); + else + s = UnicodeStringToMultiByte(ConvertPropertyToString(prop, propID), CP_OEMCP); + } + s.Replace((char)0xA, ' '); + s.Replace((char)0xD, ' '); + return s; +} + +static AString PropToString2(const NCOM::CPropVariant &prop, PROPID propID) +{ + AString s = PropToString(prop, propID); + if (s.Length() > (kInfoPanelLineSize - 1)) + s = s.Left(kInfoPanelLineSize - 1); + return s; +} + void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) { info->StructSize = sizeof(*info); @@ -439,10 +520,10 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) name = fullName.Mid(index); } - m_PannelTitle = - UString(L' ') + - _archiveTypeName + - UString(L':') + + m_PannelTitle = + UString(L' ') + + _archiveTypeName + + UString(L':') + name + UString(L' '); if (!m_CurrentDir.IsEmpty()) @@ -463,46 +544,73 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) int numItems = 2; - CMyComPtr<IFolderProperties> folderProperties; - _folder.QueryInterface(IID_IFolderProperties, &folderProperties); - if (folderProperties) { - UInt32 numProps; - if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK) + CMyComPtr<IFolderProperties> folderProperties; + _folder.QueryInterface(IID_IFolderProperties, &folderProperties); + if (folderProperties) + { + UInt32 numProps; + if (folderProperties->GetNumberOfFolderProperties(&numProps) == S_OK) + { + for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++) + { + CMyComBSTR name; + PROPID propID; + VARTYPE vt; + if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK) + continue; + NCOM::CPropVariant prop; + if (_folder->GetFolderProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY) + continue; + + InfoPanelLine &item = m_InfoLines[numItems++]; + MyStringCopy(item.Text, (const char *)GetNameOfProp2(propID, name)); + MyStringCopy(item.Data, (const char *)PropToString2(prop, propID)); + } + } + } + } + + if (numItems < kNumInfoLinesMax) + { + InfoPanelLine &item = m_InfoLines[numItems++]; + MyStringCopy(item.Text, ""); + MyStringCopy(item.Data, ""); + item.Separator = TRUE; + } + + { + CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties; + _folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties); + if (getFolderArchiveProperties) { - for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++) + CMyComPtr<IFolderArchiveProperties> getProps; + getFolderArchiveProperties->GetFolderArchiveProperties(&getProps); + if (getProps) { - CMyComBSTR name; - PROPID propID; - VARTYPE vt; - if (folderProperties->GetFolderPropertyInfo(i, &name, &propID, &vt) != S_OK) - continue; - - InfoPanelLine &item = m_InfoLines[numItems]; - int index = FindPropertyToName(propID); - AString s; - if (index < 0) + UInt32 numProps; + if (getProps->GetNumberOfArchiveProperties(&numProps) == S_OK) { - if (name != 0) - s = (const char *)UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP); + /* + if (numProps > 0) + message += kSeparator; + */ + for (UInt32 i = 0; i < numProps && numItems < kNumInfoLinesMax; i++) + { + CMyComBSTR name; + PROPID propID; + VARTYPE vt; + if (getProps->GetArchivePropertyInfo(i, &name, &propID, &vt) != S_OK) + continue; + NCOM::CPropVariant prop; + if (getProps->GetArchiveProperty(propID, &prop) != S_OK || prop.vt == VT_EMPTY) + continue; + InfoPanelLine &item = m_InfoLines[numItems++]; + MyStringCopy(item.Text, (const char *)GetNameOfProp2(propID, name)); + MyStringCopy(item.Data, (const char *)PropToString2(prop, propID)); + + } } - else - s = g_StartupInfo.GetMsgString(kPROPIDToName[index].PluginID); - - if (s.Length() > (kInfoPanelLineSize - 1)) - s = s.Left(kInfoPanelLineSize - 1); - MyStringCopy(item.Text, (const char *)s); - - NCOM::CPropVariant propVariant; - if (_folder->GetFolderProperty(propID, &propVariant) != S_OK) - continue; - s = ConvertPropertyToString2(propVariant, propID); - s.Replace((char)0xA, ' '); - s.Replace((char)0xD, ' '); - if (s.Length() > (kInfoPanelLineSize - 1)) - s = s.Left(kInfoPanelLineSize - 1); - MyStringCopy(item.Data, (const char *)s); - numItems++; } } } @@ -523,10 +631,10 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) AddColumn(kpidName); AddColumn(kpidSize); AddColumn(kpidPackedSize); - AddColumn(kpidLastWriteTime); - AddColumn(kpidCreationTime); - AddColumn(kpidLastAccessTime); - AddColumn(kpidAttributes); + AddColumn(kpidMTime); + AddColumn(kpidCTime); + AddColumn(kpidATime); + AddColumn(kpidAttrib); PanelMode.ColumnTypes = (char *)(const char *)PanelModeColumnTypes; PanelMode.ColumnWidths = (char *)(const char *)PanelModeColumnWidths; @@ -565,8 +673,8 @@ HRESULT CPlugin::ShowAttributesWindow() PluginPanelItem pluginPanelItem; if (!g_StartupInfo.ControlGetActivePanelCurrentItemInfo(pluginPanelItem)) return S_FALSE; - if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 && - NFile::NFind::NAttributes::IsDirectory(pluginPanelItem.FindData.dwFileAttributes)) + if (strcmp(pluginPanelItem.FindData.cFileName, "..") == 0 && + NFile::NFind::NAttributes::IsDir(pluginPanelItem.FindData.dwFileAttributes)) return S_FALSE; int itemIndex = pluginPanelItem.UserData; @@ -580,63 +688,57 @@ HRESULT CPlugin::ShowAttributesWindow() PROPID propID; VARTYPE vt; RINOK(_folder->GetPropertyInfo(i, &name, &propID, &vt)); - CArchiveItemProperty destProperty; - destProperty.Type = vt; - destProperty.ID = propID; - if (destProperty.ID == kpidPath) - destProperty.ID = kpidName; - AString propName; - { - if (name != NULL) - destProperty.Name = UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP); - else - destProperty.Name = "?"; - } - properties.Add(destProperty); + CArchiveItemProperty prop; + prop.Type = vt; + prop.ID = propID; + if (prop.ID == kpidPath) + prop.ID = kpidName; + prop.Name = GetNameOfProp(propID, name); + properties.Add(prop); } int size = 2; CRecordVector<CInitDialogItem> initDialogItems; int xSize = 70; - CInitDialogItem initDialogItem = + CInitDialogItem idi = { DI_DOUBLEBOX, 3, 1, xSize - 4, size - 2, false, false, 0, false, NMessageID::kProperties, NULL, NULL }; - initDialogItems.Add(initDialogItem); + initDialogItems.Add(idi); AStringVector values; for (i = 0; i < properties.Size(); i++) { const CArchiveItemProperty &property = properties[i]; - CInitDialogItem initDialogItem = + CInitDialogItem idi = { DI_TEXT, 5, 3 + i, 0, 0, false, false, 0, false, 0, NULL, NULL }; int index = FindPropertyToName(property.ID); if (index < 0) { - initDialogItem.DataMessageId = -1; - initDialogItem.DataString = property.Name; + idi.DataMessageId = -1; + idi.DataString = property.Name; } else - initDialogItem.DataMessageId = kPROPIDToName[index].PluginID; - initDialogItems.Add(initDialogItem); + idi.DataMessageId = kPROPIDToName[index].PluginID; + initDialogItems.Add(idi); - NCOM::CPropVariant propVariant; - RINOK(_folder->GetProperty(itemIndex, property.ID, &propVariant)); - CSysString s = ConvertPropertyToString2(propVariant, property.ID); + NCOM::CPropVariant prop; + RINOK(_folder->GetProperty(itemIndex, property.ID, &prop)); + CSysString s = PropToString(prop, property.ID); values.Add(s); { - CInitDialogItem initDialogItem = + CInitDialogItem idi = { DI_TEXT, 30, 3 + i, 0, 0, false, false, 0, false, -1, NULL, NULL }; - initDialogItems.Add(initDialogItem); + initDialogItems.Add(idi); } } int numLines = values.Size(); for (i = 0; i < numLines; i++) { - CInitDialogItem &initDialogItem = initDialogItems[1 + i * 2 + 1]; - initDialogItem.DataString = values[i]; + CInitDialogItem &idi = initDialogItems[1 + i * 2 + 1]; + idi.DataString = values[i]; } int numDialogItems = initDialogItems.Size(); @@ -645,7 +747,7 @@ HRESULT CPlugin::ShowAttributesWindow() dialogItems.Reserve(numDialogItems); for (i = 0; i < numDialogItems; i++) dialogItems.Add(FarDialogItem()); - g_StartupInfo.InitDialogItems(&initDialogItems.Front(), + g_StartupInfo.InitDialogItems(&initDialogItems.Front(), &dialogItems.Front(), numDialogItems); int maxLen = 0; @@ -695,8 +797,8 @@ int CPlugin::ProcessKey(int key, unsigned int controlState) PanelInfo panelInfo; g_StartupInfo.ControlGetActivePanelInfo(panelInfo); GetFilesReal(panelInfo.SelectedItems, - panelInfo.SelectedItemsNumber, FALSE, - UnicodeStringToMultiByte(folderPath, CP_OEMCP), OPM_SILENT, true); + panelInfo.SelectedItemsNumber, FALSE, + UnicodeStringToMultiByte(folderPath, CP_OEMCP), OPM_SILENT, true); g_StartupInfo.Control(this, FCTL_UPDATEPANEL, NULL); g_StartupInfo.Control(this, FCTL_REDRAWPANEL, NULL); g_StartupInfo.Control(this, FCTL_UPDATEANOTHERPANEL, NULL); diff --git a/CPP/7zip/UI/Far/Plugin.h b/CPP/7zip/UI/Far/Plugin.h index d9b99fa9..034b1556 100755 --- a/CPP/7zip/UI/Far/Plugin.h +++ b/CPP/7zip/UI/Far/Plugin.h @@ -13,7 +13,7 @@ #include "FarUtils.h" -const UInt32 kNumInfoLinesMax = 30; // Change it; +const UInt32 kNumInfoLinesMax = 64; class CPlugin { @@ -53,8 +53,8 @@ public: UString Password; - CPlugin(const UString &fileName, - // const UString &aDefaultName, + CPlugin(const UString &fileName, + // const UString &aDefaultName, IInFolderArchive *archiveHandler, UString archiveTypeName ); @@ -73,10 +73,10 @@ public: HRESULT ExtractFiles( bool decompressAllItems, - const UINT32 *indices, - UINT32 numIndices, - bool silent, - NExtract::NPathMode::EEnum pathMode, + const UINT32 *indices, + UINT32 numIndices, + bool silent, + NExtract::NPathMode::EEnum pathMode, NExtract::NOverwriteMode::EEnum overwriteMode, const UString &destPath, bool passwordIsDefined, const UString &password); @@ -84,7 +84,7 @@ public: NFar::NFileOperationReturnCode::EEnum GetFiles(struct PluginPanelItem *aPanelItem, int itemsNumber, int move, char *destPath, int opMode); - NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *aPanelItems, + NFar::NFileOperationReturnCode::EEnum GetFilesReal(struct PluginPanelItem *aPanelItems, int itemsNumber, int move, const char *_aDestPath, int opMode, bool aShowBox); NFar::NFileOperationReturnCode::EEnum PutFiles(struct PluginPanelItem *aPanelItems, int itemsNumber, diff --git a/CPP/7zip/UI/Far/PluginCommon.cpp b/CPP/7zip/UI/Far/PluginCommon.cpp index 3e8e3cee..ce1a18bb 100755 --- a/CPP/7zip/UI/Far/PluginCommon.cpp +++ b/CPP/7zip/UI/Far/PluginCommon.cpp @@ -5,7 +5,7 @@ #include "Plugin.h" /* -void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder, +void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder, int anIndexInVector, vector<int> &aRealIndexes) { const CArchiveFolderFileItem &anItem = aFolder.m_FileSubItems[anIndexInVector]; @@ -15,7 +15,7 @@ void CPlugin::AddRealIndexOfFile(const CArchiveFolderItem &aFolder, aRealIndexes.push_back(aHandlerItemIndex); } -void CPlugin::AddRealIndexes(const CArchiveFolderItem &anItem, +void CPlugin::AddRealIndexes(const CArchiveFolderItem &anItem, vector<int> &aRealIndexes) { int aHandlerItemIndex = m_ProxyHandler->GetHandlerItemIndex(anItem.m_Properties); @@ -28,7 +28,7 @@ void CPlugin::AddRealIndexes(const CArchiveFolderItem &anItem, } -void CPlugin::GetRealIndexes(PluginPanelItem *aPanelItems, int anItemsNumber, +void CPlugin::GetRealIndexes(PluginPanelItem *aPanelItems, int anItemsNumber, vector<int> &aRealIndexes) { aRealIndexes.clear(); diff --git a/CPP/7zip/UI/Far/PluginDelete.cpp b/CPP/7zip/UI/Far/PluginDelete.cpp index 95e43a36..a1dfb915 100755 --- a/CPP/7zip/UI/Far/PluginDelete.cpp +++ b/CPP/7zip/UI/Far/PluginDelete.cpp @@ -54,11 +54,11 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, } else if (numItems > 1) { - sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteNumberOfFiles), + sprintf(msg, g_StartupInfo.GetMsgString(NMessageID::kDeleteNumberOfFiles), numItems); msgItems[1] = msg; } - if (g_StartupInfo.ShowMessage(FMSG_WARNING, NULL, msgItems, + if (g_StartupInfo.ShowMessage(FMSG_WARNING, NULL, msgItems, sizeof(msgItems) / sizeof(msgItems[0]), 2) != 0) return (FALSE); } @@ -71,8 +71,9 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, screenRestorer.Save(); progressBoxPointer = &progressBox; - progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), - g_StartupInfo.GetMsgString(NMessageID::kDeleting), 1 << 17); + progressBox.Init( + // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), + g_StartupInfo.GetMsgString(NMessageID::kDeleting), 48); } NWorkDir::CInfo workDirInfo; @@ -112,11 +113,11 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp; CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec ); - updateCallbackSpec->Init(m_ArchiveHandler, &progressBox); + updateCallbackSpec->Init(/* m_ArchiveHandler, */ &progressBox); result = outArchive->DeleteItems( - tempFileName, + tempFileName, &indices.Front(), indices.Size(), updateCallback); updateCallback.Release(); diff --git a/CPP/7zip/UI/Far/PluginRead.cpp b/CPP/7zip/UI/Far/PluginRead.cpp index 503ff639..7cf7c3c6 100755 --- a/CPP/7zip/UI/Far/PluginRead.cpp +++ b/CPP/7zip/UI/Far/PluginRead.cpp @@ -24,14 +24,14 @@ static const char *kHelpTopicExtrFromSevenZip = "Extract"; static const char kDirDelimiter = '\\'; -static const char *kExractPathHistoryName = "7-ZipExtractPath"; +static const char *kExractPathHistoryName = "7-ZipExtractPath"; HRESULT CPlugin::ExtractFiles( bool decompressAllItems, - const UINT32 *indices, - UINT32 numIndices, + const UINT32 *indices, + UINT32 numIndices, bool silent, - NExtract::NPathMode::EEnum pathMode, + NExtract::NPathMode::EEnum pathMode, NExtract::NOverwriteMode::EEnum overwriteMode, const UString &destPath, bool passwordIsDefined, const UString &password) @@ -44,8 +44,9 @@ HRESULT CPlugin::ExtractFiles( screenRestorer.Save(); progressBoxPointer = &progressBox; - progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), - g_StartupInfo.GetMsgString(NMessageID::kExtracting), 1 << 17); + progressBox.Init( + // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), + g_StartupInfo.GetMsgString(NMessageID::kExtracting), 48); } @@ -54,10 +55,10 @@ HRESULT CPlugin::ExtractFiles( extractCallbackSpec->Init( CP_OEMCP, - progressBoxPointer, + progressBoxPointer, /* GetDefaultName(m_FileName, m_ArchiverInfo.Extension), - m_FileInfo.LastWriteTime, m_FileInfo.Attributes, + m_FileInfo.MTime, m_FileInfo.Attributes, */ passwordIsDefined, password); @@ -74,14 +75,14 @@ HRESULT CPlugin::ExtractFiles( } } -NFileOperationReturnCode::EEnum CPlugin::GetFiles(struct PluginPanelItem *panelItems, +NFileOperationReturnCode::EEnum CPlugin::GetFiles(struct PluginPanelItem *panelItems, int itemsNumber, int move, char *_aDestPath, int opMode) { - return GetFilesReal(panelItems, itemsNumber, move, + return GetFilesReal(panelItems, itemsNumber, move, _aDestPath, opMode, (opMode & OPM_SILENT) == 0); } -NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems, +NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *panelItems, int itemsNumber, int move, const char *_aDestPath, int opMode, bool showBox) { if(move != 0) @@ -130,31 +131,31 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa // { DI_EDIT, 5, 3, kXSize - 6, 3, true, false, 0, false, -1, destPath, NULL}, { DI_SINGLEBOX, 4, 5, kXMid - 2, 5 + 4, false, false, 0, false, NMessageID::kExtractPathMode, NULL, NULL }, - { DI_RADIOBUTTON, 6, 6, 0, 0, false, - extractionInfo.PathMode == NExtract::NPathMode::kFullPathnames, + { DI_RADIOBUTTON, 6, 6, 0, 0, false, + extractionInfo.PathMode == NExtract::NPathMode::kFullPathnames, DIF_GROUP, false, NMessageID::kExtractPathFull, NULL, NULL }, - { DI_RADIOBUTTON, 6, 7, 0, 0, false, + { DI_RADIOBUTTON, 6, 7, 0, 0, false, extractionInfo.PathMode == NExtract::NPathMode::kCurrentPathnames, 0, false, NMessageID::kExtractPathCurrent, NULL, NULL }, { DI_RADIOBUTTON, 6, 8, 0, 0, false, - extractionInfo.PathMode == NExtract::NPathMode::kNoPathnames, + extractionInfo.PathMode == NExtract::NPathMode::kNoPathnames, false, 0, NMessageID::kExtractPathNo, NULL, NULL }, { DI_SINGLEBOX, kXMid, 5, kXSize - 6, 5 + kNumOverwriteOptions, false, false, 0, false, NMessageID::kExtractOwerwriteMode, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, - extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAskBefore, + { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, + extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAskBefore, DIF_GROUP, false, NMessageID::kExtractOwerwriteAsk, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false, - extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kWithoutPrompt, + { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false, + extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kWithoutPrompt, 0, false, NMessageID::kExtractOwerwritePrompt, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false, - extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kSkipExisting, + { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false, + extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kSkipExisting, 0, false, NMessageID::kExtractOwerwriteSkip, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false, - extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRename, + { DI_RADIOBUTTON, kXMid + 2, 9, 0, 0, false, + extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRename, 0, false, NMessageID::kExtractOwerwriteAutoRename, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 10, 0, 0, false, - extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting, + { DI_RADIOBUTTON, kXMid + 2, 10, 0, 0, false, + extractionInfo.OverwriteMode == NExtract::NOverwriteMode::kAutoRenameExisting, 0, false, NMessageID::kExtractOwerwriteAutoRenameExisting, NULL, NULL }, { DI_SINGLEBOX, 4, 10, kXMid- 2, 10 + 3, false, false, 0, false, NMessageID::kExtractFilesMode, NULL, NULL }, @@ -164,7 +165,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa { DI_SINGLEBOX, kXMid, kPasswordYPos, kXSize - 6, kPasswordYPos + 2, false, false, 0, false, NMessageID::kExtractPassword, NULL, NULL }, { DI_PSWEDIT, kXMid + 2, kPasswordYPos + 1, kXSize - 8, 12, false, false, 0, false, -1, oemPassword, NULL}, - { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, + { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, { DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kExtractExtract, NULL, NULL }, @@ -179,7 +180,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems); for (;;) { - int askCode = g_StartupInfo.ShowDialog(kXSize, kYSize, + int askCode = g_StartupInfo.ShowDialog(kXSize, kYSize, kHelpTopicExtrFromSevenZip, dialogItems, kNumDialogItems); if (askCode != kOkButtonIndex) return NFileOperationReturnCode::kInterruptedByUser; @@ -239,7 +240,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa throw 31806; oemPassword = dialogItems[kPasswordIndex].Data; - password = MultiByteToUnicodeString(oemPassword, CP_OEMCP); + password = MultiByteToUnicodeString(oemPassword, CP_OEMCP); passwordIsDefined = !password.IsEmpty(); } @@ -255,11 +256,11 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa for (int i = 0; i < itemsNumber; i++) indices.Add(panelItems[i].UserData); - HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber, - !showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode, - MultiByteToUnicodeString(destPath, CP_OEMCP), + HRESULT result = ExtractFiles(decompressAllItems, &indices.Front(), itemsNumber, + !showBox, extractionInfo.PathMode, extractionInfo.OverwriteMode, + MultiByteToUnicodeString(destPath, CP_OEMCP), passwordIsDefined, password); - // HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox, + // HRESULT result = ExtractFiles(decompressAllItems, realIndices, !showBox, // extractionInfo, destPath, passwordIsDefined, password); if (result != S_OK) { diff --git a/CPP/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp index 80f9916a..2f7fbc83 100755 --- a/CPP/7zip/UI/Far/PluginWrite.cpp +++ b/CPP/7zip/UI/Far/PluginWrite.cpp @@ -34,9 +34,9 @@ static const char *kHelpTopic = "Update"; static LPCWSTR kTempArcivePrefix = L"7zA"; -static const char *kArchiveHistoryKeyName = "7-ZipArcName"; +static const char *kArchiveHistoryKeyName = "7-ZipArcName"; -static UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 }; +static UINT32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 }; static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method) { @@ -55,7 +55,7 @@ static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UINT32 method) } NFileOperationReturnCode::EEnum CPlugin::PutFiles( - struct PluginPanelItem *panelItems, int numItems, + struct PluginPanelItem *panelItems, int numItems, int moveMode, int opMode) { if(moveMode != 0) @@ -95,17 +95,17 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( struct CInitDialogItem initItems[]={ { DI_DOUBLEBOX, 3, 1, 72, kYSize - 2, false, false, 0, false, NMessageID::kUpdateTitle, NULL, NULL }, { DI_SINGLEBOX, 4, 2, kXMid - 2, 2 + 7, false, false, 0, false, NMessageID::kUpdateMethod, NULL, NULL }, - { DI_RADIOBUTTON, 6, 3, 0, 0, methodIndex == 0, methodIndex == 0, + { DI_RADIOBUTTON, 6, 3, 0, 0, methodIndex == 0, methodIndex == 0, DIF_GROUP, false, NMessageID::kUpdateMethodStore, NULL, NULL }, - { DI_RADIOBUTTON, 6, 4, 0, 0, methodIndex == 1, methodIndex == 1, + { DI_RADIOBUTTON, 6, 4, 0, 0, methodIndex == 1, methodIndex == 1, 0, false, NMessageID::kUpdateMethodFastest, NULL, NULL }, - { DI_RADIOBUTTON, 6, 5, 0, 0, methodIndex == 2, methodIndex == 2, + { DI_RADIOBUTTON, 6, 5, 0, 0, methodIndex == 2, methodIndex == 2, 0, false, NMessageID::kUpdateMethodFast, NULL, NULL }, - { DI_RADIOBUTTON, 6, 6, 0, 0, methodIndex == 3, methodIndex == 3, + { DI_RADIOBUTTON, 6, 6, 0, 0, methodIndex == 3, methodIndex == 3, 0, false, NMessageID::kUpdateMethodNormal, NULL, NULL }, - { DI_RADIOBUTTON, 6, 7, 0, 0, methodIndex == 4, methodIndex == 4, + { DI_RADIOBUTTON, 6, 7, 0, 0, methodIndex == 4, methodIndex == 4, 0, false, NMessageID::kUpdateMethodMaximum, NULL, NULL }, - { DI_RADIOBUTTON, 6, 8, 0, 0, methodIndex == 5, methodIndex == 5, + { DI_RADIOBUTTON, 6, 8, 0, 0, methodIndex == 5, methodIndex == 5, 0, false, NMessageID::kUpdateMethodUltra, NULL, NULL }, { DI_SINGLEBOX, kXMid, 2, 70, 2 + 5, false, false, 0, false, NMessageID::kUpdateMode, NULL, NULL }, @@ -113,12 +113,12 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( DIF_GROUP, false, NMessageID::kUpdateModeAdd, NULL, NULL }, { DI_RADIOBUTTON, kXMid + 2, 4, 0, 0, false, false, 0, false, NMessageID::kUpdateModeUpdate, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false, false, + { DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false, false, 0, false, NMessageID::kUpdateModeFreshen, NULL, NULL }, { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, false, 0, false, NMessageID::kUpdateModeSynchronize, NULL, NULL }, - { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, + { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, { DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kUpdateAdd, NULL, NULL }, { DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kCancel, NULL, NULL } @@ -128,7 +128,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( const int kOkButtonIndex = kNumDialogItems - 2; FarDialogItem dialogItems[kNumDialogItems]; g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems); - int askCode = g_StartupInfo.ShowDialog(76, kYSize, + int askCode = g_StartupInfo.ShowDialog(76, kYSize, kHelpTopic, dialogItems, kNumDialogItems); if (askCode != kOkButtonIndex) return NFileOperationReturnCode::kInterruptedByUser; @@ -184,8 +184,9 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( screenRestorer.Save(); progressBoxPointer = &progressBox; - progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), - g_StartupInfo.GetMsgString(NMessageID::kUpdating), 1 << 16); + progressBox.Init( + // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), + g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48); } //////////////////////////// @@ -223,8 +224,8 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( // CSysString aCurrentFolder; // MyGetCurrentDirectory(aCurrentFolder); - // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP), - outArchive->SetFiles(L"", + // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP), + outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size()); BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues]; for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++) @@ -233,7 +234,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp; CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec ); - updateCallbackSpec->Init(m_ArchiveHandler, &progressBox); + updateCallbackSpec->Init(/* m_ArchiveHandler, */ &progressBox); if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK) return NFileOperationReturnCode::kError; @@ -243,8 +244,8 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( outArchive.Release(); /* - HRESULT result = Compress(fileNames, anArchivePrefix, *actionSet, - m_ProxyHandler.get(), + HRESULT result = Compress(fileNames, anArchivePrefix, *actionSet, + m_ProxyHandler.get(), m_ArchiverInfo.ClassID, compressionInfo.Method == 0, compressionInfo.Method == 2, tempFileName, progressBoxPointer); */ @@ -305,7 +306,7 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( { const PluginPanelItem &aPluginPanelItem = panelItems[i]; bool result; - if(NFile::NFind::NAttributes::IsDirectory(aPluginPanelItem.FindData.dwFileAttributes)) + if(NFile::NFind::NAttributes::IsDir(aPluginPanelItem.FindData.dwFileAttributes)) result = NFile::NDirectory::RemoveDirectoryWithSubItems( aPluginPanelItem.FindData.cFileName); else @@ -397,7 +398,7 @@ UString CParsedPath::MergePath() const /* // {23170F69-40C1-278A-1000-000100030000} -DEFINE_GUID(CLSID_CAgentArchiveHandler, +DEFINE_GUID(CLSID_CAgentArchiveHandler, 0x23170F69, 0x40C1, 0x278A, 0x10, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x00); */ @@ -412,11 +413,11 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) { const PluginPanelItem &panelItem = pluginPanelItems[i]; CSysString fullName; - if (strcmp(panelItem.FindData.cFileName, "..") == 0 && - NFind::NAttributes::IsDirectory(panelItem.FindData.dwFileAttributes)) + if (strcmp(panelItem.FindData.cFileName, "..") == 0 && + NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes)) return E_FAIL; - if (strcmp(panelItem.FindData.cFileName, ".") == 0 && - NFind::NAttributes::IsDirectory(panelItem.FindData.dwFileAttributes)) + if (strcmp(panelItem.FindData.cFileName, ".") == 0 && + NFind::NAttributes::IsDir(panelItem.FindData.dwFileAttributes)) return E_FAIL; if (!MyGetFullPathName(panelItem.FindData.cFileName, fullName)) return E_FAIL; @@ -498,7 +499,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) char updateAddToArchiveString[512]; const AString s = GetSystemString(arcInfo.Name, CP_OEMCP); - sprintf(updateAddToArchiveString, + sprintf(updateAddToArchiveString, g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s); int methodIndex = 0; @@ -520,34 +521,34 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) // { DI_EDIT, 5, 3, 70, 3, true, false, 0, false, -1, archiveName, NULL}, { DI_SINGLEBOX, 4, 4, kXMid - 2, 4 + 7, false, false, 0, false, NMessageID::kUpdateMethod, NULL, NULL }, - { DI_RADIOBUTTON, 6, 5, 0, 0, false, methodIndex == 0, + { DI_RADIOBUTTON, 6, 5, 0, 0, false, methodIndex == 0, DIF_GROUP, false, NMessageID::kUpdateMethodStore, NULL, NULL }, - { DI_RADIOBUTTON, 6, 6, 0, 0, false, methodIndex == 1, + { DI_RADIOBUTTON, 6, 6, 0, 0, false, methodIndex == 1, 0, false, NMessageID::kUpdateMethodFastest, NULL, NULL }, - { DI_RADIOBUTTON, 6, 7, 0, 0, false, methodIndex == 2, + { DI_RADIOBUTTON, 6, 7, 0, 0, false, methodIndex == 2, 0, false, NMessageID::kUpdateMethodFast, NULL, NULL }, - { DI_RADIOBUTTON, 6, 8, 0, 0, false, methodIndex == 3, + { DI_RADIOBUTTON, 6, 8, 0, 0, false, methodIndex == 3, 0, false, NMessageID::kUpdateMethodNormal, NULL, NULL }, - { DI_RADIOBUTTON, 6, 9, 0, 0, false, methodIndex == 4, + { DI_RADIOBUTTON, 6, 9, 0, 0, false, methodIndex == 4, false, 0, NMessageID::kUpdateMethodMaximum, NULL, NULL }, - { DI_RADIOBUTTON, 6, 10, 0, 0, false, methodIndex == 5, + { DI_RADIOBUTTON, 6, 10, 0, 0, false, methodIndex == 5, false, 0, NMessageID::kUpdateMethodUltra, NULL, NULL }, { DI_SINGLEBOX, kXMid, 4, 70, 4 + 5, false, false, 0, false, NMessageID::kUpdateMode, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false, + { DI_RADIOBUTTON, kXMid + 2, 5, 0, 0, false, actionSet == &kAddActionSet, DIF_GROUP, false, NMessageID::kUpdateModeAdd, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, + { DI_RADIOBUTTON, kXMid + 2, 6, 0, 0, false, actionSet == &kUpdateActionSet, 0, false, NMessageID::kUpdateModeUpdate, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false, + { DI_RADIOBUTTON, kXMid + 2, 7, 0, 0, false, actionSet == &kFreshActionSet, 0, false, NMessageID::kUpdateModeFreshen, NULL, NULL }, - { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false, + { DI_RADIOBUTTON, kXMid + 2, 8, 0, 0, false, actionSet == &kSynchronizeActionSet, 0, false, NMessageID::kUpdateModeSynchronize, NULL, NULL }, - { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, + { DI_TEXT, 3, kYSize - 4, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, { DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, true, NMessageID::kUpdateAdd, NULL, NULL }, { DI_BUTTON, 0, kYSize - 3, 0, 0, false, false, DIF_CENTERGROUP, false, NMessageID::kUpdateSelectArchiver, NULL, NULL }, @@ -561,7 +562,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) FarDialogItem dialogItems[kNumDialogItems]; g_StartupInfo.InitDialogItems(initItems, dialogItems, kNumDialogItems); - int askCode = g_StartupInfo.ShowDialog(76, kYSize, + int askCode = g_StartupInfo.ShowDialog(76, kYSize, kHelpTopic, dialogItems, kNumDialogItems); archiveNameA = dialogItems[kArchiveNameIndex].Data; @@ -598,7 +599,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) } } - int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT, + int index = g_StartupInfo.Menu(FMENU_AUTOHIGHLIGHT, g_StartupInfo.GetMsgString(NMessageID::kUpdateSelectArchiverMenuTitle), NULL, archiverNames, archiverIndex); if(index >= 0) @@ -672,8 +673,9 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) screenRestorer.Save(); progressBoxPointer = &progressBox; - progressBox.Init(g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), - g_StartupInfo.GetMsgString(NMessageID::kUpdating), 1 << 16); + progressBox.Init( + // g_StartupInfo.GetMsgString(NMessageID::kWaitTitle), + g_StartupInfo.GetMsgString(NMessageID::kUpdating), 48); NFind::CFileInfoW fileInfo; @@ -683,7 +685,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) CMyComPtr<IInFolderArchive> archiveHandler; if(NFind::FindFile(fullArchiveName, fileInfo)) { - if (fileInfo.IsDirectory()) + if (fileInfo.IsDir()) throw "There is Directory with such name"; CAgent *agentSpec = new CAgent; @@ -691,8 +693,8 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) // CLSID realClassID; CMyComBSTR archiveType; RINOK(agentSpec->Open( - GetUnicodeString(fullArchiveName, CP_OEMCP), - // &realClassID, + GetUnicodeString(fullArchiveName, CP_OEMCP), + // &realClassID, &archiveType, NULL)); @@ -730,8 +732,8 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) outArchive->SetFolder(NULL); // CSysString aCurrentFolder; // MyGetCurrentDirectory(aCurrentFolder); - // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP), - outArchive->SetFiles(L"", + // outArchive->SetFiles(MultiByteToUnicodeString(aCurrentFolder, CP_OEMCP), + outArchive->SetFiles(L"", &fileNamePointers.Front(), fileNamePointers.Size()); BYTE actionSetByte[NUpdateArchive::NPairState::kNumValues]; for (i = 0; i < NUpdateArchive::NPairState::kNumValues; i++) @@ -740,14 +742,14 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) CUpdateCallback100Imp *updateCallbackSpec = new CUpdateCallback100Imp; CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec ); - updateCallbackSpec->Init(archiveHandler, &progressBox); + updateCallbackSpec->Init(/* archiveHandler, */ &progressBox); RINOK(SetOutProperties(outArchive, compressionInfo.Level)); HRESULT result = outArchive->DoOperation( codecs, archiverIndex, - tempFileName, actionSetByte, + tempFileName, actionSetByte, NULL, updateCallback); updateCallback.Release(); outArchive.Release(); diff --git a/CPP/7zip/UI/Far/ProgressBox.cpp b/CPP/7zip/UI/Far/ProgressBox.cpp index d708331a..b13b0b51 100755 --- a/CPP/7zip/UI/Far/ProgressBox.cpp +++ b/CPP/7zip/UI/Far/ProgressBox.cpp @@ -5,100 +5,108 @@ #include <stdio.h> #include "ProgressBox.h" - +#include "Common/IntToString.h" #include "FarUtils.h" -using namespace NFar; - -static void CopySpaces(char *destString, int numSpaces) +static void CopySpaces(char *dest, int numSpaces) { int i; - for(i = 0; i < numSpaces; i++) - destString[i] = ' '; - destString[i] = '\0'; + for (i = 0; i < numSpaces; i++) + dest[i] = ' '; + dest[i] = '\0'; } -///////////////////////////////// -// CMessageBox +void ConvertUInt64ToStringAligned(UInt64 value, char *s, int alignSize) +{ + char temp[32]; + ConvertUInt64ToString(value, temp); + int len = (int)strlen(temp); + int numSpaces = 0; + if (len < alignSize) + { + numSpaces = alignSize - len; + CopySpaces(s, numSpaces); + } + strcpy(s + numSpaces, temp); +} -const int kNumStringsMax = 10; -void CMessageBox::Init(const CSysString &title, const CSysString &message, - int numStrings, int width) -{ - if (numStrings > kNumStringsMax) - throw 120620; - m_NumStrings = numStrings; - m_Width = width; +// ---------- CMessageBox ---------- - m_Title = title; - m_Message = message; -} +static const int kMaxLen = 255; -const int kNumStaticStrings = 2; +void CMessageBox::Init(const AString &title, int width) +{ + _title = title; + _width = MyMin(width, kMaxLen); +} -void CMessageBox::ShowProcessMessages(const char *messages[]) +void CMessageBox::ShowMessages(const char *strings[], int numStrings) { + const int kNumStaticStrings = 1; + const int kNumStringsMax = 10; + + if (numStrings > kNumStringsMax) + numStrings = kNumStringsMax; + const char *msgItems[kNumStaticStrings + kNumStringsMax]; - msgItems[0] = m_Title; - msgItems[1] = m_Message; + msgItems[0] = _title; - char formattedMessages[kNumStringsMax][256]; + char formattedMessages[kNumStringsMax][kMaxLen + 1]; - for (int i = 0; i < m_NumStrings; i++) + for (int i = 0; i < numStrings; i++) { char *formattedMessage = formattedMessages[i]; - int len = (int)strlen(messages[i]); - int size = MyMax(m_Width, len); - int startPos = (size - len) / 2; - CopySpaces(formattedMessage, startPos); - MyStringCopy(formattedMessage + startPos, messages[i]); - CopySpaces(formattedMessage + startPos + len, size - startPos - len); + const char *s = strings[i]; + int len = (int)strlen(s); + if (len < kMaxLen) + { + int size = MyMax(_width, len); + int startPos = (size - len) / 2; + CopySpaces(formattedMessage, startPos); + strcpy(formattedMessage + startPos, s); + CopySpaces(formattedMessage + startPos + len, size - startPos - len); + } + else + { + strncpy(formattedMessage, s, kMaxLen); + formattedMessage[kMaxLen] = 0; + } msgItems[kNumStaticStrings + i] = formattedMessage; } - - g_StartupInfo.ShowMessage(0, NULL, msgItems, kNumStaticStrings + m_NumStrings, 0); + NFar::g_StartupInfo.ShowMessage(0, NULL, msgItems, kNumStaticStrings + numStrings, 0); } -///////////////////////////////// -// CProgressBox - -void CProgressBox::Init(const CSysString &title, const CSysString &message, - UInt64 step) -{ - CMessageBox::Init(title, message, 1, 22); - m_Step = step; - m_CompletedPrev = 0; - m_Total = 0; -} - - -void CProgressBox::ShowProcessMessage(const char *message) -{ - CMessageBox::ShowProcessMessages(&message); -} -void CProgressBox::PrintPercent(UInt64 percent) -{ - char valueBuffer[32]; - sprintf(valueBuffer, "%I64u%%", percent); - ShowProcessMessage(valueBuffer); -} +// ---------- CProgressBox ---------- -void CProgressBox::SetTotal(UInt64 total) +void CProgressBox::Init(const AString &title, int width) { - m_Total = total; + CMessageBox::Init(title, width); + _prevMessage.Empty(); + _prevPercentMessage.Empty(); + _wasShown = false; } -void CProgressBox::PrintCompeteValue(UInt64 completed) +void CProgressBox::Progress(const UInt64 *total, const UInt64 *completed, const AString &message) { - if (completed >= m_CompletedPrev + m_Step || completed < m_CompletedPrev || - completed == 0) + AString percentMessage; + if (total != 0 && completed != 0) { - if (m_Total == 0) - PrintPercent(0); - else - PrintPercent(completed * 100 / m_Total); - m_CompletedPrev = completed; + UInt64 totalVal = *total; + if (totalVal == 0) + totalVal = 1; + char buf[32]; + ConvertUInt64ToStringAligned(*completed * 100 / totalVal, buf, 3); + strcat(buf, "%"); + percentMessage = buf; + } + if (message != _prevMessage || percentMessage != _prevPercentMessage || !_wasShown) + { + _prevMessage = message; + _prevPercentMessage = percentMessage; + const char *strings[] = { message, percentMessage }; + ShowMessages(strings, sizeof(strings) / sizeof(strings[0])); + _wasShown = true; } } diff --git a/CPP/7zip/UI/Far/ProgressBox.h b/CPP/7zip/UI/Far/ProgressBox.h index 9e6f671a..2bada8e9 100755 --- a/CPP/7zip/UI/Far/ProgressBox.h +++ b/CPP/7zip/UI/Far/ProgressBox.h @@ -6,30 +6,25 @@ #include "Common/MyString.h" #include "Common/Types.h" +void ConvertUInt64ToStringAligned(UInt64 value, char *s, int alignSize); + class CMessageBox { - CSysString m_Title; - CSysString m_Message; - int m_NumStrings; - int m_Width; + AString _title; + int _width; public: - void Init(const CSysString &title, - const CSysString &message, int numStrings, int width); - void ShowProcessMessages(const char *messages[]); + void Init(const AString &title, int width); + void ShowMessages(const char *strings[], int numStrings); }; class CProgressBox: public CMessageBox { - UInt64 m_Total; - UInt64 m_CompletedPrev; - UInt64 m_Step; + AString _prevMessage; + AString _prevPercentMessage; + bool _wasShown; public: - void Init(const CSysString &title, - const CSysString &message, UInt64 step); - void ShowProcessMessage(const char *message); - void PrintPercent(UInt64 percent); - void PrintCompeteValue(UInt64 completed); - void SetTotal(UInt64 total); + void Init(const AString &title, int width); + void Progress(const UInt64 *total, const UInt64 *completed, const AString &message); }; #endif diff --git a/CPP/7zip/UI/Far/UpdateCallback100.cpp b/CPP/7zip/UI/Far/UpdateCallback100.cpp index ce4fa05e..dc90c810 100755 --- a/CPP/7zip/UI/Far/UpdateCallback100.cpp +++ b/CPP/7zip/UI/Far/UpdateCallback100.cpp @@ -15,22 +15,18 @@ STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 /* numFiles */) return S_OK; } -STDMETHODIMP CUpdateCallback100Imp::SetTotal(UINT64 aSize) +STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size) { - if (m_ProgressBox != 0) - { - m_ProgressBox->SetTotal(aSize); - m_ProgressBox->PrintCompeteValue(0); - } + _total = size; return S_OK; } -STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UINT64 *aCompleteValue) +STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue) { - if(WasEscPressed()) + if (WasEscPressed()) return E_ABORT; - if (m_ProgressBox != 0 && aCompleteValue != NULL) - m_ProgressBox->PrintCompeteValue(*aCompleteValue); + if (_progressBox != 0) + _progressBox->Progress(&_total, completeValue, AString()); return S_OK; } @@ -44,15 +40,14 @@ STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t* /* name */) return S_OK; } -STDMETHODIMP CUpdateCallback100Imp::OperationResult(INT32 /* operationResult */) +STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* opRes */) { return S_OK; } STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message) { - CSysString s = UnicodeStringToMultiByte(message, CP_OEMCP); - if (g_StartupInfo.ShowMessage(s) == -1) + if (g_StartupInfo.ShowMessage(UnicodeStringToMultiByte(message, CP_OEMCP)) == -1) return E_ABORT; return S_OK; } diff --git a/CPP/7zip/UI/Far/UpdateCallback100.h b/CPP/7zip/UI/Far/UpdateCallback100.h index f12193e9..45f4daea 100755 --- a/CPP/7zip/UI/Far/UpdateCallback100.h +++ b/CPP/7zip/UI/Far/UpdateCallback100.h @@ -9,34 +9,25 @@ #include "ProgressBox.h" -class CUpdateCallback100Imp: +class CUpdateCallback100Imp: public IFolderArchiveUpdateCallback, public CMyUnknownImp { + // CMyComPtr<IInFolderArchive> _archiveHandler; + CProgressBox *_progressBox; + UInt64 _total; + public: MY_UNKNOWN_IMP - // IProfress - - STDMETHOD(SetTotal)(UINT64 aSize); - STDMETHOD(SetCompleted)(const UINT64 *aCompleteValue); + INTERFACE_IProgress(;) + INTERFACE_IFolderArchiveUpdateCallback(;) - // IUpdateCallBack - STDMETHOD(CompressOperation)(const wchar_t *aName); - STDMETHOD(DeleteOperation)(const wchar_t *aName); - STDMETHOD(OperationResult)(INT32 aOperationResult); - STDMETHOD(UpdateErrorMessage)(const wchar_t *message); - STDMETHOD(SetNumFiles)(UInt64 numFiles); - -private: - CMyComPtr<IInFolderArchive> m_ArchiveHandler; - CProgressBox *m_ProgressBox; -public: - void Init(IInFolderArchive *anArchiveHandler, - CProgressBox *aProgressBox) + CUpdateCallback100Imp(): _total(0) {} + void Init(/* IInFolderArchive *archiveHandler, */ CProgressBox *progressBox) { - m_ArchiveHandler = anArchiveHandler; - m_ProgressBox = aProgressBox; + // _archiveHandler = archiveHandler; + _progressBox = progressBox; } }; diff --git a/CPP/7zip/UI/Far/makefile b/CPP/7zip/UI/Far/makefile index 1210e961..2c820077 100755 --- a/CPP/7zip/UI/Far/makefile +++ b/CPP/7zip/UI/Far/makefile @@ -39,6 +39,7 @@ WIN_OBJS = \ $O\PropVariantConversions.obj \ $O\Registry.obj \ $O\Synchronization.obj \ + $O\Time.obj \ 7ZIP_COMMON_OBJS = \ $O\FilePathAutoRename.obj \ |