diff options
Diffstat (limited to 'CPP')
53 files changed, 543 insertions, 198 deletions
diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp index e04313be..a4292545 100755 --- a/CPP/7zip/Archive/7z/7zIn.cpp +++ b/CPP/7zip/Archive/7z/7zIn.cpp @@ -607,7 +607,9 @@ void CInArchive::ReadStreamsInfo( for (;;) { UInt64 type = ReadID(); - switch(type) + if (type > ((UInt32)1 << 30)) + ThrowIncorrect(); + switch((UInt32)type) { case NID::kEnd: return; @@ -627,6 +629,8 @@ void CInArchive::ReadStreamsInfo( unPackSizes, digestsDefined, digests); break; } + default: + ThrowIncorrect(); } } } @@ -664,7 +668,7 @@ void CInArchive::ReadBoolVector2(int numItems, CBoolVector &v) } void CInArchive::ReadTime(const CObjectVector<CByteBuffer> &dataVector, - CObjectVector<CFileItem> &files, UInt64 type) + CObjectVector<CFileItem> &files, UInt32 type) { CBoolVector boolVector; ReadBoolVector2(files.Size(), boolVector); @@ -881,8 +885,10 @@ HRESULT CInArchive::ReadHeader( if (type == NID::kEnd) break; UInt64 size = ReadNumber(); - database.ArchiveInfo.FileInfoPopIDs.Add(type); - switch(type) + bool isKnownType = true; + if (type > ((UInt32)1 << 30)) + isKnownType = false; + else switch((UInt32)type) { case NID::kName: { @@ -951,15 +957,16 @@ HRESULT CInArchive::ReadHeader( case NID::kLastWriteTime: case NID::kLastAccessTime: { - ReadTime(dataVector, database.Files, type); + ReadTime(dataVector, database.Files, (UInt32)type); break; } default: - { - database.ArchiveInfo.FileInfoPopIDs.DeleteBack(); - SkeepData(size); - } + isKnownType = false; } + if (isKnownType) + database.ArchiveInfo.FileInfoPopIDs.Add(type); + else + SkeepData(size); } CNum emptyFileIndex = 0; diff --git a/CPP/7zip/Archive/7z/7zIn.h b/CPP/7zip/Archive/7z/7zIn.h index 47cd3b35..aae43506 100755 --- a/CPP/7zip/Archive/7z/7zIn.h +++ b/CPP/7zip/Archive/7z/7zIn.h @@ -194,7 +194,7 @@ private: void ReadBoolVector(int numItems, CBoolVector &v); void ReadBoolVector2(int numItems, CBoolVector &v); void ReadTime(const CObjectVector<CByteBuffer> &dataVector, - CObjectVector<CFileItem> &files, UInt64 type); + CObjectVector<CFileItem> &files, UInt32 type); HRESULT ReadAndDecodePackedStreams( DECL_EXTERNAL_CODECS_LOC_VARS UInt64 baseOffset, UInt64 &dataOffset, diff --git a/CPP/7zip/Archive/Rar/RarHandler.cpp b/CPP/7zip/Archive/Rar/RarHandler.cpp index 6664cb07..fd0952d1 100755 --- a/CPP/7zip/Archive/Rar/RarHandler.cpp +++ b/CPP/7zip/Archive/Rar/RarHandler.cpp @@ -104,7 +104,7 @@ STDMETHODIMP CHandler::GetArchiveProperty(PROPID propID, PROPVARIANT *value) prop = (UInt32)numBlocks; break; } - case kpidNumVolumes: prop = (UInt32)(_archives.Size() - 1); + case kpidNumVolumes: prop = (UInt32)_archives.Size(); // case kpidCommented: prop = _archiveInfo.IsCommented(); break; } diff --git a/CPP/7zip/Archive/Tar/TarHandler.cpp b/CPP/7zip/Archive/Tar/TarHandler.cpp index d16307ca..33866d61 100755 --- a/CPP/7zip/Archive/Tar/TarHandler.cpp +++ b/CPP/7zip/Archive/Tar/TarHandler.cpp @@ -1,4 +1,4 @@ -/ Tar/Handler.cpp +// Tar/Handler.cpp #include "StdAfx.h" diff --git a/CPP/7zip/Archive/Tar/TarIn.cpp b/CPP/7zip/Archive/Tar/TarIn.cpp index 86afc482..bae1db86 100755 --- a/CPP/7zip/Archive/Tar/TarIn.cpp +++ b/CPP/7zip/Archive/Tar/TarIn.cpp @@ -219,7 +219,7 @@ HRESULT CInArchive::GetNextItem(bool &filled, CItemEx &item) item.LongLinkSize = item.HeaderPosition - headerPosition; item.HeaderPosition = headerPosition; } - else if (item.LinkFlag == 'g' || item.LinkFlag == 'x') + else if (item.LinkFlag == 'g' || item.LinkFlag == 'x' || item.LinkFlag == 'X') { // pax Extended Header return S_OK; diff --git a/CPP/7zip/Compress/LZ/LZOutWindow.h b/CPP/7zip/Compress/LZ/LZOutWindow.h index 3c50c6e7..60b1b8af 100755 --- a/CPP/7zip/Compress/LZ/LZOutWindow.h +++ b/CPP/7zip/Compress/LZ/LZOutWindow.h @@ -25,7 +25,16 @@ public: return false; pos += _bufferSize; } - do + if (_limitPos - _pos > len && _bufferSize - pos > len) + { + const Byte *src = _buffer + pos; + Byte *dest = _buffer + _pos; + _pos += len; + do + *dest++ = *src++; + while(--len != 0); + } + else do { if (pos == _bufferSize) pos = 0; diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp index d8d785e2..923c014c 100755 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp +++ b/CPP/7zip/Compress/LZMA_Alone/LzmaAlone.cpp @@ -159,7 +159,7 @@ int main2(int n, const char *args[]) g_IsNT = IsItWindowsNT(); #endif - fprintf(stderr, "\nLZMA 4.49 Copyright (c) 1999-2007 Igor Pavlov 2007-07-05\n"); + fprintf(stderr, "\nLZMA 4.54 Copyright (c) 1999-2007 Igor Pavlov 2007-09-04\n"); if (n == 1) { diff --git a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp index 124f559b..4cd2d63e 100755 --- a/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp +++ b/CPP/7zip/Compress/LZMA_Alone/LzmaBench.cpp @@ -448,7 +448,7 @@ UInt64 GetCompressRating(UInt32 dictionarySize, UInt64 elapsedTime, UInt64 freq, UInt64 GetDecompressRating(UInt64 elapsedTime, UInt64 freq, UInt64 outSize, UInt64 inSize, UInt32 numIterations) { // UInt64 numCommands = (inSize * 216 + outSize * 14) * numIterations; // AMD K8 - UInt64 numCommands = (inSize * 220 + outSize * 14) * numIterations; // Intel Core2 + UInt64 numCommands = (inSize * 220 + outSize * 8) * numIterations; // Intel Core2 return MyMultDiv64(numCommands, elapsedTime, freq); } diff --git a/CPP/7zip/Compress/Rar/Rar3Decoder.h b/CPP/7zip/Compress/Rar/Rar3Decoder.h index 6eefb28f..07008138 100755 --- a/CPP/7zip/Compress/Rar/Rar3Decoder.h +++ b/CPP/7zip/Compress/Rar/Rar3Decoder.h @@ -266,13 +266,26 @@ public: { _lzSize += len; UInt32 pos = (_winPos - distance - 1) & kWindowMask; + Byte *window = _window; + UInt32 winPos = _winPos; + if (kWindowSize - winPos > len && kWindowSize - pos > len) + { + const Byte *src = window + pos; + Byte *dest = window + winPos; + _winPos += len; + do + *dest++ = *src++; + while(--len != 0); + return; + } do { - _window[_winPos] = _window[pos]; - _winPos = (_winPos + 1) & kWindowMask; + window[winPos] = window[pos]; + winPos = (winPos + 1) & kWindowMask; pos = (pos + 1) & kWindowMask; } while(--len != 0); + _winPos = winPos; } void PutByte(Byte b) diff --git a/CPP/7zip/MyVersion.h b/CPP/7zip/MyVersion.h index 0c2bb33d..742f6f98 100755 --- a/CPP/7zip/MyVersion.h +++ b/CPP/7zip/MyVersion.h @@ -1,8 +1,8 @@ #define MY_VER_MAJOR 4 -#define MY_VER_MINOR 53 -#define MY_VER_BUILD 3 -#define MY_VERSION "4.53 beta" -#define MY_7ZIP_VERSION "7-Zip 4.53 beta" -#define MY_DATE "2007-08-27" +#define MY_VER_MINOR 54 +#define MY_VER_BUILD 0 +#define MY_VERSION "4.54 beta" +#define MY_7ZIP_VERSION "7-Zip 4.54 beta" +#define MY_DATE "2007-09-04" #define MY_COPYRIGHT "Copyright (c) 1999-2007 Igor Pavlov" #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE diff --git a/CPP/7zip/UI/Client7z/Client7z.cpp b/CPP/7zip/UI/Client7z/Client7z.cpp index 079345f7..8d448258 100755 --- a/CPP/7zip/UI/Client7z/Client7z.cpp +++ b/CPP/7zip/UI/Client7z/Client7z.cpp @@ -2,8 +2,7 @@ #include "StdAfx.h" -#include <initguid.h> - +#include "Common/MyInitGuid.h" #include "Common/StringConvert.h" #include "Common/IntToString.h" @@ -45,6 +44,7 @@ typedef UINT32 (WINAPI * CreateObjectFunc)( const GUID *interfaceID, void **outObject); +#ifdef _WIN32 #ifndef _UNICODE bool g_IsNT = false; static inline bool IsItWindowsNT() @@ -56,6 +56,7 @@ static inline bool IsItWindowsNT() return (versionInfo.dwPlatformId == VER_PLATFORM_WIN32_NT); } #endif +#endif void PrintString(const UString &s) { @@ -678,9 +679,11 @@ __cdecl #endif main(int argc, char* argv[]) { + #ifdef _WIN32 #ifndef _UNICODE g_IsNT = IsItWindowsNT(); #endif + #endif PrintStringLn(kCopyrightString); diff --git a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp index ac0e55e5..6cf95f27 100755 --- a/CPP/7zip/UI/Common/ArchiveCommandLine.cpp +++ b/CPP/7zip/UI/Common/ArchiveCommandLine.cpp @@ -262,13 +262,11 @@ static bool AddNameToCensor(NWildcard::CCensor &wildcardCensor, return true; } -static inline UINT GetCurrentCodePage() { return AreFileApisANSI() ? CP_ACP : CP_OEMCP; } - static void AddToCensorFromListFile(NWildcard::CCensor &wildcardCensor, LPCWSTR fileName, bool include, NRecursedType::EEnum type, UINT codePage) { UStringVector names; - if (!ReadNamesFromListFile(GetSystemString(fileName, GetCurrentCodePage()), names, codePage)) + if (!ReadNamesFromListFile(fileName, names, codePage)) throw kIncorrectListFile; for (int i = 0; i < names.Size(); i++) if (!AddNameToCensor(wildcardCensor, names[i], include, type)) diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp index b03bf48e..7e97b542 100755 --- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp +++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp @@ -48,11 +48,7 @@ void CArchiveExtractCallback::Init( _extractCallback2 = extractCallback2; _compressProgress.Release(); _extractCallback2.QueryInterface(IID_ICompressProgressInfo, &_compressProgress); - if (!_localProgress) - { - LocalProgressSpec = new CLocalProgress(); - _localProgress = LocalProgressSpec; - } + LocalProgressSpec->Init(extractCallback2, true); _itemDefaultName = itemDefaultName; diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.h b/CPP/7zip/UI/Common/ArchiveExtractCallback.h index 7c8bb832..f24f5b87 100755 --- a/CPP/7zip/UI/Common/ArchiveExtractCallback.h +++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.h @@ -98,7 +98,11 @@ public: WriteCreated(false), WriteAccessed(false), _multiArchives(false) - {} + { + LocalProgressSpec = new CLocalProgress(); + _localProgress = LocalProgressSpec; + } + CLocalProgress *LocalProgressSpec; CMyComPtr<ICompressProgressInfo> _localProgress; bool _ratioMode; diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp index e54214be..2f0c41a4 100755 --- a/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp +++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.cpp @@ -119,6 +119,7 @@ STDMETHODIMP COpenCallbackImp::GetStream(const wchar_t *name, IInStream **inStre inFile->OpenCallbackImp = this; inFile->OpenCallbackRef = this; FileNames.Add(name); + TotalSize += _fileInfo.Size; return S_OK; COM_TRY_END } diff --git a/CPP/7zip/UI/Common/ArchiveOpenCallback.h b/CPP/7zip/UI/Common/ArchiveOpenCallback.h index 304c2048..12b2b325 100755 --- a/CPP/7zip/UI/Common/ArchiveOpenCallback.h +++ b/CPP/7zip/UI/Common/ArchiveOpenCallback.h @@ -75,6 +75,7 @@ private: public: UStringVector FileNames; IOpenCallbackUI *Callback; + UInt64 TotalSize; COpenCallbackImp(): Callback(NULL) {} void Init(const UString &folderPrefix, const UString &fileName) @@ -84,6 +85,7 @@ public: throw 1; FileNames.Clear(); _subArchiveMode = false; + TotalSize = 0; } int FindName(const UString &name); }; diff --git a/CPP/7zip/UI/Common/Extract.cpp b/CPP/7zip/UI/Common/Extract.cpp index 6b6eb329..faf0f727 100755 --- a/CPP/7zip/UI/Common/Extract.cpp +++ b/CPP/7zip/UI/Common/Extract.cpp @@ -163,7 +163,8 @@ HRESULT DecompressArchives( archiveFileInfo.Size, archiveLink.GetDefaultItemName(), wildcardCensor, options, extractCallback, extractCallbackSpec, errorMessage)); - extractCallbackSpec->LocalProgressSpec->InSize += archiveFileInfo.Size; + extractCallbackSpec->LocalProgressSpec->InSize += archiveFileInfo.Size + + archiveLink.VolumesSize; extractCallbackSpec->LocalProgressSpec->OutSize = extractCallbackSpec->UnpackSize; if (!errorMessage.IsEmpty()) return E_FAIL; diff --git a/CPP/7zip/UI/Common/OpenArchive.cpp b/CPP/7zip/UI/Common/OpenArchive.cpp index b2941df5..2874f6a7 100755 --- a/CPP/7zip/UI/Common/OpenArchive.cpp +++ b/CPP/7zip/UI/Common/OpenArchive.cpp @@ -366,8 +366,10 @@ HRESULT MyOpenArchive( UString &defaultItemName0, UString &defaultItemName1, UStringVector &volumePaths, + UInt64 &volumesSize, IOpenCallbackUI *openCallbackUI) { + volumesSize = 0; COpenCallbackImp *openCallbackSpec = new COpenCallbackImp; CMyComPtr<IArchiveOpenCallback> openCallback = openCallbackSpec; openCallbackSpec->Callback = openCallbackUI; @@ -391,6 +393,7 @@ HRESULT MyOpenArchive( volumePaths.Add(prefix + name); for (int i = 0; i < openCallbackSpec->FileNames.Size(); i++) volumePaths.Add(prefix + openCallbackSpec->FileNames[i]); + volumesSize = openCallbackSpec->TotalSize; return S_OK; } @@ -435,6 +438,7 @@ HRESULT MyOpenArchive(CCodecs *codecs, &archiveLink.Archive0, &archiveLink.Archive1, archiveLink.DefaultItemName0, archiveLink.DefaultItemName1, archiveLink.VolumePaths, + archiveLink.VolumesSize, openCallbackUI); archiveLink.IsOpen = (res == S_OK); return res; diff --git a/CPP/7zip/UI/Common/OpenArchive.h b/CPP/7zip/UI/Common/OpenArchive.h index 412b2e3b..7b424463 100755 --- a/CPP/7zip/UI/Common/OpenArchive.h +++ b/CPP/7zip/UI/Common/OpenArchive.h @@ -69,6 +69,7 @@ HRESULT MyOpenArchive( UString &defaultItemName0, UString &defaultItemName1, UStringVector &volumePaths, + UInt64 &volumesSize, IOpenCallbackUI *openCallbackUI); struct CArchiveLink @@ -83,6 +84,8 @@ struct CArchiveLink UStringVector VolumePaths; + UInt64 VolumesSize; + int GetNumLevels() const { int result = 0; @@ -97,7 +100,7 @@ struct CArchiveLink bool IsOpen; - CArchiveLink(): IsOpen(false) {}; + CArchiveLink(): IsOpen(false), VolumesSize(0) {}; IInArchive *GetArchive() { return Archive1 != 0 ? Archive1: Archive0; } UString GetDefaultItemName() { return Archive1 != 0 ? DefaultItemName1: DefaultItemName0; } diff --git a/CPP/7zip/UI/Console/Main.cpp b/CPP/7zip/UI/Console/Main.cpp index 7afc6f7c..bbee32e9 100755 --- a/CPP/7zip/UI/Console/Main.cpp +++ b/CPP/7zip/UI/Console/Main.cpp @@ -7,12 +7,9 @@ #include "Common/CommandLineParser.h" #include "Common/MyException.h" #include "Common/IntToString.h" -#include "Common/ListFileUtils.h" -#include "Common/StdInStream.h" #include "Common/StdOutStream.h" #include "Common/StringConvert.h" #include "Common/StringToInt.h" -#include "Common/Wildcard.h" #include "Windows/FileDir.h" #include "Windows/FileName.h" diff --git a/CPP/7zip/UI/Explorer/Explorer.dsp b/CPP/7zip/UI/Explorer/Explorer.dsp index 2f9252c7..811ee2c5 100755 --- a/CPP/7zip/UI/Explorer/Explorer.dsp +++ b/CPP/7zip/UI/Explorer/Explorer.dsp @@ -371,14 +371,6 @@ SOURCE=..\..\..\Common\Random.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\StdInStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StdInStream.h -# End Source File -# Begin Source File - SOURCE=..\..\..\Common\StringConvert.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/UI/Explorer/makefile b/CPP/7zip/UI/Explorer/makefile index d2203b2c..c58531d8 100755 --- a/CPP/7zip/UI/Explorer/makefile +++ b/CPP/7zip/UI/Explorer/makefile @@ -17,16 +17,14 @@ EXPLORER_OBJS = \ COMMON_OBJS = \ $O\IntToString.obj \ $O\Lang.obj \ - $O\ListFileUtils.obj \ + $O\MyString.obj \ + $O\MyVector.obj \ $O\NewHandler.obj \ $O\Random.obj \ - $O\StdInStream.obj \ - $O\MyString.obj \ $O\StringConvert.obj \ $O\StringToInt.obj \ $O\TextConfig.obj \ $O\UTFConvert.obj \ - $O\MyVector.obj \ $O\Wildcard.obj \ WIN_OBJS = \ diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp index d0957a40..c176ac92 100755 --- a/CPP/7zip/UI/Far/Plugin.cpp +++ b/CPP/7zip/UI/Far/Plugin.cpp @@ -79,6 +79,10 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) throw 272340; CSysString oemString = UnicodeStringToMultiByte(propVariant.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); + MyStringCopy(panelItem.FindData.cFileName, (const char *)oemString); panelItem.FindData.cAlternateFileName[0] = 0; diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp index 0f88ce47..86479f04 100755 --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -18,6 +18,7 @@ #include "ExtractCallback.h" #include "ViewSettings.h" #include "RegistryUtils.h" +#include "LangUtils.h" using namespace NWindows; using namespace NFile; @@ -32,6 +33,7 @@ void CPanelCallbackImp::OnTab() { if (g_App.NumPanels != 1) _app->Panels[1 - _index].SetFocusToList(); + _app->RefreshTitle(); } void CPanelCallbackImp::SetFocusToPath(int index) @@ -40,26 +42,17 @@ void CPanelCallbackImp::SetFocusToPath(int index) if (g_App.NumPanels == 1) newPanelIndex = g_App.LastFocusedPanel; _app->Panels[newPanelIndex]._headerComboBox.SetFocus(); + _app->RefreshTitle(); } -void CPanelCallbackImp::OnCopy(bool move, bool copyToSame) - { _app->OnCopy(move, copyToSame, _index); } - -void CPanelCallbackImp::OnSetSameFolder() - { _app->OnSetSameFolder(_index); } - -void CPanelCallbackImp::OnSetSubFolder() - { _app->OnSetSubFolder(_index); } - -void CPanelCallbackImp::PanelWasFocused() - { _app->SetFocusedPanel(_index); } - -void CPanelCallbackImp::DragBegin() - { _app->DragBegin(_index); } - -void CPanelCallbackImp::DragEnd() - { _app->DragEnd(); } +void CPanelCallbackImp::OnCopy(bool move, bool copyToSame) { _app->OnCopy(move, copyToSame, _index); } +void CPanelCallbackImp::OnSetSameFolder() { _app->OnSetSameFolder(_index); } +void CPanelCallbackImp::OnSetSubFolder() { _app->OnSetSubFolder(_index); } +void CPanelCallbackImp::PanelWasFocused() { _app->SetFocusedPanel(_index); _app->RefreshTitle(_index); } +void CPanelCallbackImp::DragBegin() { _app->DragBegin(_index); } +void CPanelCallbackImp::DragEnd() { _app->DragEnd(); } +void CPanelCallbackImp::RefreshTitle(bool always) { _app->RefreshTitle(_index, always); } void CApp::SetListSettings() { @@ -636,6 +629,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) } } + RefreshTitleAlways(); if (copyToSame || move) { srcPanel.RefreshListCtrl(srcSelState); @@ -757,3 +751,22 @@ void CApp::OnNotify(int /* ctrlID */, LPNMHDR pnmh) #endif } } + +void CApp::RefreshTitle(bool always) +{ + UString path = GetFocusedPanel()._currentFolderPrefix; + if (path.IsEmpty()) + path += LangString(IDS_APP_TITLE, 0x03000000); + if (!always && path == PrevTitle) + return; + PrevTitle = path; + NWindows::MySetWindowText(_window, path); +} + +void CApp::RefreshTitle(int panelIndex, bool always) +{ + if (panelIndex != GetFocusedPanelIndex()) + return; + RefreshTitle(always); +} + diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h index faa40afe..2479d81e 100755 --- a/CPP/7zip/UI/FileManager/App.h +++ b/CPP/7zip/UI/FileManager/App.h @@ -41,6 +41,7 @@ public: virtual void PanelWasFocused(); virtual void DragBegin(); virtual void DragEnd(); + virtual void RefreshTitle(bool always); }; class CApp; @@ -216,6 +217,8 @@ public: { GetFocusedPanel().CreateFile(); } // Edit + void EditCut() + { GetFocusedPanel().EditCut(); } void EditCopy() { GetFocusedPanel().EditCopy(); } void EditPaste() @@ -327,6 +330,11 @@ public: { GetFocusedPanel().TestArchives(); } void OnNotify(int ctrlID, LPNMHDR pnmh); + + UString PrevTitle; + void RefreshTitle(bool always = false); + void RefreshTitleAlways() { RefreshTitle(true); } + void RefreshTitle(int panelIndex, bool always = false); }; #endif diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp index 1ba0bcf1..d2284325 100755 --- a/CPP/7zip/UI/FileManager/FM.dsp +++ b/CPP/7zip/UI/FileManager/FM.dsp @@ -759,6 +759,14 @@ SOURCE=..\..\..\Windows\Control\Window2.h # End Group # Begin Source File +SOURCE=..\..\..\Windows\Clipboard.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\Clipboard.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\CommonDialog.cpp # End Source File # Begin Source File @@ -999,14 +1007,6 @@ SOURCE=..\..\..\Common\Lang.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\ListFileUtils.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\ListFileUtils.h -# End Source File -# Begin Source File - SOURCE=..\..\..\Common\MyCom.h # End Source File # Begin Source File @@ -1043,22 +1043,6 @@ SOURCE=..\..\..\Common\Random.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\StdInStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StdInStream.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StdOutStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StdOutStream.h -# End Source File -# Begin Source File - SOURCE=..\..\..\Common\StringConvert.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp index 9a88f674..f6994066 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.cpp +++ b/CPP/7zip/UI/FileManager/FSFolder.cpp @@ -5,8 +5,6 @@ #include "FSFolder.h" #include "Common/StringConvert.h" -#include "Common/StdInStream.h" -#include "Common/StdOutStream.h" #include "Common/UTFConvert.h" #include "Common/ComTry.h" @@ -73,7 +71,7 @@ HRESULT CFSFolder::Init(const UString &path, IFolderFolder *parentFolder) return S_OK; } -static HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress) +HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress) { RINOK(progress->SetCompleted(NULL)); numFiles = numFolders = size = 0; diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h index 63de80cc..d938969f 100755 --- a/CPP/7zip/UI/FileManager/FSFolder.h +++ b/CPP/7zip/UI/FileManager/FSFolder.h @@ -113,6 +113,8 @@ public: } }; +HRESULT GetFolderSize(const UString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress); + } #endif diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp index 1a1b2250..32823fb9 100755 --- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp +++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp @@ -469,6 +469,40 @@ STDMETHODIMP CFSFolder::MoveTo( STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */, const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */) { + /* + UInt64 numFolders, numFiles, totalSize; + numFiles = numFolders = totalSize = 0; + UInt32 i; + for (i = 0; i < numItems; i++) + { + UString path = (UString)fromFolderPath + itemsPaths[i]; + + CFileInfoW fileInfo; + if (!FindFile(path, fileInfo)) + return ::GetLastError(); + if (fileInfo.IsDirectory()) + { + UInt64 subFolders, subFiles, subSize; + RINOK(GetFolderSize(path + UString(L"\\") + fileInfo.Name, subFolders, subFiles, subSize, progress)); + numFolders += subFolders; + numFolders++; + numFiles += subFiles; + totalSize += subSize; + } + else + { + numFiles++; + totalSize += fileInfo.Size; + } + } + RINOK(progress->SetTotal(totalSize)); + RINOK(callback->SetNumFiles(numFiles)); + for (i = 0; i < numItems; i++) + { + UString path = (UString)fromFolderPath + itemsPaths[i]; + } + return S_OK; + */ return E_NOTIMPL; } diff --git a/CPP/7zip/UI/FileManager/LangUtils.cpp b/CPP/7zip/UI/FileManager/LangUtils.cpp index f41e764e..bf75df00 100755 --- a/CPP/7zip/UI/FileManager/LangUtils.cpp +++ b/CPP/7zip/UI/FileManager/LangUtils.cpp @@ -35,7 +35,7 @@ void ReloadLang() if (GetProgramFolderPath(folderPath)) langPath = folderPath + UString(L"Lang\\") + langPath; } - g_Lang.Open(GetSystemString(langPath)); + g_Lang.Open(langPath); } } @@ -107,7 +107,7 @@ void LoadLangs(CObjectVector<CLangEx> &langs) if (fileInfo.Name.Right(kExtSize) != L".txt") continue; lang.ShortName = fileInfo.Name.Left(fileInfo.Name.Length() - kExtSize); - if (lang.Lang.Open(GetSystemString(filePath))) + if (lang.Lang.Open(filePath)) langs.Add(lang); } } diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp index a2a6c202..4ad152b1 100755 --- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp @@ -6,6 +6,7 @@ #include "Windows/Menu.h" #include "Windows/Error.h" +#include "Windows/Clipboard.h" #include "../../PropID.h" @@ -30,6 +31,7 @@ extern void OptionsDialog(HWND hwndOwner, HINSTANCE hInstance); using namespace NWindows; static const int kFileMenuIndex = 0; +static const int kEditMenuIndex = 1; static const int kViewMenuIndex = 2; static const int kBookmarksMenuIndex = kViewMenuIndex + 1; @@ -321,7 +323,16 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) } // CopyMenu(g_FileMenu, hMenu); g_App.GetFocusedPanel().CreateFileMenu(hMenu); - + } + else if (position == kEditMenuIndex) + { + /* + CMenu menu; + menu.Attach(hMenu); + menu.EnableItem(IDM_EDIT_CUT, MF_ENABLED); + menu.EnableItem(IDM_EDIT_COPY, MF_ENABLED); + menu.EnableItem(IDM_EDIT_PASTE, IsClipboardFormatAvailableHDROP() ? MF_ENABLED : MF_GRAYED); + */ } else if (position == kViewMenuIndex) { @@ -545,6 +556,9 @@ bool OnMenuCommand(HWND hWnd, int id) break; // Edit + case IDM_EDIT_CUT: + g_App.EditCut(); + break; case IDM_EDIT_COPY: g_App.EditCopy(); break; diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp index b1ef614f..ac6e7d4b 100755 --- a/CPP/7zip/UI/FileManager/Panel.cpp +++ b/CPP/7zip/UI/FileManager/Panel.cpp @@ -891,6 +891,7 @@ void CPanel::TestArchives() _folder.QueryInterface(IID_IArchiveFolder, &archiveFolder); if (archiveFolder) { + { CThreadTest extracter; extracter.ArchiveFolder = archiveFolder; @@ -938,6 +939,8 @@ void CPanel::TestArchives() if (extracter.Result != S_OK && extracter.Result != E_ABORT) MessageBoxError(extracter.Result, L"Testing Error"); } + } + RefreshTitleAlways(); return; } diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h index 1f6dc140..a9c6a304 100755 --- a/CPP/7zip/UI/FileManager/Panel.h +++ b/CPP/7zip/UI/FileManager/Panel.h @@ -32,9 +32,8 @@ const int kToolbarStartID = 2000; const int kParentIndex = -1; -class CPanelCallback +struct CPanelCallback { -public: virtual void OnTab() = 0; virtual void SetFocusToPath(int index) = 0; virtual void OnCopy(bool move, bool copyToSame) = 0; @@ -43,6 +42,7 @@ public: virtual void PanelWasFocused() = 0; virtual void DragBegin() = 0; virtual void DragEnd() = 0; + virtual void RefreshTitle(bool always) = 0; }; void PanelCopyItems(); @@ -378,6 +378,7 @@ public: void InvokeSystemCommand(const char *command); void Properties(); + void EditCut(); void EditCopy(); void EditPaste(); @@ -499,13 +500,17 @@ public: HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, bool showErrorMessages, UStringVector *messages); - void CopyFrom(const UStringVector &filePaths); + void CopyFromNoAsk(const UStringVector &filePaths); + void CopyFromAsk(const UStringVector &filePaths); // empty folderPath means create new Archive to path of first fileName. void DropObject(IDataObject * dataObject, const UString &folderPath); // empty folderPath means create new Archive to path of first fileName. void CompressDropFiles(const UStringVector &fileNames, const UString &folderPath); + + void RefreshTitle(bool always = false) { _panelCallback->RefreshTitle(always); } + void RefreshTitleAlways() { RefreshTitle(true); } }; #endif diff --git a/CPP/7zip/UI/FileManager/PanelCopy.cpp b/CPP/7zip/UI/FileManager/PanelCopy.cpp index 0bb5dafa..c5745010 100755 --- a/CPP/7zip/UI/FileManager/PanelCopy.cpp +++ b/CPP/7zip/UI/FileManager/PanelCopy.cpp @@ -58,37 +58,42 @@ HRESULT CPanel::CopyTo(const CRecordVector<UInt32> &indices, const UString &fold return E_FAIL; } + HRESULT res; + { CThreadExtractInArchive2 extracter; - + extracter.ExtractCallbackSpec = new CExtractCallbackImp; extracter.ExtractCallback = extracter.ExtractCallbackSpec; extracter.ExtractCallbackSpec->ParentWindow = GetParent(); extracter.ExtractCallbackSpec->ShowMessages = showErrorMessages; extracter.ExtractCallbackSpec->ProgressDialog.CompressingMode = false; - + UString title = moveMode ? LangString(IDS_MOVING, 0x03020206): LangString(IDS_COPYING, 0x03020205); UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - + extracter.ExtractCallbackSpec->ProgressDialog.MainWindow = GetParent(); extracter.ExtractCallbackSpec->ProgressDialog.MainTitle = progressWindowTitle; extracter.ExtractCallbackSpec->ProgressDialog.MainAddTitle = title + L" "; - + extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore; extracter.ExtractCallbackSpec->Init(); extracter.Indices = indices; extracter.DestPath = folder; extracter.FolderOperations = folderOperations; extracter.MoveMode = moveMode; - + NWindows::CThread extractThread; RINOK(extractThread.Create(CThreadExtractInArchive2::MyThreadFunction, &extracter)); extracter.ExtractCallbackSpec->StartProgressDialog(title); - + if (messages != 0) *messages = extracter.ExtractCallbackSpec->Messages; - return extracter.Result; + res = extracter.Result; + } + RefreshTitleAlways(); + return res; } @@ -135,6 +140,8 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP return E_FAIL; } + HRESULT res; + { CThreadUpdate updater; updater.UpdateCallbackSpec = new CUpdateCallback100Imp; updater.UpdateCallback = updater.UpdateCallbackSpec; @@ -164,20 +171,14 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP if (messages != 0) *messages = updater.UpdateCallbackSpec->Messages; - return updater.Result; + res = updater.Result; + } + RefreshTitleAlways(); + return res; } -void CPanel::CopyFrom(const UStringVector &filePaths) +void CPanel::CopyFromNoAsk(const UStringVector &filePaths) { - UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222); - UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223); - message += L"\n\'"; - message += _currentFolderPrefix; - message += L"\' ?"; - int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL); - if (res != IDYES) - return; - CDisableTimerProcessing disableTimerProcessing(*this); CSelectedState srcSelState; @@ -201,3 +202,17 @@ void CPanel::CopyFrom(const UStringVector &filePaths) SetFocusToList(); } +void CPanel::CopyFromAsk(const UStringVector &filePaths) +{ + UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222); + UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223); + message += L"\n\'"; + message += _currentFolderPrefix; + message += L"\' ?"; + int res = ::MessageBoxW(*(this), message, title, MB_YESNOCANCEL | MB_ICONQUESTION | MB_SYSTEMMODAL); + if (res != IDYES) + return; + + CopyFromNoAsk(filePaths); +} + diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp index b2163742..4ce435da 100755 --- a/CPP/7zip/UI/FileManager/PanelCrc.cpp +++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp @@ -290,6 +290,7 @@ void CApp::CalculateCrc() combiner.DirEnumerator.BasePrefix = srcPanel._currentFolderPrefix; combiner.DirEnumerator.FlatMode = GetFlatMode(); + { CProgressDialog progressDialog; combiner.ProgressDialog = &progressDialog; combiner.ErrorCode = 0; @@ -362,4 +363,6 @@ void CApp::CalculateCrc() } srcPanel.MessageBoxInfo(s, LangString(IDS_CHECKSUM_INFORMATION, 0x03020720)); } + } + RefreshTitleAlways(); } diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp index 0baa151a..f242c8a1 100755 --- a/CPP/7zip/UI/FileManager/PanelDrag.cpp +++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp @@ -792,5 +792,5 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo ); } else - CopyFrom(fileNames); + CopyFromAsk(fileNames); } diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp index a8cfb3be..d6fdcc98 100755 --- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp +++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp @@ -145,6 +145,7 @@ void CPanel::LoadFullPathAndShow() // _headerComboBox.SendMessage(CB_RESETCONTENT, 0, 0); _headerComboBox.SetText(_currentFolderPrefix); + RefreshTitle(); /* for (int i = 0; i < g_Folders.m_Strings.Size(); i++) diff --git a/CPP/7zip/UI/FileManager/PanelKey.cpp b/CPP/7zip/UI/FileManager/PanelKey.cpp index 5f002de9..218476ed 100755 --- a/CPP/7zip/UI/FileManager/PanelKey.cpp +++ b/CPP/7zip/UI/FileManager/PanelKey.cpp @@ -157,8 +157,25 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) } case VK_INSERT: { - OnInsert(); - return true; + if (!alt) + { + if (ctrl && !shift) + { + EditCopy(); + return true; + } + if (shift && !ctrl) + { + EditPaste(); + return true; + } + if (!shift && !ctrl && _mySelectMode) + { + OnInsert(); + return true; + } + } + return false; } case VK_DOWN: { @@ -249,6 +266,27 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) return true; } return false; + case 'X': + if (ctrl) + { + EditCut(); + return true; + } + return false; + case 'C': + if (ctrl) + { + EditCopy(); + return true; + } + return false; + case 'V': + if (ctrl) + { + EditPaste(); + return true; + } + return false; case 'N': if (ctrl) { diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp index 58d457cb..8ebbc8ac 100755 --- a/CPP/7zip/UI/FileManager/PanelMenu.cpp +++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp @@ -4,6 +4,7 @@ #include "Windows/Menu.h" #include "Windows/COM.h" #include "Windows/PropVariant.h" +#include "Windows/Clipboard.h" #include "../Common/PropIDUtils.h" #include "../../PropID.h" @@ -27,6 +28,7 @@ static const UINT kSystemStartMenuID = kPluginMenuStartID + 100; void CPanel::InvokeSystemCommand(const char *command) { + NCOM::CComInitializer comInitializer; if (!IsFSFolder() && !IsFSDrivesFolder()) return; CRecordVector<UInt32> operatedIndices; @@ -181,18 +183,51 @@ void CPanel::Properties() } } -// Copy and paste do not work, if you know why write me. +void CPanel::EditCut() +{ + // InvokeSystemCommand("cut"); +} void CPanel::EditCopy() { - NCOM::CComInitializer comInitializer; - InvokeSystemCommand("copy"); + /* + CMyComPtr<IGetFolderArchiveProperties> getFolderArchiveProperties; + _folder.QueryInterface(IID_IGetFolderArchiveProperties, &getFolderArchiveProperties); + if (!getFolderArchiveProperties) + { + InvokeSystemCommand("copy"); + return; + } + */ + UString s; + CRecordVector<UInt32> indices; + GetSelectedItemsIndices(indices); + for (int i = 0; i < indices.Size(); i++) + { + if (i > 0) + s += L"\xD\n"; + s += GetItemName(indices[i]); + } + ClipboardSetText(_mainWindow, s); } void CPanel::EditPaste() { - NCOM::CComInitializer comInitializer; - InvokeSystemCommand("paste"); + /* + UStringVector names; + ClipboardGetFileNames(names); + CopyFromNoAsk(names); + UString s; + for (int i = 0; i < names.Size(); i++) + { + s += L" "; + s += names[i]; + } + + MessageBoxW(0, s, L"", 0); + */ + + // InvokeSystemCommand("paste"); } HRESULT CPanel::CreateShellContextMenu( diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp index 392ca370..2cdabdc1 100755 --- a/CPP/7zip/UI/FileManager/PanelOperations.cpp +++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp @@ -220,6 +220,7 @@ void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices) if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK) return; + { CThreadDelete deleter; deleter.UpdateCallbackSpec = new CUpdateCallback100Imp; deleter.UpdateCallback = deleter.UpdateCallbackSpec; @@ -242,6 +243,8 @@ void CPanel::DeleteItemsInternal(CRecordVector<UInt32> &indices) HRESULT result = deleter.Result; if (result != S_OK) MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217)); + } + RefreshTitleAlways(); } BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh) @@ -319,6 +322,7 @@ void CPanel::CreateFolder() // HRESULT result = folderOperations->CreateFolder(newName, 0); + { CThreadCreateFolder upd; upd.UpdateCallbackSpec = new CUpdateCallback100Imp; upd.UpdateCallback = upd.UpdateCallbackSpec; @@ -352,6 +356,8 @@ void CPanel::CreateFolder() state.SelectedNames.Clear(); state.FocusedName = newName; state.SelectFocused = true; + } + RefreshTitleAlways(); RefreshListCtrl(state); } diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp index b9cce2d8..cbfc6c25 100755 --- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp +++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp @@ -259,6 +259,7 @@ void CApp::Split() CThreadSplit spliter; // spliter.Panel = this; + { CProgressDialog progressDialog; spliter.ProgressDialog = &progressDialog; @@ -284,6 +285,9 @@ void CApp::Split() if (thread.Create(CThreadSplit::MyThreadFunction, &spliter) != S_OK) throw 271824; progressDialog.Create(title, _window); + } + RefreshTitleAlways(); + if (!spliter.Error.IsEmpty()) srcPanel.MessageBoxMyError(spliter.Error); @@ -442,6 +446,7 @@ void CApp::Combine() CThreadCombine combiner; // combiner.Panel = this; + { CProgressDialog progressDialog; combiner.ProgressDialog = &progressDialog; @@ -471,6 +476,8 @@ void CApp::Combine() if (thread.Create(CThreadCombine::MyThreadFunction, &combiner) != S_OK) throw 271824; progressDialog.Create(title, _window); + } + RefreshTitleAlways(); if (!combiner.Error.IsEmpty()) srcPanel.MessageBoxMyError(combiner.Error); diff --git a/CPP/7zip/UI/FileManager/makefile b/CPP/7zip/UI/FileManager/makefile index 68723921..0b815ad9 100755 --- a/CPP/7zip/UI/FileManager/makefile +++ b/CPP/7zip/UI/FileManager/makefile @@ -70,20 +70,18 @@ COMMON_OBJS = \ $O\CRC.obj \ $O\IntToString.obj \ $O\Lang.obj \ - $O\ListFileUtils.obj \ + $O\MyString.obj \ + $O\MyVector.obj \ $O\NewHandler.obj \ $O\Random.obj \ - $O\StdInStream.obj \ - $O\StdOutStream.obj \ - $O\MyString.obj \ $O\StringConvert.obj \ $O\StringToInt.obj \ $O\TextConfig.obj \ $O\UTFConvert.obj \ - $O\MyVector.obj \ $O\Wildcard.obj \ WIN_OBJS = \ + $O\Clipboard.obj \ $O\CommonDialog.obj \ $O\DLL.obj \ $O\Error.obj \ diff --git a/CPP/7zip/UI/GUI/GUI.dsp b/CPP/7zip/UI/GUI/GUI.dsp index 4a5ad512..b61ef92f 100755 --- a/CPP/7zip/UI/GUI/GUI.dsp +++ b/CPP/7zip/UI/GUI/GUI.dsp @@ -759,14 +759,6 @@ SOURCE=..\..\..\Common\NewHandler.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\StdInStream.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\StdInStream.h -# End Source File -# Begin Source File - SOURCE=..\..\..\Common\StringConvert.cpp # End Source File # Begin Source File diff --git a/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp b/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp index ae204d17..7717de99 100755 --- a/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp +++ b/CPP/7zip/UI/GUI/OpenCallbackGUI.cpp @@ -4,10 +4,6 @@ #include "OpenCallbackGUI.h" -#include "Common/StdOutStream.h" -#include "Common/StdInStream.h" -#include "Common/StringConvert.h" - #ifndef _NO_CRYPTO #include "../FileManager/PasswordDialog.h" #endif diff --git a/CPP/7zip/UI/GUI/makefile b/CPP/7zip/UI/GUI/makefile index f321e560..e37ce7d5 100755 --- a/CPP/7zip/UI/GUI/makefile +++ b/CPP/7zip/UI/GUI/makefile @@ -25,14 +25,13 @@ COMMON_OBJS = \ $O\IntToString.obj \ $O\Lang.obj \ $O\ListFileUtils.obj \ - $O\NewHandler.obj \ - $O\StdInStream.obj \ $O\MyString.obj \ + $O\MyVector.obj \ + $O\NewHandler.obj \ $O\StringConvert.obj \ $O\StringToInt.obj \ $O\TextConfig.obj \ $O\UTFConvert.obj \ - $O\MyVector.obj \ $O\Wildcard.obj \ WIN_OBJS = \ diff --git a/CPP/Common/Lang.cpp b/CPP/Common/Lang.cpp index 803209cf..7316ade4 100755 --- a/CPP/Common/Lang.cpp +++ b/CPP/Common/Lang.cpp @@ -5,40 +5,18 @@ #include "Lang.h" #include "TextConfig.h" -#include "StdInStream.h" +#include "../Windows/FileIO.h" #include "UTFConvert.h" #include "Defs.h" -/* -static UInt32 HexStringToNumber(const char *string, int &finishPos) +static bool HexStringToNumber(const UString &s, UInt32 &value) { - UInt32 number = 0; - for (finishPos = 0; finishPos < 8; finishPos++) - { - char c = string[finishPos]; - int a; - if (c >= '0' && c <= '9') - a = c - '0'; - else if (c >= 'A' && c <= 'F') - a = 10 + c - 'A'; - else if (c >= 'a' && c <= 'f') - a = 10 + c - 'a'; - else - return number; - number *= 0x10; - number += a; - } - return number; -} -*/ -static bool HexStringToNumber(const UString &string, UInt32 &aResultValue) -{ - aResultValue = 0; - if (string.IsEmpty()) + value = 0; + if (s.IsEmpty()) return false; - for (int i = 0; i < string.Length(); i++) + for (int i = 0; i < s.Length(); i++) { - wchar_t c = string[i]; + wchar_t c = s[i]; int a; if (c >= L'0' && c <= L'9') a = c - L'0'; @@ -48,17 +26,17 @@ static bool HexStringToNumber(const UString &string, UInt32 &aResultValue) a = 10 + c - L'a'; else return false; - aResultValue *= 0x10; - aResultValue += a; + value *= 0x10; + value += a; } return true; } -static bool WaitNextLine(const AString &string, int &pos) +static bool WaitNextLine(const AString &s, int &pos) { - for (;pos < string.Length(); pos++) - if (string[pos] == 0x0A) + for (; pos < s.Length(); pos++) + if (s[pos] == 0x0A) return true; return false; } @@ -70,19 +48,29 @@ static int CompareLangItems(void *const *elem1, void *const *elem2, void *) return MyCompare(langPair1.Value, langPair2.Value); } -bool CLang::Open(LPCTSTR fileName) +bool CLang::Open(LPCWSTR fileName) { _langPairs.Clear(); - CStdInStream file; + NWindows::NFile::NIO::CInFile file; if (!file.Open(fileName)) return false; - AString string; - file.ReadToString(string); + UInt64 length; + if (!file.GetLength(length)) + return false; + if (length > (1 << 20)) + return false; + AString s; + char *p = s.GetBuffer((int)length + 1); + UInt32 processed; + if (!file.Read(p, (UInt32)length, processed)) + return false; + p[(UInt32)length] = 0; + s.ReleaseBuffer(); file.Close(); int pos = 0; - if (string.Length() >= 3) + if (s.Length() >= 3) { - if (Byte(string[0]) == 0xEF && Byte(string[1]) == 0xBB && Byte(string[2]) == 0xBF) + if (Byte(s[0]) == 0xEF && Byte(s[1]) == 0xBB && Byte(s[2]) == 0xBF) pos += 3; } @@ -90,15 +78,15 @@ bool CLang::Open(LPCTSTR fileName) // read header AString stringID = ";!@Lang@!UTF-8!"; - if (string.Mid(pos, stringID.Length()) != stringID) + if (s.Mid(pos, stringID.Length()) != stringID) return false; pos += stringID.Length(); - if (!WaitNextLine(string, pos)) + if (!WaitNextLine(s, pos)) return false; CObjectVector<CTextConfigPair> pairs; - if (!GetTextConfig(string.Mid(pos), pairs)) + if (!GetTextConfig(s.Mid(pos), pairs)) return false; _langPairs.Reserve(_langPairs.Size()); diff --git a/CPP/Common/Lang.h b/CPP/Common/Lang.h index acbf8a6b..cf978758 100755 --- a/CPP/Common/Lang.h +++ b/CPP/Common/Lang.h @@ -17,7 +17,7 @@ class CLang { CObjectVector<CLangPair> _langPairs; public: - bool Open(LPCTSTR fileName); + bool Open(LPCWSTR fileName); void Clear() { _langPairs.Clear(); } int FindItem(UInt32 value) const; bool GetMessage(UInt32 value, UString &message) const; diff --git a/CPP/Common/ListFileUtils.cpp b/CPP/Common/ListFileUtils.cpp index 349622ed..4f8a9e59 100755 --- a/CPP/Common/ListFileUtils.cpp +++ b/CPP/Common/ListFileUtils.cpp @@ -2,8 +2,9 @@ #include "StdAfx.h" +#include "../Windows/FileIO.h" + #include "ListFileUtils.h" -#include "StdInStream.h" #include "StringConvert.h" #include "UTFConvert.h" @@ -15,14 +16,25 @@ static void RemoveQuote(UString &s) s = s.Mid(1, s.Length() - 2); } -bool ReadNamesFromListFile(LPCTSTR fileName, UStringVector &resultStrings, UINT codePage) +bool ReadNamesFromListFile(LPCWSTR fileName, UStringVector &resultStrings, UINT codePage) { - CStdInStream file; + NWindows::NFile::NIO::CInFile file; if (!file.Open(fileName)) return false; - + UInt64 length; + if (!file.GetLength(length)) + return false; + if (length > ((UInt32)1 << 31)) + return false; AString s; - file.ReadToString(s); + char *p = s.GetBuffer((int)length + 1); + UInt32 processed; + if (!file.Read(p, (UInt32)length, processed)) + return false; + p[(UInt32)length] = 0; + s.ReleaseBuffer(); + file.Close(); + UString u; #ifdef CP_UTF8 if (codePage == CP_UTF8) @@ -43,7 +55,7 @@ bool ReadNamesFromListFile(LPCTSTR fileName, UStringVector &resultStrings, UINT for(int i = 0; i < u.Length(); i++) { wchar_t c = u[i]; - if (c == L'\n') + if (c == L'\n' || c == 0xD) { t.Trim(); RemoveQuote(t); diff --git a/CPP/Common/ListFileUtils.h b/CPP/Common/ListFileUtils.h index 182d32fa..c58a8bd4 100755 --- a/CPP/Common/ListFileUtils.h +++ b/CPP/Common/ListFileUtils.h @@ -6,6 +6,6 @@ #include "MyString.h" #include "Types.h" -bool ReadNamesFromListFile(LPCTSTR fileName, UStringVector &strings, UINT codePage = CP_OEMCP); +bool ReadNamesFromListFile(LPCWSTR fileName, UStringVector &strings, UINT codePage = CP_OEMCP); #endif diff --git a/CPP/Common/StdInStream.cpp b/CPP/Common/StdInStream.cpp index 923f366e..8fed7bc0 100755 --- a/CPP/Common/StdInStream.cpp +++ b/CPP/Common/StdInStream.cpp @@ -75,7 +75,7 @@ bool CStdInStream::Eof() int CStdInStream::GetChar() { - int c = getc(_stream); + int c = fgetc(_stream); // getc() doesn't work in BeOS? if(c == EOF && !Eof()) throw kReadErrorMessage; return c; diff --git a/CPP/Windows/Clipboard.cpp b/CPP/Windows/Clipboard.cpp new file mode 100755 index 00000000..cc27d3da --- /dev/null +++ b/CPP/Windows/Clipboard.cpp @@ -0,0 +1,131 @@ +// Windows/Clipboard.cpp + +#include "StdAfx.h" + +#include "Windows/Clipboard.h" +#include "Windows/Defs.h" +#include "Windows/Memory.h" +#include "Windows/Shell.h" +#include "Windows/Memory.h" + +#include "Common/StringConvert.h" + +namespace NWindows { + +bool CClipboard::Open(HWND wndNewOwner) +{ + m_Open = BOOLToBool(::OpenClipboard(wndNewOwner)); + return m_Open; +} + +CClipboard::~CClipboard() +{ + Close(); +} + +bool CClipboard::Close() +{ + if (!m_Open) + return true; + m_Open = !BOOLToBool(CloseClipboard()); + return !m_Open; +} + +bool ClipboardIsFormatAvailableHDROP() +{ + return BOOLToBool(IsClipboardFormatAvailable(CF_HDROP)); +} + +/* +bool ClipboardGetTextString(AString &s) +{ + s.Empty(); + if (!IsClipboardFormatAvailable(CF_TEXT)) + return false; + CClipboard clipboard; + + if (!clipboard.Open(NULL)) + return false; + + HGLOBAL h = ::GetClipboardData(CF_TEXT); + if (h != NULL) + { + NMemory::CGlobalLock globalLock(h); + const char *p = (const char *)globalLock.GetPointer(); + if (p != NULL) + { + s = p; + return true; + } + } + return false; +} +*/ + +/* +bool ClipboardGetFileNames(UStringVector &names) +{ + names.Clear(); + if (!IsClipboardFormatAvailable(CF_HDROP)) + return false; + CClipboard clipboard; + + if (!clipboard.Open(NULL)) + return false; + + HGLOBAL h = ::GetClipboardData(CF_HDROP); + if (h != NULL) + { + NMemory::CGlobalLock globalLock(h); + void *p = (void *)globalLock.GetPointer(); + if (p != NULL) + { + NShell::CDrop drop(false); + drop.Attach((HDROP)p); + drop.QueryFileNames(names); + return true; + } + } + return false; +} +*/ + +static bool ClipboardSetData(UINT uFormat, const void *data, size_t size) +{ + NMemory::CGlobal global; + if (!global.Alloc(GMEM_DDESHARE | GMEM_MOVEABLE, size)) + return false; + { + NMemory::CGlobalLock globalLock(global); + LPVOID p = globalLock.GetPointer(); + if (p == NULL) + return false; + memcpy(p, data, size); + } + if (::SetClipboardData(uFormat, global) == NULL) + return false; + global.Detach(); + return true; +} + +bool ClipboardSetText(HWND owner, const UString &s) +{ + CClipboard clipboard; + if (!clipboard.Open(owner)) + return false; + if (!::EmptyClipboard()) + return false; + + bool res; + res = ClipboardSetData(CF_UNICODETEXT, (const wchar_t *)s, (s.Length() + 1) * sizeof(wchar_t)); + #ifndef _UNICODE + AString a; + a = UnicodeStringToMultiByte(s, CP_ACP); + res |= ClipboardSetData(CF_TEXT, (const char *)a, (a.Length() + 1) * sizeof(char)); + a = UnicodeStringToMultiByte(s, CP_OEMCP); + res |= ClipboardSetData(CF_OEMTEXT, (const char *)a, (a.Length() + 1) * sizeof(char)); + #endif + return res; +} + +} diff --git a/CPP/Windows/Clipboard.h b/CPP/Windows/Clipboard.h new file mode 100755 index 00000000..b97b5156 --- /dev/null +++ b/CPP/Windows/Clipboard.h @@ -0,0 +1,28 @@ +// Windows/Clipboard.h + +#ifndef __CLIPBOARD_H +#define __CLIPBOARD_H + +#include "Common/MyString.h" + +namespace NWindows { + +class CClipboard +{ + bool m_Open; +public: + CClipboard(): m_Open(false) {}; + ~CClipboard(); + bool Open(HWND wndNewOwner); + bool Close(); +}; + +bool ClipboardIsFormatAvailableHDROP(); + +// bool ClipboardGetFileNames(UStringVector &names); +// bool ClipboardGetTextString(AString &s); +bool ClipboardSetText(HWND owner, const UString &s); + +} + +#endif diff --git a/CPP/Windows/Menu.h b/CPP/Windows/Menu.h index 9e0d375c..aa800a61 100755 --- a/CPP/Windows/Menu.h +++ b/CPP/Windows/Menu.h @@ -119,6 +119,9 @@ public: { return BOOLToBool(::CheckMenuRadioItem(_menu, idFirst, idLast, idCheck, flags)); } DWORD CheckItem(UINT id, UINT uCheck) { return ::CheckMenuItem(_menu, id, uCheck); } + + BOOL EnableItem(UINT uIDEnableItem, UINT uEnable) + { return EnableMenuItem(_menu, uIDEnableItem, uEnable); } }; class CMenuDestroyer |