From f08f4dcc3c02464c17753b3feafcfe5243b9e236 Mon Sep 17 00:00:00 2001 From: Igor Pavlov Date: Sun, 23 Nov 2014 00:00:00 +0000 Subject: 9.34 --- CPP/7zip/UI/FileManager/7zFM.exe.manifest | 0 CPP/7zip/UI/FileManager/7zipLogo.ico | Bin CPP/7zip/UI/FileManager/AboutDialog.cpp | 46 +- CPP/7zip/UI/FileManager/AboutDialog.h | 7 +- CPP/7zip/UI/FileManager/AboutDialog.rc | 16 +- CPP/7zip/UI/FileManager/AboutDialogRes.h | 14 +- CPP/7zip/UI/FileManager/Add.bmp | Bin CPP/7zip/UI/FileManager/Add2.bmp | Bin CPP/7zip/UI/FileManager/App.cpp | 284 ++++--- CPP/7zip/UI/FileManager/App.h | 55 +- CPP/7zip/UI/FileManager/AppState.h | 41 +- CPP/7zip/UI/FileManager/BrowseDialog.cpp | 968 ++++++++++++++++------ CPP/7zip/UI/FileManager/BrowseDialog.h | 80 +- CPP/7zip/UI/FileManager/BrowseDialog.rc | 24 +- CPP/7zip/UI/FileManager/BrowseDialogRes.h | 13 +- CPP/7zip/UI/FileManager/ClassDefs.cpp | 3 +- CPP/7zip/UI/FileManager/ComboDialog.cpp | 18 +- CPP/7zip/UI/FileManager/ComboDialog.h | 7 +- CPP/7zip/UI/FileManager/ComboDialog.rc | 9 +- CPP/7zip/UI/FileManager/ComboDialogRes.h | 6 +- CPP/7zip/UI/FileManager/Copy.bmp | Bin CPP/7zip/UI/FileManager/Copy2.bmp | Bin CPP/7zip/UI/FileManager/CopyDialog.cpp | 44 +- CPP/7zip/UI/FileManager/CopyDialog.h | 6 +- CPP/7zip/UI/FileManager/CopyDialog.rc | 13 +- CPP/7zip/UI/FileManager/CopyDialogRes.h | 12 +- CPP/7zip/UI/FileManager/Delete.bmp | Bin CPP/7zip/UI/FileManager/Delete2.bmp | Bin CPP/7zip/UI/FileManager/DialogSize.h | 2 +- CPP/7zip/UI/FileManager/EditPage.cpp | 51 +- CPP/7zip/UI/FileManager/EditPage.h | 5 +- CPP/7zip/UI/FileManager/EditPage.rc | 0 CPP/7zip/UI/FileManager/EditPage2.rc | 17 +- CPP/7zip/UI/FileManager/EditPageRes.h | 21 +- CPP/7zip/UI/FileManager/EnumFormatEtc.cpp | 0 CPP/7zip/UI/FileManager/EnumFormatEtc.h | 0 CPP/7zip/UI/FileManager/Extract.bmp | Bin CPP/7zip/UI/FileManager/Extract2.bmp | Bin CPP/7zip/UI/FileManager/ExtractCallback.cpp | 644 ++++++++++++--- CPP/7zip/UI/FileManager/ExtractCallback.h | 217 ++++- CPP/7zip/UI/FileManager/FM.cpp | 334 +++++--- CPP/7zip/UI/FileManager/FM.dsp | 263 +++--- CPP/7zip/UI/FileManager/FM.dsw | 0 CPP/7zip/UI/FileManager/FM.ico | Bin CPP/7zip/UI/FileManager/FM.mak | 81 ++ CPP/7zip/UI/FileManager/FSDrives.cpp | 172 ++-- CPP/7zip/UI/FileManager/FSDrives.h | 18 +- CPP/7zip/UI/FileManager/FSFolder.cpp | 901 ++++++++++++++------ CPP/7zip/UI/FileManager/FSFolder.h | 138 +++- CPP/7zip/UI/FileManager/FSFolderCopy.cpp | 253 +++--- CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp | 22 +- CPP/7zip/UI/FileManager/FileFolderPluginOpen.h | 0 CPP/7zip/UI/FileManager/FilePlugins.cpp | 8 +- CPP/7zip/UI/FileManager/FilePlugins.h | 0 CPP/7zip/UI/FileManager/FoldersPage.cpp | 40 +- CPP/7zip/UI/FileManager/FoldersPage.h | 2 +- CPP/7zip/UI/FileManager/FoldersPage.rc | 0 CPP/7zip/UI/FileManager/FoldersPage2.rc | 16 +- CPP/7zip/UI/FileManager/FoldersPageRes.h | 21 +- CPP/7zip/UI/FileManager/FormatUtils.cpp | 20 +- CPP/7zip/UI/FileManager/FormatUtils.h | 14 +- CPP/7zip/UI/FileManager/HelpUtils.cpp | 6 +- CPP/7zip/UI/FileManager/HelpUtils.h | 6 +- CPP/7zip/UI/FileManager/IFolder.h | 59 +- CPP/7zip/UI/FileManager/Info.bmp | Bin CPP/7zip/UI/FileManager/Info2.bmp | Bin CPP/7zip/UI/FileManager/LangPage.cpp | 85 +- CPP/7zip/UI/FileManager/LangPage.h | 5 +- CPP/7zip/UI/FileManager/LangPage.rc | 10 +- CPP/7zip/UI/FileManager/LangPageRes.h | 12 +- CPP/7zip/UI/FileManager/LangUtils.cpp | 280 ++++--- CPP/7zip/UI/FileManager/LangUtils.h | 31 +- CPP/7zip/UI/FileManager/LinkDialog.cpp | 342 ++++++++ CPP/7zip/UI/FileManager/LinkDialog.h | 33 + CPP/7zip/UI/FileManager/LinkDialog.rc | 36 + CPP/7zip/UI/FileManager/LinkDialogRes.h | 21 + CPP/7zip/UI/FileManager/ListViewDialog.cpp | 16 +- CPP/7zip/UI/FileManager/ListViewDialog.h | 6 +- CPP/7zip/UI/FileManager/ListViewDialog.rc | 4 +- CPP/7zip/UI/FileManager/ListViewDialogRes.h | 4 +- CPP/7zip/UI/FileManager/MenuPage.cpp | 84 +- CPP/7zip/UI/FileManager/MenuPage.h | 4 +- CPP/7zip/UI/FileManager/MenuPage.rc | 2 +- CPP/7zip/UI/FileManager/MenuPage2.rc | 15 +- CPP/7zip/UI/FileManager/MenuPageRes.h | 14 +- CPP/7zip/UI/FileManager/MessagesDialog.cpp | 46 +- CPP/7zip/UI/FileManager/MessagesDialog.h | 8 +- CPP/7zip/UI/FileManager/MessagesDialog.rc | 4 +- CPP/7zip/UI/FileManager/MessagesDialogRes.h | 6 +- CPP/7zip/UI/FileManager/Move.bmp | Bin CPP/7zip/UI/FileManager/Move2.bmp | Bin CPP/7zip/UI/FileManager/MyCom2.h | 2 +- CPP/7zip/UI/FileManager/MyLoadMenu.cpp | 352 +++----- CPP/7zip/UI/FileManager/MyLoadMenu.h | 0 CPP/7zip/UI/FileManager/MyWindowsNew.h | 0 CPP/7zip/UI/FileManager/NetFolder.cpp | 21 +- CPP/7zip/UI/FileManager/NetFolder.h | 4 +- CPP/7zip/UI/FileManager/OpenCallback.cpp | 57 +- CPP/7zip/UI/FileManager/OpenCallback.h | 13 +- CPP/7zip/UI/FileManager/OptionsDialog.cpp | 19 +- CPP/7zip/UI/FileManager/OverwriteDialog.cpp | 112 ++- CPP/7zip/UI/FileManager/OverwriteDialog.h | 6 +- CPP/7zip/UI/FileManager/OverwriteDialog.rc | 57 +- CPP/7zip/UI/FileManager/OverwriteDialogRes.h | 29 +- CPP/7zip/UI/FileManager/Panel.cpp | 240 ++++-- CPP/7zip/UI/FileManager/Panel.h | 212 +++-- CPP/7zip/UI/FileManager/PanelCopy.cpp | 199 ++++- CPP/7zip/UI/FileManager/PanelCrc.cpp | 427 +++++----- CPP/7zip/UI/FileManager/PanelDrag.cpp | 95 ++- CPP/7zip/UI/FileManager/PanelFolderChange.cpp | 107 +-- CPP/7zip/UI/FileManager/PanelItemOpen.cpp | 431 ++++++++-- CPP/7zip/UI/FileManager/PanelItems.cpp | 444 ++++++++-- CPP/7zip/UI/FileManager/PanelKey.cpp | 30 +- CPP/7zip/UI/FileManager/PanelListNotify.cpp | 407 +++++++-- CPP/7zip/UI/FileManager/PanelMenu.cpp | 174 +++- CPP/7zip/UI/FileManager/PanelOperations.cpp | 265 +++--- CPP/7zip/UI/FileManager/PanelSelect.cpp | 57 +- CPP/7zip/UI/FileManager/PanelSort.cpp | 147 +++- CPP/7zip/UI/FileManager/PanelSplitFile.cpp | 183 ++--- CPP/7zip/UI/FileManager/PasswordDialog.cpp | 26 +- CPP/7zip/UI/FileManager/PasswordDialog.h | 11 +- CPP/7zip/UI/FileManager/PasswordDialog.rc | 8 +- CPP/7zip/UI/FileManager/PasswordDialogRes.h | 9 +- CPP/7zip/UI/FileManager/PluginInterface.h | 2 +- CPP/7zip/UI/FileManager/PluginLoader.h | 8 +- CPP/7zip/UI/FileManager/PluginsPage.cpp | 22 +- CPP/7zip/UI/FileManager/PluginsPage.h | 0 CPP/7zip/UI/FileManager/PluginsPage.rc | 0 CPP/7zip/UI/FileManager/PluginsPageRes.h | 8 +- CPP/7zip/UI/FileManager/ProgramLocation.cpp | 0 CPP/7zip/UI/FileManager/ProgramLocation.h | 0 CPP/7zip/UI/FileManager/ProgressDialog.cpp | 16 +- CPP/7zip/UI/FileManager/ProgressDialog.h | 12 +- CPP/7zip/UI/FileManager/ProgressDialog.rc | 2 +- CPP/7zip/UI/FileManager/ProgressDialog2.cpp | 995 ++++++++++++++--------- CPP/7zip/UI/FileManager/ProgressDialog2.h | 307 +++---- CPP/7zip/UI/FileManager/ProgressDialog2.rc | 7 +- CPP/7zip/UI/FileManager/ProgressDialog2Res.h | 81 +- CPP/7zip/UI/FileManager/ProgressDialog2a.rc | 80 +- CPP/7zip/UI/FileManager/ProgressDialogRes.h | 4 +- CPP/7zip/UI/FileManager/PropertyName.cpp | 107 +-- CPP/7zip/UI/FileManager/PropertyName.h | 6 +- CPP/7zip/UI/FileManager/PropertyName.rc | 135 +-- CPP/7zip/UI/FileManager/PropertyNameRes.h | 143 ++-- CPP/7zip/UI/FileManager/RegistryAssociations.cpp | 20 +- CPP/7zip/UI/FileManager/RegistryAssociations.h | 2 +- CPP/7zip/UI/FileManager/RegistryPlugins.cpp | 8 +- CPP/7zip/UI/FileManager/RegistryPlugins.h | 2 +- CPP/7zip/UI/FileManager/RegistryUtils.cpp | 19 +- CPP/7zip/UI/FileManager/RegistryUtils.h | 17 +- CPP/7zip/UI/FileManager/RootFolder.cpp | 40 +- CPP/7zip/UI/FileManager/RootFolder.h | 2 +- CPP/7zip/UI/FileManager/SettingsPage.cpp | 86 +- CPP/7zip/UI/FileManager/SettingsPage.h | 8 +- CPP/7zip/UI/FileManager/SettingsPage.rc | 0 CPP/7zip/UI/FileManager/SettingsPage2.rc | 31 +- CPP/7zip/UI/FileManager/SettingsPageRes.h | 22 +- CPP/7zip/UI/FileManager/SplitDialog.cpp | 32 +- CPP/7zip/UI/FileManager/SplitDialog.h | 6 +- CPP/7zip/UI/FileManager/SplitDialog.rc | 12 +- CPP/7zip/UI/FileManager/SplitDialogRes.h | 13 +- CPP/7zip/UI/FileManager/SplitUtils.cpp | 87 +- CPP/7zip/UI/FileManager/SplitUtils.h | 14 +- CPP/7zip/UI/FileManager/StdAfx.cpp | 0 CPP/7zip/UI/FileManager/StdAfx.h | 18 +- CPP/7zip/UI/FileManager/StringUtils.cpp | 35 +- CPP/7zip/UI/FileManager/StringUtils.h | 6 +- CPP/7zip/UI/FileManager/SysIconUtils.cpp | 156 +++- CPP/7zip/UI/FileManager/SysIconUtils.h | 30 +- CPP/7zip/UI/FileManager/SystemPage.cpp | 41 +- CPP/7zip/UI/FileManager/SystemPage.h | 14 +- CPP/7zip/UI/FileManager/SystemPage.rc | 34 +- CPP/7zip/UI/FileManager/SystemPageRes.h | 18 +- CPP/7zip/UI/FileManager/Test.bmp | Bin CPP/7zip/UI/FileManager/Test2.bmp | Bin CPP/7zip/UI/FileManager/TextPairs.cpp | 29 +- CPP/7zip/UI/FileManager/TextPairs.h | 13 +- CPP/7zip/UI/FileManager/UpdateCallback100.cpp | 25 +- CPP/7zip/UI/FileManager/UpdateCallback100.h | 2 +- CPP/7zip/UI/FileManager/ViewSettings.cpp | 360 ++++---- CPP/7zip/UI/FileManager/ViewSettings.h | 67 +- CPP/7zip/UI/FileManager/makefile | 162 +--- CPP/7zip/UI/FileManager/resource.h | 331 ++++---- CPP/7zip/UI/FileManager/resource.rc | 195 ++--- CPP/7zip/UI/FileManager/resourceGui.h | 17 +- CPP/7zip/UI/FileManager/resourceGui.rc | 18 +- 186 files changed, 8943 insertions(+), 5193 deletions(-) mode change 100755 => 100644 CPP/7zip/UI/FileManager/7zFM.exe.manifest mode change 100755 => 100644 CPP/7zip/UI/FileManager/7zipLogo.ico mode change 100755 => 100644 CPP/7zip/UI/FileManager/AboutDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/AboutDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/AboutDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/AboutDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/Add.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/Add2.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/App.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/App.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/AppState.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/BrowseDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/BrowseDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/BrowseDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/BrowseDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ClassDefs.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ComboDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ComboDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ComboDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/ComboDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/Copy.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/Copy2.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/CopyDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/CopyDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/CopyDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/CopyDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/Delete.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/Delete2.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/DialogSize.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/EditPage.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/EditPage.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/EditPage.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/EditPage2.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/EditPageRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/EnumFormatEtc.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/EnumFormatEtc.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/Extract.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/Extract2.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ExtractCallback.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ExtractCallback.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/FM.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FM.dsp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FM.dsw mode change 100755 => 100644 CPP/7zip/UI/FileManager/FM.ico create mode 100644 CPP/7zip/UI/FileManager/FM.mak mode change 100755 => 100644 CPP/7zip/UI/FileManager/FSDrives.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FSDrives.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/FSFolder.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FSFolder.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/FSFolderCopy.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FileFolderPluginOpen.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/FilePlugins.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FilePlugins.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/FoldersPage.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FoldersPage.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/FoldersPage.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/FoldersPage2.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/FoldersPageRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/FormatUtils.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/FormatUtils.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/HelpUtils.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/HelpUtils.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/IFolder.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/Info.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/Info2.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/LangPage.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/LangPage.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/LangPage.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/LangPageRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/LangUtils.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/LangUtils.h create mode 100644 CPP/7zip/UI/FileManager/LinkDialog.cpp create mode 100644 CPP/7zip/UI/FileManager/LinkDialog.h create mode 100644 CPP/7zip/UI/FileManager/LinkDialog.rc create mode 100644 CPP/7zip/UI/FileManager/LinkDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ListViewDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ListViewDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ListViewDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/ListViewDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/MenuPage.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/MenuPage.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/MenuPage.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/MenuPage2.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/MenuPageRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/MessagesDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/MessagesDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/MessagesDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/MessagesDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/Move.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/Move2.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/MyCom2.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/MyLoadMenu.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/MyLoadMenu.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/MyWindowsNew.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/NetFolder.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/NetFolder.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/OpenCallback.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/OpenCallback.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/OptionsDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/OverwriteDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/OverwriteDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/OverwriteDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/OverwriteDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/Panel.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/Panel.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelCopy.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelCrc.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelDrag.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelFolderChange.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelItemOpen.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelItems.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelKey.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelListNotify.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelMenu.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelOperations.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelSelect.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelSort.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PanelSplitFile.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PasswordDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PasswordDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/PasswordDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/PasswordDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/PluginInterface.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/PluginLoader.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/PluginsPage.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PluginsPage.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/PluginsPage.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/PluginsPageRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgramLocation.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgramLocation.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialog2.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialog2.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialog2.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialog2Res.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialog2a.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/ProgressDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/PropertyName.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/PropertyName.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/PropertyName.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/PropertyNameRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/RegistryAssociations.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/RegistryAssociations.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/RegistryPlugins.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/RegistryPlugins.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/RegistryUtils.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/RegistryUtils.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/RootFolder.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/RootFolder.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/SettingsPage.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/SettingsPage.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/SettingsPage.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/SettingsPage2.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/SettingsPageRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/SplitDialog.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/SplitDialog.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/SplitDialog.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/SplitDialogRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/SplitUtils.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/SplitUtils.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/StdAfx.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/StdAfx.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/StringUtils.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/StringUtils.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/SysIconUtils.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/SysIconUtils.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/SystemPage.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/SystemPage.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/SystemPage.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/SystemPageRes.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/Test.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/Test2.bmp mode change 100755 => 100644 CPP/7zip/UI/FileManager/TextPairs.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/TextPairs.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/UpdateCallback100.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/UpdateCallback100.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/ViewSettings.cpp mode change 100755 => 100644 CPP/7zip/UI/FileManager/ViewSettings.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/makefile mode change 100755 => 100644 CPP/7zip/UI/FileManager/resource.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/resource.rc mode change 100755 => 100644 CPP/7zip/UI/FileManager/resourceGui.h mode change 100755 => 100644 CPP/7zip/UI/FileManager/resourceGui.rc (limited to 'CPP/7zip/UI/FileManager') diff --git a/CPP/7zip/UI/FileManager/7zFM.exe.manifest b/CPP/7zip/UI/FileManager/7zFM.exe.manifest old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/7zipLogo.ico b/CPP/7zip/UI/FileManager/7zipLogo.ico old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/AboutDialog.cpp b/CPP/7zip/UI/FileManager/AboutDialog.cpp old mode 100755 new mode 100644 index edfa98ba..10d76671 --- a/CPP/7zip/UI/FileManager/AboutDialog.cpp +++ b/CPP/7zip/UI/FileManager/AboutDialog.cpp @@ -2,31 +2,41 @@ #include "StdAfx.h" +#include "../../../../C/CpuArch.h" + +#include "../../MyVersion.h" + #include "AboutDialog.h" +#include "PropertyNameRes.h" + #include "HelpUtils.h" #include "LangUtils.h" -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_ABOUT_STATIC_REGISTER_INFO, 0x01000103 }, - { IDC_ABOUT_BUTTON_SUPPORT, 0x01000104 }, - { IDC_ABOUT_BUTTON_REGISTER, 0x01000105 }, - { IDOK, 0x02000702 } + IDT_ABOUT_INFO }; -#define MY_HOME_PAGE TEXT("http://www.7-zip.org/") - -static LPCTSTR kHomePageURL = MY_HOME_PAGE; -/* -static LPCTSTR kRegisterPageURL = MY_HOME_PAGE TEXT("register.html"); -static LPCTSTR kSupportPageURL = MY_HOME_PAGE TEXT("support.html"); -*/ +static LPCTSTR kHomePageURL = TEXT("http://www.7-zip.org/"); static LPCWSTR kHelpTopic = L"start.htm"; +#define LLL_(quote) L##quote +#define LLL(quote) LLL_(quote) + bool CAboutDialog::OnInit() { - LangSetWindowText(HWND(*this), 0x01000100); - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); + UString s = L"7-Zip " LLL(MY_VERSION); + #ifdef MY_CPU_64BIT + s += L" ["; + s += LangString(IDS_PROP_BIT64); + s += L']'; + #endif + + SetItemText(IDT_ABOUT_VERSION, s); + SetItemText(IDT_ABOUT_DATE, LLL(MY_DATE)); + + LangSetWindowText(*this, IDD_ABOUT); NormalizePosition(); return CModalDialog::OnInit(); } @@ -39,13 +49,9 @@ void CAboutDialog::OnHelp() bool CAboutDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { LPCTSTR url; - switch(buttonID) + switch (buttonID) { - case IDC_ABOUT_BUTTON_HOMEPAGE: url = kHomePageURL; break; - /* - case IDC_ABOUT_BUTTON_REGISTER: url = kRegisterPageURL; break; - case IDC_ABOUT_BUTTON_SUPPORT: url = kSupportPageURL; break; - */ + case IDB_ABOUT_HOMEPAGE: url = kHomePageURL; break; default: return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } diff --git a/CPP/7zip/UI/FileManager/AboutDialog.h b/CPP/7zip/UI/FileManager/AboutDialog.h old mode 100755 new mode 100644 index c8a4ea9b..39fd3ba7 --- a/CPP/7zip/UI/FileManager/AboutDialog.h +++ b/CPP/7zip/UI/FileManager/AboutDialog.h @@ -1,10 +1,11 @@ // AboutDialog.h -#ifndef __ABOUTDIALOG_H -#define __ABOUTDIALOG_H +#ifndef __ABOUT_DIALOG_H +#define __ABOUT_DIALOG_H + +#include "../../../Windows/Control/Dialog.h" #include "AboutDialogRes.h" -#include "Windows/Control/Dialog.h" class CAboutDialog: public NWindows::NControl::CModalDialog { diff --git a/CPP/7zip/UI/FileManager/AboutDialog.rc b/CPP/7zip/UI/FileManager/AboutDialog.rc old mode 100755 new mode 100644 index fcf2ae6e..6953c141 --- a/CPP/7zip/UI/FileManager/AboutDialog.rc +++ b/CPP/7zip/UI/FileManager/AboutDialog.rc @@ -5,7 +5,7 @@ #define xc 144 #define yc 144 -#define y 80 +#define y 93 IDI_LOGO ICON "../../UI/FileManager/7zipLogo.ico" @@ -13,14 +13,14 @@ IDI_LOGO ICON "../../UI/FileManager/7zipLogo.ico" #define SS_REALSIZEIMAGE 0x800 #endif -IDD_ABOUT MY_DIALOG +IDD_ABOUT DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT CAPTION "About 7-Zip" { DEFPUSHBUTTON "OK", IDOK, bx1, by, bxs, bys - PUSHBUTTON "www.7-zip.org", IDC_ABOUT_BUTTON_HOMEPAGE, bx2, by, bxs, bys - ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE - LTEXT MY_7ZIP_VERSION, -1, m, 54, xc, 8 - LTEXT MY_COPYRIGHT, -1, m, 67, xc, 8 - LTEXT "7-Zip is free software", - IDC_ABOUT_STATIC_REGISTER_INFO, m, y, xc, (by - y - 1) + PUSHBUTTON "www.7-zip.org", IDB_ABOUT_HOMEPAGE, bx2, by, bxs, bys + ICON IDI_LOGO, -1, m, m, 32, 32, SS_REALSIZEIMAGE, + LTEXT "", IDT_ABOUT_VERSION, m, 54, xc, 8 + LTEXT "", IDT_ABOUT_DATE, m, 67, xc, 8 + LTEXT MY_COPYRIGHT, -1, m, 80, xc, 8 + LTEXT "7-Zip is free software", IDT_ABOUT_INFO, m, y, xc, (by - y - 1) } diff --git a/CPP/7zip/UI/FileManager/AboutDialogRes.h b/CPP/7zip/UI/FileManager/AboutDialogRes.h old mode 100755 new mode 100644 index f7dd0602..b4165580 --- a/CPP/7zip/UI/FileManager/AboutDialogRes.h +++ b/CPP/7zip/UI/FileManager/AboutDialogRes.h @@ -1,6 +1,8 @@ -#define IDD_ABOUT 507 -#define IDI_LOGO 138 -#define IDC_ABOUT_STATIC_REGISTER_INFO 1010 -#define IDC_ABOUT_BUTTON_HOMEPAGE 1020 -#define IDC_ABOUT_BUTTON_SUPPORT 1021 -#define IDC_ABOUT_BUTTON_REGISTER 1022 +#define IDD_ABOUT 2900 + +#define IDT_ABOUT_INFO 2901 + +#define IDI_LOGO 100 +#define IDT_ABOUT_VERSION 101 +#define IDT_ABOUT_DATE 102 +#define IDB_ABOUT_HOMEPAGE 110 diff --git a/CPP/7zip/UI/FileManager/Add.bmp b/CPP/7zip/UI/FileManager/Add.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/Add2.bmp b/CPP/7zip/UI/FileManager/Add2.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp old mode 100755 new mode 100644 index 5f31f607..51c8d2db --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -5,17 +5,17 @@ #include "resource.h" #include "OverwriteDialogRes.h" -#include "Common/IntToString.h" -#include "Common/StringConvert.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/PropVariantConv.h" +/* #include "Windows/COM.h" #include "Windows/Error.h" #include "Windows/FileDir.h" -#include "Windows/FileName.h" #include "Windows/PropVariant.h" -#include "Windows/PropVariantConversions.h" #include "Windows/Thread.h" +*/ #include "App.h" #include "CopyDialog.h" @@ -26,9 +26,13 @@ #include "RegistryUtils.h" #include "ViewSettings.h" +#include "PropertyNameRes.h" + using namespace NWindows; using namespace NFile; +using namespace NDir; using namespace NFind; +using namespace NName; extern DWORD g_ComCtl32Version; extern HINSTANCE g_hInstance; @@ -61,6 +65,11 @@ void CPanelCallbackImp::DragBegin() { _app->DragBegin(_index); } void CPanelCallbackImp::DragEnd() { _app->DragEnd(); } void CPanelCallbackImp::RefreshTitle(bool always) { _app->RefreshTitle(_index, always); } +void CApp::ReloadLang() +{ + LangString(IDS_N_SELECTED_ITEMS, LangString_N_SELECTED_ITEMS); +} + void CApp::SetListSettings() { bool showDots = ReadShowDots(); @@ -102,7 +111,7 @@ void CApp::SetListSettings() void CApp::SetShowSystemMenu() { - ShowSystemMenu = ReadShowSystemMenu(); + ShowSystemMenu = Read_ShowSystemMenu(); } #ifndef ILC_COLOR32 @@ -166,23 +175,23 @@ struct CButtonInfo UINT BitmapResID; UINT Bitmap2ResID; UINT StringResID; - UInt32 LangID; - UString GetText() const { return LangString(StringResID, LangID); } + + UString GetText() const { return LangString(StringResID); } }; static CButtonInfo g_StandardButtons[] = { - { IDM_COPY_TO, IDB_COPY, IDB_COPY2, IDS_BUTTON_COPY, 0x03020420}, - { IDM_MOVE_TO, IDB_MOVE, IDB_MOVE2, IDS_BUTTON_MOVE, 0x03020421}, - { IDM_DELETE, IDB_DELETE, IDB_DELETE2, IDS_BUTTON_DELETE, 0x03020422} , - { IDM_FILE_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO, 0x03020423} + { IDM_COPY_TO, IDB_COPY, IDB_COPY2, IDS_BUTTON_COPY }, + { IDM_MOVE_TO, IDB_MOVE, IDB_MOVE2, IDS_BUTTON_MOVE }, + { IDM_DELETE, IDB_DELETE, IDB_DELETE2, IDS_BUTTON_DELETE } , + { IDM_PROPERTIES, IDB_INFO, IDB_INFO2, IDS_BUTTON_INFO } }; static CButtonInfo g_ArchiveButtons[] = { - { kAddCommand, IDB_ADD, IDB_ADD2, IDS_ADD, 0x03020400}, - { kExtractCommand, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT, 0x03020401}, - { kTestCommand , IDB_TEST, IDB_TEST2, IDS_TEST, 0x03020402} + { kMenuCmdID_Toolbar_Add, IDB_ADD, IDB_ADD2, IDS_ADD }, + { kMenuCmdID_Toolbar_Extract, IDB_EXTRACT, IDB_EXTRACT2, IDS_EXTRACT }, + { kMenuCmdID_Toolbar_Test, IDB_TEST, IDB_TEST2, IDS_TEST } }; static bool SetButtonText(int commandID, CButtonInfo *buttons, int numButtons, UString &s) @@ -201,11 +210,9 @@ static bool SetButtonText(int commandID, CButtonInfo *buttons, int numButtons, U static void SetButtonText(int commandID, UString &s) { - if (SetButtonText(commandID, g_StandardButtons, - sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]), s)) + if (SetButtonText(commandID, g_StandardButtons, ARRAY_SIZE(g_StandardButtons), s)) return; - SetButtonText(commandID, g_ArchiveButtons, - sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]), s); + SetButtonText(commandID, g_ArchiveButtons, ARRAY_SIZE(g_ArchiveButtons), s); } static void AddButton( @@ -253,10 +260,10 @@ void CApp::ReloadToolbars() CreateToolbar(_window, _buttonsImageList, _toolBar, LargeButtons); int i; if (ShowArchiveToolbar) - for (i = 0; i < sizeof(g_ArchiveButtons) / sizeof(g_ArchiveButtons[0]); i++) + for (i = 0; i < ARRAY_SIZE(g_ArchiveButtons); i++) AddButton(_buttonsImageList, _toolBar, g_ArchiveButtons[i], ShowButtonsLables, LargeButtons); if (ShowStandardToolbar) - for (i = 0; i < sizeof(g_StandardButtons) / sizeof(g_StandardButtons[0]); i++) + for (i = 0; i < ARRAY_SIZE(g_StandardButtons); i++) AddButton(_buttonsImageList, _toolBar, g_StandardButtons[i], ShowButtonsLables, LargeButtons); _toolBar.AutoSize(); @@ -295,9 +302,10 @@ HRESULT CApp::Create(HWND hwnd, const UString &mainPath, const UString &arcForma SetShowSystemMenu(); if (LastFocusedPanel >= kNumPanelsMax) LastFocusedPanel = 0; + // ShowDeletedFiles = Read_ShowDeleted(); CListMode listMode; - ReadListMode(listMode); + listMode.Read(); for (i = 0; i < kNumPanelsMax; i++) { CPanel &panel = Panels[i]; @@ -361,7 +369,8 @@ void CApp::Save() listMode.Panels[i] = panel.GetListViewMode(); SaveFlatView(i, panel._flatModeForArc); } - SaveListMode(listMode); + listMode.Save(); + // Save_ShowDeleted(ShowDeletedFiles); } void CApp::Release() @@ -383,20 +392,20 @@ static void ReducePathToRealFileSystemPath(UString &path) } int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos < 0) + { path.Empty(); - else + break; + } + path.DeleteFrom(pos + 1); + if (path.Len() == 3 && path[1] == L':') + break; + if (path.Len() > 2 && path[0] == '\\' && path[1] == '\\') { - path = path.Left(pos + 1); - if (path.Length() == 3 && path[1] == L':') + int nextPos = path.Find(WCHAR_PATH_SEPARATOR, 2); // pos after \\COMPNAME + if (nextPos > 0 && path.Find(WCHAR_PATH_SEPARATOR, nextPos + 1) == pos) break; - if (path.Length() > 2 && path[0] == '\\' && path[1] == '\\') - { - int nextPos = path.Find(WCHAR_PATH_SEPARATOR, 2); // pos after \\COMPNAME - if (nextPos > 0 && path.Find(WCHAR_PATH_SEPARATOR, nextPos + 1) == pos) - break; - } - path = path.Left(pos); } + path.DeleteFrom(pos); } } @@ -408,38 +417,27 @@ static bool CheckFolderPath(const UString &path) return (pathReduced == path); } -static bool IsPathAbsolute(const UString &path) -{ - if (path.Length() >= 1 && path[0] == WCHAR_PATH_SEPARATOR) - return true; - #ifdef _WIN32 - if (path.Length() >= 3 && path[1] == L':' && path[2] == L'\\') - return true; - #endif - return false; -} - extern UString ConvertSizeToString(UInt64 value); static UString AddSizeValue(UInt64 size) { - return MyFormatNew(IDS_FILE_SIZE, 0x02000982, ConvertSizeToString(size)); + return MyFormatNew(IDS_FILE_SIZE, ConvertSizeToString(size)); } -static void AddValuePair1(UINT resourceID, UInt32 langID, UInt64 size, UString &s) +static void AddValuePair1(UString &s, UINT resourceID, UInt64 size) { - s += LangString(resourceID, langID); - s += L" "; + s += LangString(resourceID); + s += L": "; s += AddSizeValue(size); - s += L"\n"; + s += L'\n'; } -void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s) +void AddValuePair2(UString &s, UINT resourceID, UInt64 num, UInt64 size) { if (num == 0) return; - s += LangString(resourceID, langID); - s += L" "; + s += LangString(resourceID); + s += L": "; s += ConvertSizeToString(num); if (size != (UInt64)(Int64)-1) @@ -448,7 +446,7 @@ void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UStr s += AddSizeValue(size); s += L" )"; } - s += L"\n"; + s += L'\n'; } static void AddPropValueToSum(IFolderFolder *folder, int index, PROPID propID, UInt64 &sum) @@ -457,15 +455,11 @@ static void AddPropValueToSum(IFolderFolder *folder, int index, PROPID propID, U return; NCOM::CPropVariant prop; folder->GetProperty(index, propID, &prop); - switch(prop.vt) - { - case VT_UI4: - case VT_UI8: - sum += ConvertPropVariantToUInt64(prop); - break; - default: - sum = (UInt64)(Int64)-1; - } + UInt64 val = 0; + if (ConvertPropVariantToUInt64(prop, val)) + sum += val; + else + sum = (UInt64)(Int64)-1; } UString CPanel::GetItemsInfoString(const CRecordVector &indices) @@ -473,11 +467,11 @@ UString CPanel::GetItemsInfoString(const CRecordVector &indices) UString info; UInt64 numDirs, numFiles, filesSize, foldersSize; numDirs = numFiles = filesSize = foldersSize = 0; - int i; + unsigned i; for (i = 0; i < indices.Size(); i++) { int index = indices[i]; - if (IsItemFolder(index)) + if (IsItem_Folder(index)) { AddPropValueToSum(_folder, index, kpidSize, foldersSize); numDirs++; @@ -489,22 +483,22 @@ UString CPanel::GetItemsInfoString(const CRecordVector &indices) } } - AddValuePair2(IDS_FOLDERS_COLON, 0x02000321, numDirs, foldersSize, info); - AddValuePair2(IDS_FILES_COLON, 0x02000320, numFiles, filesSize, info); + AddValuePair2(info, IDS_PROP_FOLDERS, numDirs, foldersSize); + AddValuePair2(info, IDS_PROP_FILES, numFiles, filesSize); int numDefined = ((foldersSize != (UInt64)(Int64)-1) && foldersSize != 0) ? 1: 0; numDefined += ((filesSize != (UInt64)(Int64)-1) && filesSize != 0) ? 1: 0; if (numDefined == 2) - AddValuePair1(IDS_SIZE_COLON, 0x02000322, filesSize + foldersSize, info); + AddValuePair1(info, IDS_PROP_SIZE, filesSize + foldersSize); info += L"\n"; info += _currentFolderPrefix; - for (i = 0; i < indices.Size() && i < kCopyDialog_NumInfoLines - 6; i++) + for (i = 0; i < indices.Size() && (int)i < (int)kCopyDialog_NumInfoLines - 6; i++) { info += L"\n "; int index = indices[i]; info += GetItemRelPath(index); - if (IsItemFolder(index)) + if (IsItem_Folder(index)) info += WCHAR_PATH_SEPARATOR; } if (i != indices.Size()) @@ -512,7 +506,7 @@ UString CPanel::GetItemsInfoString(const CRecordVector &indices) return info; } -bool IsCorrectFsName(const UString name); +bool IsCorrectFsName(const UString &name); void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) { @@ -525,7 +519,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) if (!srcPanel.DoesItSupportOperations()) { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } @@ -554,49 +548,49 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) if (NumPanels == 1) ReducePathToRealFileSystemPath(destPath); } - + } + UStringVector copyFolders; + ReadCopyHistory(copyFolders); + { CCopyDialog copyDialog; - UStringVector copyFolders; - ReadCopyHistory(copyFolders); copyDialog.Strings = copyFolders; copyDialog.Value = destPath; - - copyDialog.Title = move ? - LangString(IDS_MOVE, 0x03020202): - LangString(IDS_COPY, 0x03020201); - copyDialog.Static = move ? - LangString(IDS_MOVE_TO, 0x03020204): - LangString(IDS_COPY_TO, 0x03020203); - + LangString(move ? IDS_MOVE : IDS_COPY, copyDialog.Title); + LangString(move ? IDS_MOVE_TO : IDS_COPY_TO, copyDialog.Static); copyDialog.Info = srcPanel.GetItemsInfoString(indices); - if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL) + if (copyDialog.Create(srcPanel.GetParent()) != IDOK) return; destPath = copyDialog.Value; + } + { if (destPath.IsEmpty()) { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } - if (!IsPathAbsolute(destPath)) + UString correctName; + if (!srcPanel.CorrectFsPath(destPath, correctName)) { - if (!srcPanel.IsFSFolder()) - { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); - return; - } - destPath = srcPanel._currentFolderPrefix + destPath; + srcPanel.MessageBoxError(E_INVALIDARG); + return; } + if (IsAbsolutePath(destPath)) + destPath.Empty(); + else + destPath = srcPanel._currentFolderPrefix; + destPath += correctName; + #ifndef UNDER_CE - if (destPath.Length() > 0 && destPath[0] == '\\') - if (destPath.Length() == 1 || destPath[1] != '\\') + if (destPath.Len() > 0 && destPath[0] == '\\') + if (destPath.Len() == 1 || destPath[1] != '\\') { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } #endif @@ -606,13 +600,13 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) NFind::DoesDirExist(us2fs(destPath)) || srcPanel.IsArcFolder()) { - NDirectory::CreateComplexDirectory(us2fs(destPath)); + CreateComplexDir(us2fs(destPath)); NName::NormalizeDirPathPrefix(destPath); if (!CheckFolderPath(destPath)) { if (NumPanels < 2 || destPath != destPanel._currentFolderPrefix || !destPanel.DoesItSupportOperations()) { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } useDestPanel = true; @@ -629,10 +623,10 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) if (pos >= 0) { UString prefix = destPath.Left(pos + 1); - NDirectory::CreateComplexDirectory(us2fs(prefix)); + CreateComplexDir(us2fs(prefix)); if (!CheckFolderPath(prefix)) { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } } @@ -654,7 +648,7 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) bool useSrcPanel = (!useDestPanel || !srcPanel.IsFsOrDrivesFolder() || destPanel.IsFSFolder()); bool useTemp = useSrcPanel && useDestPanel; - NFile::NDirectory::CTempDir tempDirectory; + CTempDir tempDirectory; FString tempDirPrefix; if (useTemp) { @@ -668,24 +662,23 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) srcPanel.SaveSelectedState(srcSelState); destPanel.SaveSelectedState(destSelState); - HRESULT result; + CPanel::CDisableNotify disableNotify1(destPanel); + CPanel::CDisableNotify disableNotify2(srcPanel); + + HRESULT result = S_OK; if (useSrcPanel) { - UString folder = useTemp ? fs2us(tempDirPrefix) : destPath; - result = srcPanel.CopyTo(indices, folder, move, true, 0); - if (result != S_OK) - { - disableTimerProcessing1.Restore(); - disableTimerProcessing2.Restore(); - // For Password: - srcPanel.SetFocusToList(); - if (result != E_ABORT) - srcPanel.MessageBoxError(result, L"Error"); - return; - } + CCopyToOptions options; + options.folder = useTemp ? fs2us(tempDirPrefix) : destPath; + options.moveMode = move; + options.includeAltStreams = true; + options.replaceAltStreamChars = false; + options.showErrorMessages = true; + + result = srcPanel.CopyTo(options, indices, NULL); } - if (useDestPanel) + if (result == S_OK && useDestPanel) { UStringVector filePaths; UString folderPrefix; @@ -693,22 +686,22 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) folderPrefix = fs2us(tempDirPrefix); else folderPrefix = srcPanel._currentFolderPrefix; - filePaths.Reserve(indices.Size()); - for (int i = 0; i < indices.Size(); i++) - filePaths.Add(srcPanel.GetItemRelPath(indices[i])); - - result = destPanel.CopyFrom(folderPrefix, filePaths, true, 0); - - if (result != S_OK) - { - disableTimerProcessing1.Restore(); - disableTimerProcessing2.Restore(); - // For Password: - srcPanel.SetFocusToList(); - if (result != E_ABORT) - srcPanel.MessageBoxError(result, L"Error"); - return; - } + filePaths.ClearAndReserve(indices.Size()); + FOR_VECTOR (i, indices) + filePaths.AddInReserved(srcPanel.GetItemRelPath(indices[i])); + result = destPanel.CopyFrom(move, folderPrefix, filePaths, true, 0); + } + if (result != S_OK) + { + // disableNotify1.Restore(); + // disableNotify2.Restore(); + // For Password: + // srcPanel.SetFocusToList(); + // srcPanel.InvalidateList(NULL, true); + + if (result != E_ABORT) + srcPanel.MessageBoxError(result, L"Error"); + // return; } RefreshTitleAlways(); @@ -721,8 +714,8 @@ void CApp::OnCopy(bool move, bool copyToSame, int srcPanelIndex) destPanel.RefreshListCtrl(destSelState); srcPanel.KillSelection(); } - disableTimerProcessing1.Restore(); - disableTimerProcessing2.Restore(); + disableNotify1.Restore(); + disableNotify2.Restore(); srcPanel.SetFocusToList(); } @@ -746,7 +739,7 @@ void CApp::OnSetSubFolder(int srcPanelIndex) if (focusedItem < 0) return; int realIndex = srcPanel.GetRealItemIndex(focusedItem); - if (!srcPanel.IsItemFolder(realIndex)) + if (!srcPanel.IsItem_Folder(realIndex)) return; // destPanel.BindToFolder(srcPanel._currentFolderPrefix + srcPanel.GetItemName(realIndex) + WCHAR_PATH_SEPARATOR); @@ -763,7 +756,7 @@ void CApp::OnSetSubFolder(int srcPanelIndex) return; } destPanel.CloseOpenFolders(); - destPanel._folder = newFolder; + destPanel.SetNewFolder(newFolder); destPanel.RefreshListCtrl(); } @@ -821,7 +814,7 @@ void CApp::RefreshTitle(bool always) { UString path = GetFocusedPanel()._currentFolderPrefix; if (path.IsEmpty()) - path += LangString(IDS_APP_TITLE, 0x03000000); + path = L"7-Zip"; // LangString(IDS_APP_TITLE); if (!always && path == PrevTitle) return; PrevTitle = path; @@ -834,3 +827,28 @@ void CApp::RefreshTitle(int panelIndex, bool always) return; RefreshTitle(always); } + +void AddUniqueStringToHead(UStringVector &list, const UString &s) +{ + for (unsigned i = 0; i < list.Size();) + if (s.IsEqualToNoCase(list[i])) + list.Delete(i); + else + i++; + list.Insert(0, s); +} + + +void CFolderHistory::Normalize() +{ + const unsigned kMaxSize = 100; + if (Strings.Size() > kMaxSize) + Strings.DeleteFrom(kMaxSize); +} + +void CFolderHistory::AddString(const UString &s) +{ + NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); + AddUniqueStringToHead(Strings, s); + Normalize(); +} diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h old mode 100755 new mode 100644 index 2af63b47..c775cc2e --- a/CPP/7zip/UI/FileManager/App.h +++ b/CPP/7zip/UI/FileManager/App.h @@ -3,8 +3,8 @@ #ifndef __APP_H #define __APP_H -#include "Windows/Control/CommandBar.h" -#include "Windows/Control/ImageList.h" +#include "../../../Windows/Control/CommandBar.h" +#include "../../../Windows/Control/ImageList.h" #include "AppState.h" #include "Panel.h" @@ -18,11 +18,15 @@ const int kNumPanelsMax = 2; extern bool g_IsSmallScreen; +const int kMenuCmdID_Plugin_Start = 1000; // must be large them context menu IDs +const int kMenuCmdID_Toolbar_Start = 1500; + enum { - kAddCommand = kToolbarStartID, - kExtractCommand, - kTestCommand + kMenuCmdID_Toolbar_Add = kMenuCmdID_Toolbar_Start, + kMenuCmdID_Toolbar_Extract, + kMenuCmdID_Toolbar_Test, + kMenuCmdID_Toolbar_End }; class CPanelCallbackImp: public CPanelCallback @@ -106,6 +110,7 @@ class CApp public: NWindows::CWindow _window; bool ShowSystemMenu; + // bool ShowDeletedFiles; int NumPanels; int LastFocusedPanel; @@ -129,7 +134,15 @@ public: CDropTarget *_dropTargetSpec; CMyComPtr _dropTarget; - CApp(): _window(0), NumPanels(2), LastFocusedPanel(0) {} + UString LangString_N_SELECTED_ITEMS; + + void ReloadLang(); + + CApp(): _window(0), NumPanels(2), LastFocusedPanel(0), + AutoRefresh_Mode(true) + { + SetPanels_AutoRefresh_Mode(); + } void CreateDragTarget() { @@ -177,17 +190,21 @@ public: void OpenItem() { GetFocusedPanel().OpenSelectedItems(true); } void OpenItemInside() { GetFocusedPanel().OpenFocusedItemAsInternal(); } void OpenItemOutside() { GetFocusedPanel().OpenSelectedItems(false); } - void EditItem() { GetFocusedPanel().EditItem(); } + void EditItem(bool useEditor) { GetFocusedPanel().EditItem(useEditor); } void Rename() { GetFocusedPanel().RenameFile(); } void CopyTo() { OnCopy(false, false, GetFocusedPanelIndex()); } void MoveTo() { OnCopy(true, false, GetFocusedPanelIndex()); } void Delete(bool toRecycleBin) { GetFocusedPanel().DeleteItems(toRecycleBin); } - void CalculateCrc(); + void CalculateCrc(const UString &methodName); void DiffFiles(); void Split(); void Combine(); void Properties() { GetFocusedPanel().Properties(); } void Comment() { GetFocusedPanel().ChangeComment(); } + + #ifndef UNDER_CE + void Link(); + #endif void CreateFolder() { GetFocusedPanel().CreateFolder(); } void CreateFile() { GetFocusedPanel().CreateFile(); } @@ -241,8 +258,30 @@ public: void SetListSettings(); void SetShowSystemMenu(); HRESULT SwitchOnOffOnePanel(); + bool GetFlatMode() { return Panels[LastFocusedPanel].GetFlatMode(); } + // bool Get_ShowNtfsStrems_Mode() { return Panels[LastFocusedPanel].Get_ShowNtfsStrems_Mode(); } + void ChangeFlatMode() { Panels[LastFocusedPanel].ChangeFlatMode(); } + // void Change_ShowNtfsStrems_Mode() { Panels[LastFocusedPanel].Change_ShowNtfsStrems_Mode(); } + // void Change_ShowDeleted() { ShowDeletedFiles = !ShowDeletedFiles; } + + bool AutoRefresh_Mode; + bool Get_AutoRefresh_Mode() + { + // return Panels[LastFocusedPanel].Get_ShowNtfsStrems_Mode(); + return AutoRefresh_Mode; + } + void Change_AutoRefresh_Mode() + { + AutoRefresh_Mode = !AutoRefresh_Mode; + SetPanels_AutoRefresh_Mode(); + } + void SetPanels_AutoRefresh_Mode() + { + for (int i = 0; i < kNumPanelsMax; i++) + Panels[i].Set_AutoRefresh_Mode(AutoRefresh_Mode); + } void OpenBookmark(int index) { GetFocusedPanel().OpenBookmark(index); } void SetBookmark(int index) { GetFocusedPanel().SetBookmark(index); } diff --git a/CPP/7zip/UI/FileManager/AppState.h b/CPP/7zip/UI/FileManager/AppState.h old mode 100755 new mode 100644 index 374cf04f..cc887150 --- a/CPP/7zip/UI/FileManager/AppState.h +++ b/CPP/7zip/UI/FileManager/AppState.h @@ -3,34 +3,23 @@ #ifndef __APP_STATE_H #define __APP_STATE_H -#include "Windows/Synchronization.h" +#include "../../../Windows/Synchronization.h" #include "ViewSettings.h" -void inline AddUniqueStringToHead(UStringVector &list, - const UString &string) -{ - for(int i = 0; i < list.Size();) - if (string.CompareNoCase(list[i]) == 0) - list.Delete(i); - else - i++; - list.Insert(0, string); -} - class CFastFolders { NWindows::NSynchronization::CCriticalSection _criticalSection; public: UStringVector Strings; - void SetString(int index, const UString &string) + void SetString(unsigned index, const UString &s) { NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); - while(Strings.Size() <= index) - Strings.Add(UString()); - Strings[index] = string; + while (Strings.Size() <= index) + Strings.AddNew(); + Strings[index] = s; } - UString GetString(int index) + UString GetString(unsigned index) { NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); if (index >= Strings.Size()) @@ -53,12 +42,8 @@ class CFolderHistory { NWindows::NSynchronization::CCriticalSection _criticalSection; UStringVector Strings; - void Normalize() - { - const int kMaxSize = 100; - if (Strings.Size() > kMaxSize) - Strings.Delete(kMaxSize, Strings.Size() - kMaxSize); - } + + void Normalize(); public: @@ -68,13 +53,8 @@ public: foldersHistory = Strings; } - void AddString(const UString &string) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); - AddUniqueStringToHead(Strings, string); - Normalize(); - } - + void AddString(const UString &s); + void RemoveAll() { NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); @@ -99,6 +79,7 @@ struct CAppState { CFastFolders FastFolders; CFolderHistory FolderHistory; + void Save() { FastFolders.Save(); diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.cpp b/CPP/7zip/UI/FileManager/BrowseDialog.cpp old mode 100755 new mode 100644 index 1c350064..32db8f8f --- a/CPP/7zip/UI/FileManager/BrowseDialog.cpp +++ b/CPP/7zip/UI/FileManager/BrowseDialog.cpp @@ -2,63 +2,191 @@ #include "StdAfx.h" +#ifndef UNDER_CE +#include "../../../Windows/CommonDialog.h" +#include "../../../Windows/Shell.h" +#endif + +#include "../../../Windows/FileName.h" +#include "../../../Windows/FileFind.h" + +#ifdef UNDER_CE +#include +#endif + #include "BrowseDialog.h" +#define USE_MY_BROWSE_DIALOG + #ifdef USE_MY_BROWSE_DIALOG -#include "Common/IntToString.h" +#include "../../../Common/Defs.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/Wildcard.h" -#include "Windows/PropVariantConversions.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/PropVariantConv.h" -#include "LangUtils.h" +#include "../../../Windows/Control/ComboBox.h" +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/Edit.h" +#include "../../../Windows/Control/ListView.h" + +#include "BrowseDialogRes.h" #include "PropertyNameRes.h" +#include "SysIconUtils.h" #ifndef _SFX #include "RegistryUtils.h" #endif +#endif + +#include "ComboDialog.h" +#include "LangUtils.h" + +#include "resource.h" + using namespace NWindows; using namespace NFile; +using namespace NName; using namespace NFind; +#ifdef USE_MY_BROWSE_DIALOG + extern bool g_LVN_ITEMACTIVATE_Support; static const int kParentIndex = -1; +static const UINT k_Message_RefreshPathEdit = WM_APP + 1; + +static HRESULT GetNormalizedError() +{ + DWORD errorCode = GetLastError(); + return errorCode == 0 ? E_FAIL : errorCode; +} + +extern UString HResultToMessage(HRESULT errorCode); + +static void MessageBox_Error_Global(HWND wnd, const wchar_t *message) +{ + ::MessageBoxW(wnd, message, L"7-Zip", MB_ICONERROR); +} -#ifdef LANG -static CIDLangPair kIDLangPairs[] = +static void MessageBox_HResError(HWND wnd, HRESULT errorCode, const wchar_t *name) { - { IDOK, 0x02000702 }, - { IDCANCEL, 0x02000710 } + UString s = HResultToMessage(errorCode); + if (name) + { + s += L'\n'; + s += name; + } + MessageBox_Error_Global(wnd, s); +} + +class CBrowseDialog: public NControl::CModalDialog +{ + NControl::CListView _list; + NControl::CEdit _pathEdit; + NControl::CComboBox _filterCombo; + + CObjectVector _files; + + CExtToIconMap _extToIconMap; + int _sortIndex; + bool _ascending; + bool _showDots; + UString _topDirPrefix; // we don't open parent of that folder + UString DirPrefix; + + virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); + virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); + virtual bool OnNotify(UINT controlID, LPNMHDR header); + virtual bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo); + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); + virtual void OnOK(); + + void Post_RefreshPathEdit() { PostMessage(k_Message_RefreshPathEdit); } + + bool GetParentPath(const UString &path, UString &parentPrefix, UString &name); + // Reload changes DirPrefix. Don't send DirPrefix in pathPrefix parameter + HRESULT Reload(const UString &pathPrefix, const UString &selectedName); + HRESULT Reload(); + + void OpenParentFolder(); + void SetPathEditText(); + void OnCreateDir(); + void OnItemEnter(); + void FinishOnOK(); + + int GetRealItemIndex(int indexInListView) const + { + LPARAM param; + if (!_list.GetItemParam(indexInListView, param)) + return (int)-1; + return (int)param; + } + +public: + bool FolderMode; + UString Title; + UString FilePath; // input/ result path + bool ShowAllFiles; + UStringVector Filters; + UString FilterDescription; + + CBrowseDialog(): FolderMode(false), _showDots(false), ShowAllFiles(true) {} + void SetFilter(const UString &s); + INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_BROWSE, parent); } + int CompareItems(LPARAM lParam1, LPARAM lParam2); }; -#endif -static bool GetParentPath(const UString &path2, UString &dest, UString &focused) +void CBrowseDialog::SetFilter(const UString &s) { - UString path = path2; - dest.Empty(); - if (path.IsEmpty()) - return false; - if (path.Back() == WCHAR_PATH_SEPARATOR) - path.DeleteBack(); - if (path.IsEmpty()) - return false; - int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR); - if (pos < 0 || path.Back() == WCHAR_PATH_SEPARATOR) - return false; - focused = path.Mid(pos + 1); - dest = path.Left(pos + 1); - return true; + Filters.Clear(); + UString mask; + unsigned i; + for (i = 0; i < s.Len(); i++) + { + wchar_t c = s[i]; + if (c == ';') + { + if (!mask.IsEmpty()) + Filters.Add(mask); + mask.Empty(); + } + else + mask += c; + } + if (!mask.IsEmpty()) + Filters.Add(mask); + ShowAllFiles = Filters.IsEmpty(); + for (i = 0; i < Filters.Size(); i++) + { + const UString &f = Filters[i]; + if (f == L"*.*" || f == L"*") + { + ShowAllFiles = true; + break; + } + } } bool CBrowseDialog::OnInit() { #ifdef LANG - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, NULL, 0); #endif if (!Title.IsEmpty()) SetText(Title); - _list.Attach(GetItem(IDC_BROWSE_LIST)); + _list.Attach(GetItem(IDL_BROWSE)); + _filterCombo.Attach(GetItem(IDC_BROWSE_FILTER)); + _pathEdit.Attach(GetItem(IDE_BROWSE_PATH)); + + if (FolderMode) + HideItem(IDC_BROWSE_FILTER); + else + EnableItem(IDC_BROWSE_FILTER, false); #ifndef UNDER_CE _list.SetUnicodeFormat(); @@ -70,54 +198,104 @@ bool CBrowseDialog::OnInit() _showDots = ReadShowDots(); #endif + { + UString s; + if (!FilterDescription.IsEmpty()) + s = FilterDescription; + else if (ShowAllFiles) + s = L"*.*"; + else + { + FOR_VECTOR (i, Filters) + { + if (i != 0) + s += L' '; + s += Filters[i]; + } + } + _filterCombo.AddString(s); + _filterCombo.SetCurSel(0); + } + _list.SetImageList(GetSysImageList(true), LVSIL_SMALL); _list.SetImageList(GetSysImageList(false), LVSIL_NORMAL); - _list.InsertColumn(0, LangStringSpec(IDS_PROP_NAME, 0x02000204), 100); - _list.InsertColumn(1, LangStringSpec(IDS_PROP_MTIME, 0x0200020C), 100); + _list.InsertColumn(0, LangString(IDS_PROP_NAME), 100); + _list.InsertColumn(1, LangString(IDS_PROP_MTIME), 100); { LV_COLUMNW column; + column.iSubItem = 2; column.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; column.fmt = LVCFMT_RIGHT; - column.iSubItem = 2; - UString s = LangStringSpec(IDS_PROP_SIZE, 0x02000207); + column.cx = 100; + const UString s = LangString(IDS_PROP_SIZE); column.pszText = (wchar_t *)(const wchar_t *)s; _list.InsertColumn(2, &column); - - // _list.InsertColumn(2, LangStringSpec(IDS_PROP_SIZE, 0x02000207), 100); } - _list.InsertItem(0, L"12345678901234567"); - _list.SetSubItem(0, 1, L"2009-09-09"); + _list.InsertItem(0, L"12345678901234567" + #ifndef UNDER_CE + L"1234567890" + #endif + ); + _list.SetSubItem(0, 1, L"2009-09-09" + #ifndef UNDER_CE + L" 09:09" + #endif + ); _list.SetSubItem(0, 2, L"9999 MB"); for (int i = 0; i < 3; i++) _list.SetColumnWidthAuto(i); _list.DeleteAllItems(); - - UString selectedName; - if (!FolderMode) + + _ascending = true; + _sortIndex = 0; + + NormalizeSize(); + + _topDirPrefix.Empty(); { - int pos = Path.ReverseFind(WCHAR_PATH_SEPARATOR); - if (pos >= 0 && Path.Back() != WCHAR_PATH_SEPARATOR) + int rootSize = GetRootPrefixSize(FilePath); + // We can go up from root folder to drives list + if (NName::IsDrivePath(FilePath)) + rootSize = 0; + else if (IsSuperPath(FilePath)) { - selectedName = Path.Mid(pos + 1); - Path = Path.Left(pos + 1); + if (NName::IsDrivePath(&FilePath[kSuperPathPrefixSize])) + rootSize = kSuperPathPrefixSize; } + _topDirPrefix.SetFrom(FilePath, rootSize); } - _ascending = true; - _sortIndex = 0; - NormalizeSize(); + UString name; + if (!GetParentPath(FilePath, DirPrefix, name)) + DirPrefix = _topDirPrefix; - while (Reload(Path, selectedName) != S_OK) + for(;;) { - UString parent; - if (!GetParentPath(Path, parent, selectedName)) + UString baseFolder = DirPrefix; + if (Reload(baseFolder, name) == S_OK) break; - selectedName.Empty(); - Path = parent; + name.Empty(); + if (DirPrefix.IsEmpty()) + break; + UString parent, name2; + GetParentPath(DirPrefix, parent, name2); + DirPrefix = parent; } + if (name.IsEmpty()) + name = FilePath; + if (FolderMode) + NormalizeDirPathPrefix(name); + _pathEdit.SetText(name); + + #ifndef UNDER_CE + /* If we clear UISF_HIDEFOCUS, the focus rectangle in ListView will be visible, + even if we use mouse for pressing the button to open this dialog. */ + PostMessage(MY__WM_UPDATEUISTATE, MAKEWPARAM(MY__UIS_CLEAR, MY__UISF_HIDEFOCUS)); + #endif + return CModalDialog::OnInit(); } @@ -125,67 +303,173 @@ bool CBrowseDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) { int mx, my; { - RECT rect; - GetClientRectOfItem(IDC_BROWSE_PARENT, rect); - mx = rect.left; - my = rect.top; + RECT r; + GetClientRectOfItem(IDB_BROWSE_PARENT, r); + mx = r.left; + my = r.top; } InvalidateRect(NULL); + int xLim = xSize - mx; { - RECT rect; - GetClientRectOfItem(IDC_BROWSE_PATH, rect); - MoveItem(IDC_BROWSE_PATH, rect.left, rect.top, xSize - mx - rect.left, RECT_SIZE_Y(rect)); + RECT r; + GetClientRectOfItem(IDT_BROWSE_FOLDER, r); + MoveItem(IDT_BROWSE_FOLDER, r.left, r.top, xLim - r.left, RECT_SIZE_Y(r)); } int bx1, bx2, by; GetItemSizes(IDCANCEL, bx1, by); GetItemSizes(IDOK, bx2, by); int y = ySize - my - by; - int x = xSize - mx - bx1; + int x = xLim - bx1; MoveItem(IDCANCEL, x, y, bx1, by); MoveItem(IDOK, x - mx - bx2, y, bx2, by); + // Y_Size of ComboBox is tricky. So we use Y_Size of _pathEdit instead + + int yPathSize; + { + RECT r; + GetClientRectOfItem(IDE_BROWSE_PATH, r); + yPathSize = RECT_SIZE_Y(r); + _pathEdit.Move(r.left, y - my - yPathSize - my - yPathSize, xLim - r.left, yPathSize); + } + { - RECT rect; - GetClientRectOfItem(IDC_BROWSE_LIST, rect); - _list.Move(rect.left, rect.top, xSize - mx - rect.left, y - my - rect.top); + RECT r; + GetClientRectOfItem(IDC_BROWSE_FILTER, r); + _filterCombo.Move(r.left, y - my - yPathSize, xLim - r.left, RECT_SIZE_Y(r)); } + + { + RECT r; + GetClientRectOfItem(IDL_BROWSE, r); + _list.Move(r.left, r.top, xLim - r.left, y - my - yPathSize - my - yPathSize - my - r.top); + } + return false; } -static UString ConvertSizeToStringShort(UInt64 value) +bool CBrowseDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { - wchar_t s[32]; - wchar_t c = L'\0', c2 = L'\0'; - if (value < (UInt64)10000) + if (message == k_Message_RefreshPathEdit) + { + SetPathEditText(); + return true; + } + return CModalDialog::OnMessage(message, wParam, lParam); +} + +bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header) +{ + if (header->hwndFrom != _list) + return false; + switch (header->code) { - c = L'\0'; - c2 = L'\0'; + case LVN_ITEMACTIVATE: + if (g_LVN_ITEMACTIVATE_Support) + OnItemEnter(); + break; + case NM_DBLCLK: + case NM_RETURN: // probabably it's unused + if (!g_LVN_ITEMACTIVATE_Support) + OnItemEnter(); + break; + case LVN_COLUMNCLICK: + { + int index = LPNMLISTVIEW(header)->iSubItem; + if (index == _sortIndex) + _ascending = !_ascending; + else + { + _ascending = (index == 0); + _sortIndex = index; + } + Reload(); + return false; + } + case LVN_KEYDOWN: + { + bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header)); + Post_RefreshPathEdit(); + return boolResult; + } + case NM_RCLICK: + case NM_CLICK: + case LVN_BEGINDRAG: + Post_RefreshPathEdit(); + break; } - else if (value < ((UInt64)10000 << 10)) + return false; +} + +bool CBrowseDialog::OnKeyDown(LPNMLVKEYDOWN keyDownInfo) +{ + bool ctrl = IsKeyDown(VK_CONTROL); + + switch (keyDownInfo->wVKey) { - value >>= 10; - c = L'K'; + case VK_BACK: + OpenParentFolder(); + return true; + case 'R': + if (ctrl) + { + Reload(); + return true; + } + return false; + case VK_F7: + OnCreateDir(); + return true; } - else if (value < ((UInt64)10000 << 20)) + return false; +} + +bool CBrowseDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + switch (buttonID) { - value >>= 20; - c = L'M'; + case IDB_BROWSE_PARENT: OpenParentFolder(); break; + case IDB_BROWSE_CREATE_DIR: OnCreateDir(); break; + default: return CModalDialog::OnButtonClicked(buttonID, buttonHWND); } - else + _list.SetFocus(); + return true; +} + +void CBrowseDialog::OnOK() +{ + /* When we press "Enter" in listview, Windows sends message to first Button. + We check that message was from ListView; */ + if (GetFocus() == _list) { - value >>= 30; - c = L'G'; + OnItemEnter(); + return; } - ConvertUInt64ToString(value, s); - int p = MyStringLen(s); - if (c != 0) - s[p++] = L' '; - s[p++] = c; - s[p++] = c2; - s[p++] = L'\0'; - return s; + FinishOnOK(); +} + + +bool CBrowseDialog::GetParentPath(const UString &path, UString &parentPrefix, UString &name) +{ + parentPrefix.Empty(); + name.Empty(); + if (path.IsEmpty()) + return false; + if (_topDirPrefix == path) + return false; + UString s = path; + if (s.Back() == WCHAR_PATH_SEPARATOR) + s.DeleteBack(); + if (s.IsEmpty()) + return false; + if (s.Back() == WCHAR_PATH_SEPARATOR) + return false; + int pos = s.ReverseFind(WCHAR_PATH_SEPARATOR); + parentPrefix.SetFrom(s, pos + 1); + name = s.Ptr(pos + 1); + return true; } int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2) @@ -197,77 +481,122 @@ int CBrowseDialog::CompareItems(LPARAM lParam1, LPARAM lParam2) bool isDir1 = f1.IsDir(); bool isDir2 = f2.IsDir(); - if (isDir1 && !isDir2) return -1; if (isDir2 && !isDir1) return 1; - int result = 0; - switch(_sortIndex) + int res = 0; + switch (_sortIndex) { - case 0: result = f1.Name.CompareNoCase(f2.Name); break; - case 1: result = CompareFileTime(&f1.MTime, &f2.MTime); break; - case 2: result = MyCompare(f1.Size, f2.Size); break; + case 0: res = CompareFileNames(fs2us(f1.Name), fs2us(f2.Name)); break; + case 1: res = CompareFileTime(&f1.MTime, &f2.MTime); break; + case 2: res = MyCompare(f1.Size, f2.Size); break; } - return _ascending ? result: (-result); + return _ascending ? res: -res; } static int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) { - if (lpData == NULL) - return 0; - return ((CBrowseDialog*)lpData)->CompareItems(lParam1, lParam2); + return ((CBrowseDialog *)lpData)->CompareItems(lParam1, lParam2); } -static HRESULT GetNormalizedError() +static void ConvertSizeToString(UInt64 v, wchar_t *s) { - HRESULT errorCode = GetLastError(); - return (errorCode == 0) ? 1 : errorCode; + Byte c = 0; + if (v >= ((UInt64)10000 << 20)) { v >>= 30; c = 'G'; } + else if (v >= ((UInt64)10000 << 10)) { v >>= 20; c = 'M'; } + else if (v >= ((UInt64)10000 << 0)) { v >>= 10; c = 'K'; } + ConvertUInt64ToString(v, s); + if (c != 0) + { + s += MyStringLen(s); + *s++ = ' '; + *s++ = c; + *s++ = 0; + } } +// Reload changes DirPrefix. Don't send DirPrefix in pathPrefix parameter + HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selectedName) { - CEnumerator enumerator(us2fs(pathPrefix + L'*')); CObjectVector files; - for (;;) + + #ifndef UNDER_CE + bool isDrive = false; + if (pathPrefix.IsEmpty() || pathPrefix == kSuperPathPrefix) { - bool found; - CFileInfo fi; - if (!enumerator.Next(fi, found)) + isDrive = true; + FStringVector drives; + if (!MyGetLogicalDriveStrings(drives)) return GetNormalizedError(); - if (!found) - break; - files.Add(fi); + FOR_VECTOR (i, drives) + { + FString d = drives[i]; + if (d.Len() < 3 || d.Back() != '\\') + return E_FAIL; + d.DeleteBack(); + CFileInfo &fi = files.AddNew(); + fi.SetAsDir(); + fi.Name = d; + } + } + else + #endif + { + CEnumerator enumerator(us2fs(pathPrefix + L'*')); + for (;;) + { + bool found; + CFileInfo fi; + if (!enumerator.Next(fi, found)) + return GetNormalizedError(); + if (!found) + break; + if (!fi.IsDir()) + { + if (FolderMode) + continue; + if (!ShowAllFiles) + { + unsigned i; + for (i = 0; i < Filters.Size(); i++) + if (DoesWildcardMatchName(Filters[i], fs2us(fi.Name))) + break; + if (i == Filters.Size()) + continue; + } + } + files.Add(fi); + } } - Path = pathPrefix; + DirPrefix = pathPrefix; _files = files; - SetItemText(IDC_BROWSE_PATH, Path); + SetItemText(IDT_BROWSE_FOLDER, DirPrefix); + _list.SetRedraw(false); _list.DeleteAllItems(); - if (!Path.IsEmpty() && Path.Back() != WCHAR_PATH_SEPARATOR) - Path += WCHAR_PATH_SEPARATOR; - LVITEMW item; int index = 0; int cursorIndex = -1; #ifndef _SFX - if (_showDots) + if (_showDots && _topDirPrefix != DirPrefix) { - UString itemName = L".."; item.iItem = index; + const UString itemName = L".."; if (selectedName.IsEmpty()) - cursorIndex = item.iItem; + cursorIndex = index; item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; int subItem = 0; item.iSubItem = subItem++; item.lParam = kParentIndex; item.pszText = (wchar_t *)(const wchar_t *)itemName; - item.iImage = _extToIconMap.GetIconIndex(FILE_ATTRIBUTE_DIRECTORY, Path); + item.iImage = _extToIconMap.GetIconIndex(FILE_ATTRIBUTE_DIRECTORY, DirPrefix); if (item.iImage < 0) item.iImage = 0; _list.InsertItem(&item); @@ -277,36 +606,52 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected } #endif - for (int i = 0; i < _files.Size(); i++) + for (unsigned i = 0; i < _files.Size(); i++, index++) { - const CFileInfo &fi = _files[i]; item.iItem = index; + const CFileInfo &fi = _files[i]; const UString name = fs2us(fi.Name); - if (name.CompareNoCase(selectedName) == 0) - cursorIndex = item.iItem; + if (!selectedName.IsEmpty() && CompareFileNames(name, selectedName) == 0) + cursorIndex = index; item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; int subItem = 0; item.iSubItem = subItem++; item.lParam = i; item.pszText = (wchar_t *)(const wchar_t *)name; - item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, Path + name); + + const UString fullPath = DirPrefix + name; + #ifndef UNDER_CE + if (isDrive) + { + if (GetRealIconIndex(fi.Name + FCHAR_PATH_SEPARATOR, FILE_ATTRIBUTE_DIRECTORY, item.iImage) == 0) + item.iImage = 0; + } + else + #endif + item.iImage = _extToIconMap.GetIconIndex(fi.Attrib, fullPath); if (item.iImage < 0) item.iImage = 0; _list.InsertItem(&item); + wchar_t s[32]; { FILETIME ft; - UString s; + s[0] = 0; if (FileTimeToLocalFileTime(&fi.MTime, &ft)) - s = ConvertFileTimeToString(ft, false, false); + ConvertFileTimeToString(ft, s, + #ifndef UNDER_CE + true + #else + false + #endif + , false); _list.SetSubItem(index, subItem++, s); } { - UString s; + s[0] = 0; if (!fi.IsDir()) - s = ConvertSizeToStringShort(fi.Size); + ConvertSizeToString(fi.Size, s); _list.SetSubItem(index, subItem++, s); } - index++; } if (_list.GetItemCount() > 0 && cursorIndex >= 0) @@ -316,144 +661,93 @@ HRESULT CBrowseDialog::Reload(const UString &pathPrefix, const UString &selected _list.SetItemState(0, LVIS_FOCUSED, LVIS_FOCUSED); _list.EnsureVisible(_list.GetFocusedItem(), false); _list.SetRedraw(true); + _list.InvalidateRect(NULL, true); return S_OK; } HRESULT CBrowseDialog::Reload() { - UString selectedCur; + UString selected; int index = _list.GetNextSelectedItem(-1); if (index >= 0) { int fileIndex = GetRealItemIndex(index); if (fileIndex != kParentIndex) - selectedCur = fs2us(_files[fileIndex].Name); + selected = fs2us(_files[fileIndex].Name); } - return Reload(Path, selectedCur); + UString dirPathTemp = DirPrefix; + return Reload(dirPathTemp, selected); } void CBrowseDialog::OpenParentFolder() { UString parent, selected; - if (GetParentPath(Path, parent, selected)) + if (GetParentPath(DirPrefix, parent, selected)) + { Reload(parent, selected); + SetPathEditText(); + } } -extern UString HResultToMessage(HRESULT errorCode); - -bool CBrowseDialog::OnNotify(UINT /* controlID */, LPNMHDR header) +void CBrowseDialog::SetPathEditText() { - if (header->hwndFrom != _list) - return false; - switch(header->code) + int index = _list.GetNextSelectedItem(-1); + if (index < 0) { - case LVN_ITEMACTIVATE: - if (g_LVN_ITEMACTIVATE_Support) - { - OnItemEnter(); - return true; - } - break; - case NM_DBLCLK: - case NM_RETURN: // probabably it's unused - if (!g_LVN_ITEMACTIVATE_Support) - { - OnItemEnter(); - return true; - } - break; - case LVN_COLUMNCLICK: - { - int index = LPNMLISTVIEW(header)->iSubItem; - if (index == _sortIndex) - _ascending = !_ascending; - else - { - _ascending = (index == 0); - _sortIndex = index; - } - Reload(); - return false; - } - case LVN_KEYDOWN: - { - LRESULT result; - bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result); - return boolResult; - } + if (FolderMode) + _pathEdit.SetText(DirPrefix); + return; } - return false; -} - -bool CBrowseDialog::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) -{ - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - result = 0; - - switch(keyDownInfo->wVKey) + int fileIndex = GetRealItemIndex(index); + if (fileIndex == kParentIndex) { - case VK_BACK: - OpenParentFolder(); - return true; - case 'R': - if (ctrl) - { - Reload(); - return true; - } - return false; + if (FolderMode) + _pathEdit.SetText(L".." WSTRING_PATH_SEPARATOR); + return; } - return false; -} - -bool CBrowseDialog::OnButtonClicked(int buttonID, HWND buttonHWND) -{ - switch(buttonID) + const CFileInfo &file = _files[fileIndex]; + if (file.IsDir()) { - case IDC_BROWSE_PARENT: - OpenParentFolder(); - return true; + if (!FolderMode) + return; + _pathEdit.SetText(fs2us(file.Name) + WCHAR_PATH_SEPARATOR); } - return CModalDialog::OnButtonClicked(buttonID, buttonHWND); -} - -void CBrowseDialog::ShowError(LPCWSTR s) { MessageBoxW(*this, s, L"7-Zip", MB_ICONERROR); } - -void CBrowseDialog::ShowSelectError() -{ - ShowError(FolderMode ? - L"You must select some folder": - L"You must select some file"); + else + _pathEdit.SetText(fs2us(file.Name)); } -void CBrowseDialog::FinishOnOK() +void CBrowseDialog::OnCreateDir() { - int index = _list.GetNextSelectedItem(-1); - if (index < 0) + UString name; { - if (!FolderMode) + UString enteredName; + Dlg_CreateFolder((HWND)*this, enteredName); + if (enteredName.IsEmpty()) + return; + if (!CorrectFsPath(DirPrefix, enteredName, name)) { - ShowSelectError(); + MessageBox_HResError((HWND)*this, ERROR_INVALID_NAME, name); return; } } - else + if (name.IsEmpty()) + return; + + FString destPath; + if (GetFullPath(us2fs(DirPrefix), us2fs(name), destPath)) { - int fileIndex = GetRealItemIndex(index); - if (fileIndex == kParentIndex) + if (!NDir::CreateComplexDir(destPath)) { - OpenParentFolder(); - return; + MessageBox_HResError((HWND)*this, GetNormalizedError(), fs2us(destPath)); } - const CFileInfo &file = _files[fileIndex]; - if (file.IsDir() != FolderMode) + else { - ShowSelectError(); - return; + UString tempPath = DirPrefix; + Reload(tempPath, name); + SetPathEditText(); } - Path += fs2us(file.Name); + _list.SetFocus(); } - End(IDOK); } void CBrowseDialog::OnItemEnter() @@ -471,48 +765,244 @@ void CBrowseDialog::OnItemEnter() { if (!FolderMode) FinishOnOK(); - else - ShowSelectError(); + /* + MessageBox_Error_Global(*this, FolderMode ? + L"You must select some folder": + L"You must select some file"); + */ return; } - HRESULT res = Reload(Path + fs2us(file.Name) + WCHAR_PATH_SEPARATOR, L""); + UString s = DirPrefix + fs2us(file.Name) + WCHAR_PATH_SEPARATOR; + HRESULT res = Reload(s, L""); if (res != S_OK) - ShowError(HResultToMessage(res)); + MessageBox_HResError(*this, res, s); + SetPathEditText(); } } -void CBrowseDialog::OnOK() +void CBrowseDialog::FinishOnOK() { - // When we press "Enter" in listview, windows sends message to first Button. - // We check that message was from listview; - if (GetFocus() == _list) + UString s; + _pathEdit.GetText(s); + FString destPath; + if (!GetFullPath(us2fs(DirPrefix), us2fs(s), destPath)) { - OnItemEnter(); + MessageBox_HResError((HWND)*this, ERROR_INVALID_NAME, s); return; } - FinishOnOK(); + FilePath = fs2us(destPath); + if (FolderMode) + NormalizeDirPathPrefix(FilePath); + End(IDOK); } -static bool MyBrowse(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath, bool folderMode) +#endif + +bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultPath) { + resultPath.Empty(); + + #ifndef UNDER_CE + + #ifdef USE_MY_BROWSE_DIALOG + if (!IsSuperOrDevicePath(path)) + #endif + return NShell::BrowseForFolder(owner, title, path, resultPath); + + #endif + + #ifdef USE_MY_BROWSE_DIALOG + CBrowseDialog dialog; - dialog.Title = title; - dialog.Path = initialFolder; - dialog.FolderMode = folderMode; + dialog.FolderMode = true; + if (title) + dialog.Title = title; + if (path) + dialog.FilePath = path; if (dialog.Create(owner) != IDOK) return false; - resultPath = dialog.Path; + resultPath = dialog.FilePath; + #endif + return true; } -bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath) +bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR path, + LPCWSTR filterDescription, LPCWSTR filter, UString &resultPath) { - return MyBrowse(owner, title, initialFolder, resultPath, true); + resultPath.Empty(); + + #ifndef UNDER_CE + + #ifdef USE_MY_BROWSE_DIALOG + if (!IsSuperOrDevicePath(path)) + #endif + { + if (MyGetOpenFileName(owner, title, NULL, path, filterDescription, filter, resultPath)) + return true; + #ifdef UNDER_CE + return false; + #else + // maybe we must use GetLastError in WinCE. + DWORD errorCode = CommDlgExtendedError(); + const wchar_t *errorMessage = NULL; + switch (errorCode) + { + case 0: return false; // cancel or close obn dialog + case FNERR_INVALIDFILENAME: errorMessage = L"Invalid File Name"; break; + default: errorMessage = L"Open Dialog Error"; + } + if (!errorMessage) + return false; + { + UString s = errorMessage; + s += L"\n"; + s += path; + MessageBox_Error_Global(owner, s); + } + #endif + } + + #endif + + #ifdef USE_MY_BROWSE_DIALOG + CBrowseDialog dialog; + if (title) + dialog.Title = title; + if (path) + dialog.FilePath = path; + dialog.FolderMode = false; + if (filter) + dialog.SetFilter(filter); + if (filterDescription) + dialog.FilterDescription = filterDescription; + if (dialog.Create(owner) != IDOK) + return false; + resultPath = dialog.FilePath; + #endif + + return true; } -bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR, UString &resultPath) + +#ifdef _WIN32 + +static void RemoveDotsAndSpaces(UString &path) { - return MyBrowse(owner, title, initialFolder, resultPath, false); + while (!path.IsEmpty()) + { + wchar_t c = path.Back(); + if (c != ' ' && c != '.') + return; + path.DeleteBack(); + } } + +bool CorrectFsPath(const UString &relBase, const UString &path2, UString &result) +{ + result.Empty(); + + UString path = path2; + path.Replace('/', WCHAR_PATH_SEPARATOR); + unsigned start = 0; + UString base; + if (NName::IsAbsolutePath(path)) + { + if (IsSuperOrDevicePath(path)) + { + result = path; + return true; + } + int pos = GetRootPrefixSize(path); + if (pos > 0) + start = pos; + } + else + { + if (IsSuperOrDevicePath(relBase)) + { + result = path; + return true; + } + base = relBase; + } + + /* We can't use backward, since we must change only disk paths */ + /* + for (;;) + { + if (path.Len() <= start) + break; + if (DoesFileOrDirExist(us2fs(path))) + break; + if (path.Back() == WCHAR_PATH_SEPARATOR) + { + path.DeleteBack(); + result.Insert(0, WCHAR_PATH_SEPARATOR);; + } + int pos = path.ReverseFind(WCHAR_PATH_SEPARATOR) + 1; + UString cur = path.Ptr(pos); + RemoveDotsAndSpaces(cur); + result.Insert(0, cur); + path.DeleteFrom(pos); + } + result.Insert(0, path); + return true; + */ + + result += path.Left(start); + bool checkExist = true; + UString cur; + for (;;) + { + if (start == path.Len()) + break; + int slashPos = path.Find(WCHAR_PATH_SEPARATOR, start); + cur.SetFrom(path.Ptr(start), (slashPos < 0 ? path.Len() : slashPos) - start); + if (checkExist) + { + CFileInfo fi; + if (fi.Find(us2fs(base + result + cur))) + { + if (!fi.IsDir()) + { + result = path; + break; + } + } + else + checkExist = false; + } + if (!checkExist) + RemoveDotsAndSpaces(cur); + result += cur; + if (slashPos < 0) + break; + result += WCHAR_PATH_SEPARATOR; + start = slashPos + 1; + } + + return true; +} + +#else +bool CorrectFsPath(const UString & /* relBase */, const UString &path, UString &result) +{ + result = path; + return true; +} #endif + +bool Dlg_CreateFolder(HWND wnd, UString &destName) +{ + destName.Empty(); + CComboDialog dlg; + LangString(IDS_CREATE_FOLDER, dlg.Title); + LangString(IDS_CREATE_FOLDER_NAME, dlg.Static); + LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, dlg.Value); + if (dlg.Create(wnd) != IDOK) + return false; + destName = dlg.Value; + return true; +} diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.h b/CPP/7zip/UI/FileManager/BrowseDialog.h old mode 100755 new mode 100644 index f597d1c3..77c749b5 --- a/CPP/7zip/UI/FileManager/BrowseDialog.h +++ b/CPP/7zip/UI/FileManager/BrowseDialog.h @@ -3,79 +3,19 @@ #ifndef __BROWSE_DIALOG_H #define __BROWSE_DIALOG_H -#ifdef UNDER_CE -#define USE_MY_BROWSE_DIALOG -#endif - -#ifdef USE_MY_BROWSE_DIALOG - -#include "Windows/FileFind.h" - -#include "Windows/Control/Dialog.h" -#include "Windows/Control/ListView.h" - -#include "BrowseDialogRes.h" -#include "SysIconUtils.h" - -class CBrowseDialog: public NWindows::NControl::CModalDialog -{ - NWindows::NControl::CListView _list; - CObjectVector _files; - CExtToIconMap _extToIconMap; - int _sortIndex; - bool _ascending; - bool _showDots; - - virtual bool OnInit(); - virtual bool OnSize(WPARAM wParam, int xSize, int ySize); - virtual bool OnNotify(UINT controlID, LPNMHDR header); - virtual void OnOK(); - - virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); - virtual bool OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result); - - void FinishOnOK(); - HRESULT Reload(const UString &pathPrefix, const UString &selectedName); - HRESULT Reload(); - void OpenParentFolder(); +#include "../../../Common/MyString.h" - void OnItemEnter(); +bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR path, UString &resultPath); +bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR path, LPCWSTR filterDescription, LPCWSTR filter, UString &resultPath); - int GetRealItemIndex(int indexInListView) const - { - LPARAM param; - if (!_list.GetItemParam(indexInListView, param)) - return (int)-1; - return (int)param; - } +/* CorrectFsPath removes undesirable characters in names (dots and spaces at the end of file) + But it doesn't change "bad" name in any of the following caes: + - path is Super Path (with \\?\ prefix) + - path is relative and relBase is Super Path + - there is file or dir in filesystem with specified "bad" name */ - void ShowError(LPCWSTR s); - void ShowSelectError(); -public: - UString Title; - UString Path; - bool FolderMode; +bool CorrectFsPath(const UString &relBase, const UString &path, UString &result); - CBrowseDialog(): FolderMode(true), _showDots(false) {} - - INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_BROWSE, parent); } - int CompareItems(LPARAM lParam1, LPARAM lParam2); -}; - -bool MyBrowseForFolder(HWND owner, LPCWSTR title, LPCWSTR initialFolder, UString &resultPath); -bool MyBrowseForFile(HWND owner, LPCWSTR title, LPCWSTR initialFolder, LPCWSTR s, UString &resultPath); - -#else - -#include "Windows/CommonDialog.h" -#include "Windows/Shell.h" - -#define MyBrowseForFolder(h, title, initialFolder, resultPath) \ - NShell::BrowseForFolder(h, title, initialFolder, resultPath) - -#define MyBrowseForFile(h, title, initialFolder, s, resultPath) \ - MyGetOpenFileName(h, title, initialFolder, s, resultPath) - -#endif +bool Dlg_CreateFolder(HWND wnd, UString &destName); #endif diff --git a/CPP/7zip/UI/FileManager/BrowseDialog.rc b/CPP/7zip/UI/FileManager/BrowseDialog.rc old mode 100755 new mode 100644 index 4d7ec288..04a6ad61 --- a/CPP/7zip/UI/FileManager/BrowseDialog.rc +++ b/CPP/7zip/UI/FileManager/BrowseDialog.rc @@ -1,17 +1,25 @@ #include "BrowseDialogRes.h" #include "../../GuiCommon.rc" -#define xc 180 -#define yc 160 +#define xc 256 +#define yc 320 -IDD_DIALOG_BROWSE MY_RESIZE_DIALOG +#define k_BROWSE_y_CtrlSize 14 + +#define k_BROWSE_y_List 24 + +IDD_BROWSE DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT CAPTION "7-Zip: Browse" { - LTEXT "", IDC_BROWSE_PATH, m + 20, m + 3, xc - 20, 8 - CONTROL "List1", IDC_BROWSE_LIST, "SysListView32", - LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP, - m, m + 16, xc, yc - bys - m - 16 + EDITTEXT IDE_BROWSE_PATH, m, by - m - k_BROWSE_y_CtrlSize - k_BROWSE_y_CtrlSize - m, xc, k_BROWSE_y_CtrlSize, ES_AUTOHSCROLL + COMBOBOX IDC_BROWSE_FILTER, m, by - m - k_BROWSE_y_CtrlSize, xc, 30, MY_COMBO + PUSHBUTTON "OK", IDOK, bx2, by, bxs, bys PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys - PUSHBUTTON "..", IDC_BROWSE_PARENT, m, m, 16, 14 + PUSHBUTTON "<--", IDB_BROWSE_PARENT, m, m, 24, bys + PUSHBUTTON "+", IDB_BROWSE_CREATE_DIR, m + 32, m, 24, bys + LTEXT "", IDT_BROWSE_FOLDER, m + 64, m + 3, xc - 20, 8 + CONTROL "List1", IDL_BROWSE, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_SINGLESEL | WS_BORDER | WS_TABSTOP, + m, m + k_BROWSE_y_List, xc, yc - bys - m - k_BROWSE_y_List - k_BROWSE_y_CtrlSize - m - k_BROWSE_y_CtrlSize - m } diff --git a/CPP/7zip/UI/FileManager/BrowseDialogRes.h b/CPP/7zip/UI/FileManager/BrowseDialogRes.h old mode 100755 new mode 100644 index 79f0efdb..aff84ec9 --- a/CPP/7zip/UI/FileManager/BrowseDialogRes.h +++ b/CPP/7zip/UI/FileManager/BrowseDialogRes.h @@ -1,4 +1,9 @@ -#define IDD_DIALOG_BROWSE 509 -#define IDC_BROWSE_LIST 1000 -#define IDC_BROWSE_PATH 1001 -#define IDC_BROWSE_PARENT 1002 +#define IDD_BROWSE 95 + +#define IDL_BROWSE 100 +#define IDT_BROWSE_FOLDER 101 +#define IDE_BROWSE_PATH 102 +#define IDC_BROWSE_FILTER 103 + +#define IDB_BROWSE_PARENT 110 +#define IDB_BROWSE_CREATE_DIR 112 diff --git a/CPP/7zip/UI/FileManager/ClassDefs.cpp b/CPP/7zip/UI/FileManager/ClassDefs.cpp old mode 100755 new mode 100644 index 9fec3d92..b092a9ed --- a/CPP/7zip/UI/FileManager/ClassDefs.cpp +++ b/CPP/7zip/UI/FileManager/ClassDefs.cpp @@ -2,7 +2,8 @@ #include "StdAfx.h" -#include "Common/MyInitGuid.h" +#include "../../../Common/MyInitGuid.h" #include "../Agent/Agent.h" + #include "MyWindowsNew.h" diff --git a/CPP/7zip/UI/FileManager/ComboDialog.cpp b/CPP/7zip/UI/FileManager/ComboDialog.cpp old mode 100755 new mode 100644 index c3cc08e7..729743e8 --- a/CPP/7zip/UI/FileManager/ComboDialog.cpp +++ b/CPP/7zip/UI/FileManager/ComboDialog.cpp @@ -3,7 +3,7 @@ #include "StdAfx.h" #include "ComboDialog.h" -#include "Windows/Control/Static.h" +#include "../../../Windows/Control/Static.h" #ifdef LANG #include "LangUtils.h" @@ -11,20 +11,12 @@ using namespace NWindows; -#ifdef LANG -static CIDLangPair kIDLangPairs[] = -{ - { IDOK, 0x02000702 }, - { IDCANCEL, 0x02000710 } -}; -#endif - bool CComboDialog::OnInit() { #ifdef LANG - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, NULL, 0); #endif - _comboBox.Attach(GetItem(IDC_COMBO_COMBO)); + _comboBox.Attach(GetItem(IDC_COMBO)); /* // why it doesn't work ? @@ -38,10 +30,10 @@ bool CComboDialog::OnInit() SetText(Title); NControl::CStatic staticContol; - staticContol.Attach(GetItem(IDC_COMBO_STATIC)); + staticContol.Attach(GetItem(IDT_COMBO)); staticContol.SetText(Static); _comboBox.SetText(Value); - for(int i = 0; i < Strings.Size(); i++) + FOR_VECTOR (i, Strings) _comboBox.AddString(Strings[i]); NormalizeSize(); return CModalDialog::OnInit(); diff --git a/CPP/7zip/UI/FileManager/ComboDialog.h b/CPP/7zip/UI/FileManager/ComboDialog.h old mode 100755 new mode 100644 index ff111b19..29b28b5b --- a/CPP/7zip/UI/FileManager/ComboDialog.h +++ b/CPP/7zip/UI/FileManager/ComboDialog.h @@ -3,8 +3,8 @@ #ifndef __COMBO_DIALOG_H #define __COMBO_DIALOG_H -#include "Windows/Control/ComboBox.h" -#include "Windows/Control/Dialog.h" +#include "../../../Windows/Control/ComboBox.h" +#include "../../../Windows/Control/Dialog.h" #include "ComboDialogRes.h" @@ -20,8 +20,9 @@ public: UString Static; UString Value; UStringVector Strings; + // CComboDialog(): Sorted(false) {}; - INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COMBO, parentWindow); } + INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_COMBO, parentWindow); } }; #endif diff --git a/CPP/7zip/UI/FileManager/ComboDialog.rc b/CPP/7zip/UI/FileManager/ComboDialog.rc old mode 100755 new mode 100644 index 6789347a..fddb7484 --- a/CPP/7zip/UI/FileManager/ComboDialog.rc +++ b/CPP/7zip/UI/FileManager/ComboDialog.rc @@ -4,10 +4,13 @@ #define xc 240 #define yc 64 -IDD_DIALOG_COMBO MY_RESIZE_DIALOG +IDD_COMBO DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT CAPTION "Combo" { - LTEXT "", IDC_COMBO_STATIC, m, m, xc, 8 - COMBOBOX IDC_COMBO_COMBO, m, 20, xc, 65, MY_COMBO_WITH_EDIT + LTEXT "", IDT_COMBO, m, m, xc, 8 + COMBOBOX IDC_COMBO, m, 20, xc, 65, MY_COMBO_WITH_EDIT OK_CANCEL } + +#undef xc +#undef yc diff --git a/CPP/7zip/UI/FileManager/ComboDialogRes.h b/CPP/7zip/UI/FileManager/ComboDialogRes.h old mode 100755 new mode 100644 index 7f37cb93..a044797e --- a/CPP/7zip/UI/FileManager/ComboDialogRes.h +++ b/CPP/7zip/UI/FileManager/ComboDialogRes.h @@ -1,4 +1,4 @@ -#define IDD_DIALOG_COMBO 505 +#define IDD_COMBO 98 -#define IDC_COMBO_STATIC 1000 -#define IDC_COMBO_COMBO 1001 +#define IDT_COMBO 100 +#define IDC_COMBO 101 diff --git a/CPP/7zip/UI/FileManager/Copy.bmp b/CPP/7zip/UI/FileManager/Copy.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/Copy2.bmp b/CPP/7zip/UI/FileManager/Copy2.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/CopyDialog.cpp b/CPP/7zip/UI/FileManager/CopyDialog.cpp old mode 100755 new mode 100644 index 8cbaf41f..76441215 --- a/CPP/7zip/UI/FileManager/CopyDialog.cpp +++ b/CPP/7zip/UI/FileManager/CopyDialog.cpp @@ -2,9 +2,9 @@ #include "StdAfx.h" -#include "Windows/FileName.h" +#include "../../../Windows/FileName.h" -#include "Windows/Control/Static.h" +#include "../../../Windows/Control/Static.h" #include "BrowseDialog.h" #include "CopyDialog.h" @@ -15,33 +15,25 @@ using namespace NWindows; -#ifdef LANG -static CIDLangPair kIDLangPairs[] = -{ - { IDOK, 0x02000702 }, - { IDCANCEL, 0x02000710 } -}; -#endif - bool CCopyDialog::OnInit() { #ifdef LANG - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, NULL, 0); #endif - _path.Attach(GetItem(IDC_COPY_COMBO)); + _path.Attach(GetItem(IDC_COPY)); SetText(Title); NControl::CStatic staticContol; - staticContol.Attach(GetItem(IDC_COPY_STATIC)); + staticContol.Attach(GetItem(IDT_COPY)); staticContol.SetText(Static); #ifdef UNDER_CE // we do it, since WinCE selects Value\something instead of Value !!!! _path.AddString(Value); #endif - for (int i = 0; i < Strings.Size(); i++) + FOR_VECTOR (i, Strings) _path.AddString(Strings[i]); _path.SetText(Value); - SetItemText(IDC_COPY_INFO, Info); + SetItemText(IDT_COPY_INFO, Info); NormalizeSize(true); return CModalDialog::OnInit(); } @@ -59,19 +51,19 @@ bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) InvalidateRect(NULL); { - RECT rect; - GetClientRectOfItem(IDC_COPY_SET_PATH, rect); - int bx = rect.right - rect.left; - MoveItem(IDC_COPY_SET_PATH, xSize - mx - bx, rect.top, bx, rect.bottom - rect.top); + RECT r; + GetClientRectOfItem(IDB_COPY_SET_PATH, r); + int bx = RECT_SIZE_X(r); + MoveItem(IDB_COPY_SET_PATH, xSize - mx - bx, r.top, bx, RECT_SIZE_Y(r)); ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx); } { - RECT rect; - GetClientRectOfItem(IDC_COPY_INFO, rect); + RECT r; + GetClientRectOfItem(IDT_COPY_INFO, r); NControl::CStatic staticContol; - staticContol.Attach(GetItem(IDC_COPY_INFO)); - int yPos = rect.top; + staticContol.Attach(GetItem(IDT_COPY_INFO)); + int yPos = r.top; staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos); } @@ -85,7 +77,7 @@ bool CCopyDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { - case IDC_COPY_SET_PATH: + case IDB_COPY_SET_PATH: OnButtonSetPath(); return true; } @@ -97,10 +89,10 @@ void CCopyDialog::OnButtonSetPath() UString currentPath; _path.GetText(currentPath); - UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209); + const UString title = LangString(IDS_SET_FOLDER); UString resultPath; - if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (!MyBrowseForFolder(*this, title, currentPath, resultPath)) return; NFile::NName::NormalizeDirPathPrefix(resultPath); _path.SetCurSel(-1); diff --git a/CPP/7zip/UI/FileManager/CopyDialog.h b/CPP/7zip/UI/FileManager/CopyDialog.h old mode 100755 new mode 100644 index 2c22d700..30fde71f --- a/CPP/7zip/UI/FileManager/CopyDialog.h +++ b/CPP/7zip/UI/FileManager/CopyDialog.h @@ -3,8 +3,8 @@ #ifndef __COPY_DIALOG_H #define __COPY_DIALOG_H -#include "Windows/Control/ComboBox.h" -#include "Windows/Control/Dialog.h" +#include "../../../Windows/Control/ComboBox.h" +#include "../../../Windows/Control/Dialog.h" #include "CopyDialogRes.h" @@ -25,7 +25,7 @@ public: UString Info; UStringVector Strings; - INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_COPY, parentWindow); } + INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_COPY, parentWindow); } }; #endif diff --git a/CPP/7zip/UI/FileManager/CopyDialog.rc b/CPP/7zip/UI/FileManager/CopyDialog.rc old mode 100755 new mode 100644 index 922dddc4..73d3ea80 --- a/CPP/7zip/UI/FileManager/CopyDialog.rc +++ b/CPP/7zip/UI/FileManager/CopyDialog.rc @@ -6,12 +6,15 @@ #define y 40 -IDD_DIALOG_COPY MY_RESIZE_DIALOG +IDD_COPY DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT CAPTION "Copy" { - LTEXT "", IDC_COPY_STATIC, m, m, xc, 8 - COMBOBOX IDC_COPY_COMBO, m, 20, xc - bxsDots - m, 65, MY_COMBO_WITH_EDIT - PUSHBUTTON "...", IDC_COPY_SET_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP - LTEXT "", IDC_COPY_INFO, m, y, xc, by - y - 1, SS_NOPREFIX | SS_LEFTNOWORDWRAP + LTEXT "", IDT_COPY, m, m, xc, 8 + COMBOBOX IDC_COPY, m, 20, xc - bxsDots - m, 65, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDB_COPY_SET_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP + LTEXT "", IDT_COPY_INFO, m, y, xc, by - y - 1, SS_NOPREFIX | SS_LEFTNOWORDWRAP OK_CANCEL } + +#undef xc +#undef yc diff --git a/CPP/7zip/UI/FileManager/CopyDialogRes.h b/CPP/7zip/UI/FileManager/CopyDialogRes.h old mode 100755 new mode 100644 index 4944de84..85f5a39a --- a/CPP/7zip/UI/FileManager/CopyDialogRes.h +++ b/CPP/7zip/UI/FileManager/CopyDialogRes.h @@ -1,8 +1,8 @@ -#define IDD_DIALOG_COPY 506 +#define IDD_COPY 96 -#define IDC_COPY_STATIC 1000 -#define IDC_COPY_COMBO 1001 -#define IDC_COPY_SET_PATH 1002 -#define IDC_COPY_INFO 1003 +#define IDT_COPY 100 +#define IDC_COPY 101 +#define IDB_COPY_SET_PATH 102 +#define IDT_COPY_INFO 103 -#define IDS_SET_FOLDER 210 +#define IDS_SET_FOLDER 6007 diff --git a/CPP/7zip/UI/FileManager/Delete.bmp b/CPP/7zip/UI/FileManager/Delete.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/Delete2.bmp b/CPP/7zip/UI/FileManager/Delete2.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/DialogSize.h b/CPP/7zip/UI/FileManager/DialogSize.h old mode 100755 new mode 100644 index f4dd1c32..504541bd --- a/CPP/7zip/UI/FileManager/DialogSize.h +++ b/CPP/7zip/UI/FileManager/DialogSize.h @@ -3,7 +3,7 @@ #ifndef __DIALOG_SIZE_H #define __DIALOG_SIZE_H -#include "Windows/Control/Dialog.h" +#include "../../../Windows/Control/Dialog.h" #ifdef UNDER_CE #define BIG_DIALOG_SIZE(x, y) bool isBig = NWindows::NControl::IsDialogSizeOK(x, y); diff --git a/CPP/7zip/UI/FileManager/EditPage.cpp b/CPP/7zip/UI/FileManager/EditPage.cpp old mode 100755 new mode 100644 index 3b38a3a5..627088b9 --- a/CPP/7zip/UI/FileManager/EditPage.cpp +++ b/CPP/7zip/UI/FileManager/EditPage.cpp @@ -12,24 +12,36 @@ using namespace NWindows; -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_EDIT_STATIC_EDITOR, 0x03010201}, - { IDC_EDIT_STATIC_DIFF, 0x03010202} + IDT_EDIT_EDITOR, + IDT_EDIT_DIFF +}; + +static const UInt32 kLangIDs_Colon[] = +{ + IDT_EDIT_VIEWER }; static LPCWSTR kEditTopic = L"FM/options.htm#editor"; bool CEditPage::OnInit() { - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); + LangSetDlgItems_Colon(*this, kLangIDs_Colon, ARRAY_SIZE(kLangIDs_Colon)); - _editor.Attach(GetItem(IDC_EDIT_EDIT_EDITOR)); - _diff.Attach(GetItem(IDC_EDIT_EDIT_DIFF)); + _viewer.Attach(GetItem(IDE_EDIT_VIEWER)); + _editor.Attach(GetItem(IDE_EDIT_EDITOR)); + _diff.Attach(GetItem(IDE_EDIT_DIFF)); { UString path; - ReadRegEditor(path); + ReadRegEditor(false, path); + _viewer.SetText(path); + } + { + UString path; + ReadRegEditor(true, path); _editor.SetText(path); } { @@ -42,10 +54,15 @@ bool CEditPage::OnInit() LONG CEditPage::OnApply() { + { + UString path; + _viewer.GetText(path); + SaveRegEditor(false, path); + } { UString path; _editor.GetText(path); - SaveRegEditor(path); + SaveRegEditor(true, path); } { UString path; @@ -65,7 +82,7 @@ static void Edit_BrowseForFile(NWindows::NControl::CEdit &edit, HWND hwnd) UString path; edit.GetText(path); UString resPath; - if (MyBrowseForFile(hwnd, 0, path, L"*.exe", resPath)) + if (MyBrowseForFile(hwnd, 0, path, NULL, L"*.exe", resPath)) { edit.SetText(resPath); // Changed(); @@ -76,21 +93,19 @@ bool CEditPage::OnButtonClicked(int buttonID, HWND buttonHWND) { switch (buttonID) { - case IDC_EDIT_BUTTON_EDITOR: - Edit_BrowseForFile(_editor, *this); - return true; - case IDC_EDIT_BUTTON_DIFF: - Edit_BrowseForFile(_diff, *this); - return true; + case IDB_EDIT_VIEWER: Edit_BrowseForFile(_viewer, *this); return true; + case IDB_EDIT_EDITOR: Edit_BrowseForFile(_editor, *this); return true; + case IDB_EDIT_DIFF: Edit_BrowseForFile(_diff, *this); return true; } return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); } bool CEditPage::OnCommand(int code, int itemID, LPARAM param) { - if (code == EN_CHANGE && - (itemID == IDC_EDIT_EDIT_EDITOR || - itemID == IDC_EDIT_EDIT_DIFF)) + if (code == EN_CHANGE && ( + itemID == IDE_EDIT_VIEWER || + itemID == IDE_EDIT_EDITOR || + itemID == IDE_EDIT_DIFF)) { Changed(); return true; diff --git a/CPP/7zip/UI/FileManager/EditPage.h b/CPP/7zip/UI/FileManager/EditPage.h old mode 100755 new mode 100644 index fbe3c23c..c11e613b --- a/CPP/7zip/UI/FileManager/EditPage.h +++ b/CPP/7zip/UI/FileManager/EditPage.h @@ -3,11 +3,12 @@ #ifndef __EDIT_PAGE_H #define __EDIT_PAGE_H -#include "Windows/Control/PropertyPage.h" -#include "Windows/Control/Edit.h" +#include "../../../Windows/Control/PropertyPage.h" +#include "../../../Windows/Control/Edit.h" class CEditPage: public NWindows::NControl::CPropertyPage { + NWindows::NControl::CEdit _viewer; NWindows::NControl::CEdit _editor; NWindows::NControl::CEdit _diff; public: diff --git a/CPP/7zip/UI/FileManager/EditPage.rc b/CPP/7zip/UI/FileManager/EditPage.rc old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/EditPage2.rc b/CPP/7zip/UI/FileManager/EditPage2.rc old mode 100755 new mode 100644 index 6b500d27..2d6554fb --- a/CPP/7zip/UI/FileManager/EditPage2.rc +++ b/CPP/7zip/UI/FileManager/EditPage2.rc @@ -1,9 +1,14 @@ CAPTION "Editor" { - LTEXT "&Editor:", IDC_EDIT_STATIC_EDITOR, m, m, xc, 8 - EDITTEXT IDC_EDIT_EDIT_EDITOR, m, 20, xc - m - bxsDots, 14, ES_AUTOHSCROLL - PUSHBUTTON "...", IDC_EDIT_BUTTON_EDITOR, xs - m - bxsDots, 19, bxsDots, bys - LTEXT "&Diff:", IDC_EDIT_STATIC_DIFF, m, 40, xc, 8 - EDITTEXT IDC_EDIT_EDIT_DIFF, m, 52, xc - m - bxsDots, 14, ES_AUTOHSCROLL - PUSHBUTTON "...", IDC_EDIT_BUTTON_DIFF, xs - m - bxsDots, 51, bxsDots, bys + LTEXT "&View:", IDT_EDIT_VIEWER, m, m, xc, 8 + EDITTEXT IDE_EDIT_VIEWER, m, m + 12, xc - m - bxsDots, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDB_EDIT_VIEWER, xs - m - bxsDots, m + 11, bxsDots, bys + + LTEXT "&Editor:", IDT_EDIT_EDITOR, m, m + 32, xc, 8 + EDITTEXT IDE_EDIT_EDITOR, m, m + 44, xc - m - bxsDots, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDB_EDIT_EDITOR, xs - m - bxsDots, m + 43, bxsDots, bys + + LTEXT "&Diff:", IDT_EDIT_DIFF, m, m + 64, xc, 8 + EDITTEXT IDE_EDIT_DIFF, m, m + 76, xc - m - bxsDots, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDB_EDIT_DIFF, xs - m - bxsDots, m + 75, bxsDots, bys } diff --git a/CPP/7zip/UI/FileManager/EditPageRes.h b/CPP/7zip/UI/FileManager/EditPageRes.h old mode 100755 new mode 100644 index 3b958311..017d7024 --- a/CPP/7zip/UI/FileManager/EditPageRes.h +++ b/CPP/7zip/UI/FileManager/EditPageRes.h @@ -1,10 +1,15 @@ -#define IDD_EDIT 542 -#define IDD_EDIT_2 642 +#define IDD_EDIT 2103 +#define IDD_EDIT_2 12103 -#define IDC_EDIT_STATIC_EDITOR 1000 -#define IDC_EDIT_EDIT_EDITOR 1001 -#define IDC_EDIT_BUTTON_EDITOR 1002 +#define IDT_EDIT_VIEWER 543 +#define IDT_EDIT_EDITOR 2104 +#define IDT_EDIT_DIFF 2105 -#define IDC_EDIT_STATIC_DIFF 1010 -#define IDC_EDIT_EDIT_DIFF 1011 -#define IDC_EDIT_BUTTON_DIFF 1012 +#define IDE_EDIT_VIEWER 100 +#define IDB_EDIT_VIEWER 101 + +#define IDE_EDIT_EDITOR 102 +#define IDB_EDIT_EDITOR 103 + +#define IDE_EDIT_DIFF 104 +#define IDB_EDIT_DIFF 105 diff --git a/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp b/CPP/7zip/UI/FileManager/EnumFormatEtc.cpp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/EnumFormatEtc.h b/CPP/7zip/UI/FileManager/EnumFormatEtc.h old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/Extract.bmp b/CPP/7zip/UI/FileManager/Extract.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/Extract2.bmp b/CPP/7zip/UI/FileManager/Extract2.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.cpp b/CPP/7zip/UI/FileManager/ExtractCallback.cpp old mode 100755 new mode 100644 index 90076ebb..ed4bb884 --- a/CPP/7zip/UI/FileManager/ExtractCallback.cpp +++ b/CPP/7zip/UI/FileManager/ExtractCallback.cpp @@ -2,13 +2,20 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" -#include "Windows/Error.h" -#include "Windows/FileDir.h" -#include "Windows/FileFind.h" +#include "../../../Common/ComTry.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/Lang.h" +#include "../../../Common/StringConvert.h" + +#include "../../../Windows/ErrorMsg.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/FileFind.h" +#include "../../../Windows/PropVariantConv.h" #include "../../Common/FilePathAutoRename.h" +#include "../../Common/StreamUtils.h" +#include "../Common/ExtractingFilePath.h" #ifndef _SFX #include "../Common/ZipRegistry.h" @@ -18,6 +25,7 @@ #include "ExtractCallback.h" #include "FormatUtils.h" +#include "LangUtils.h" #include "OverwriteDialog.h" #ifndef _NO_CRYPTO #include "PasswordDialog.h" @@ -39,12 +47,14 @@ void CExtractCallbackImp::Init() #endif } -void CExtractCallbackImp::AddErrorMessage(LPCWSTR message) +void CExtractCallbackImp::AddError_Message(LPCWSTR s) { ThereAreMessageErrors = true; - ProgressDialog->Sync.AddErrorMessage(message); + ProgressDialog->Sync.AddError_Message(s); } +#ifndef _SFX + STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 #ifndef _SFX numFiles @@ -52,28 +62,27 @@ STDMETHODIMP CExtractCallbackImp::SetNumFiles(UInt64 ) { #ifndef _SFX - ProgressDialog->Sync.SetNumFilesTotal(numFiles); + ProgressDialog->Sync.Set_NumFilesTotal(numFiles); #endif return S_OK; } +#endif + STDMETHODIMP CExtractCallbackImp::SetTotal(UInt64 total) { - ProgressDialog->Sync.SetProgress(total, 0); + ProgressDialog->Sync.Set_NumBytesTotal(total); return S_OK; } STDMETHODIMP CExtractCallbackImp::SetCompleted(const UInt64 *value) { - RINOK(ProgressDialog->Sync.ProcessStopAndPause()); - if (value != NULL) - ProgressDialog->Sync.SetPos(*value); - return S_OK; + return ProgressDialog->Sync.Set_NumBytesCur(value); } HRESULT CExtractCallbackImp::Open_CheckBreak() { - return ProgressDialog->Sync.ProcessStopAndPause(); + return ProgressDialog->Sync.CheckStop(); } HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) @@ -84,9 +93,8 @@ HRESULT CExtractCallbackImp::Open_SetTotal(const UInt64 * /* numFiles */, const HRESULT CExtractCallbackImp::Open_SetCompleted(const UInt64 * /* numFiles */, const UInt64 * /* numBytes */) { - RINOK(ProgressDialog->Sync.ProcessStopAndPause()); // if (numFiles != NULL) ProgressDialog->Sync.SetNumFilesCur(*numFiles); - return S_OK; + return ProgressDialog->Sync.CheckStop(); } #ifndef _NO_CRYPTO @@ -96,10 +104,10 @@ HRESULT CExtractCallbackImp::Open_CryptoGetTextPassword(BSTR *password) return CryptoGetTextPassword(password); } -HRESULT CExtractCallbackImp::Open_GetPasswordIfAny(UString &password) +HRESULT CExtractCallbackImp::Open_GetPasswordIfAny(bool &passwordIsDefined, UString &password) { - if (PasswordIsDefined) - password = Password; + passwordIsDefined = PasswordIsDefined; + password = Password; return S_OK; } @@ -119,7 +127,7 @@ void CExtractCallbackImp::Open_ClearPasswordWasAskedFlag() #ifndef _SFX STDMETHODIMP CExtractCallbackImp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) { - ProgressDialog->Sync.SetRatioInfo(inSize, outSize); + ProgressDialog->Sync.Set_Ratio(inSize, outSize); return S_OK; } #endif @@ -157,14 +165,14 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite( ProgressDialog->WaitCreating(); INT_PTR writeAnswer = dialog.Create(*ProgressDialog); - switch(writeAnswer) + switch (writeAnswer) { - case IDCANCEL: *answer = NOverwriteAnswer::kCancel; return E_ABORT; - case IDYES: *answer = NOverwriteAnswer::kYes; break; - case IDNO: *answer = NOverwriteAnswer::kNo; break; - case IDC_BUTTON_OVERWRITE_YES_TO_ALL: *answer = NOverwriteAnswer::kYesToAll; break; - case IDC_BUTTON_OVERWRITE_NO_TO_ALL: *answer = NOverwriteAnswer::kNoToAll; break; - case IDC_BUTTON_OVERWRITE_AUTO_RENAME: *answer = NOverwriteAnswer::kAutoRename; break; + case IDCANCEL: *answer = NOverwriteAnswer::kCancel; return E_ABORT; + case IDYES: *answer = NOverwriteAnswer::kYes; break; + case IDNO: *answer = NOverwriteAnswer::kNo; break; + case IDB_YES_TO_ALL: *answer = NOverwriteAnswer::kYesToAll; break; + case IDB_NO_TO_ALL: *answer = NOverwriteAnswer::kNoToAll; break; + case IDB_AUTO_RENAME: *answer = NOverwriteAnswer::kAutoRename; break; default: return E_FAIL; } return S_OK; @@ -177,75 +185,136 @@ STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, bool isF return SetCurrentFilePath2(name); } -STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message) +STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *s) { - AddErrorMessage(message); + AddError_Message(s); return S_OK; } HRESULT CExtractCallbackImp::MessageError(const char *message, const FString &path) { - return MessageError(GetUnicodeString(message) + fs2us(path)); + ThereAreMessageErrors = true; + ProgressDialog->Sync.AddError_Message_Name(GetUnicodeString(message), fs2us(path)); + return S_OK; } -STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *message) +#ifndef _SFX + +STDMETHODIMP CExtractCallbackImp::ShowMessage(const wchar_t *s) { - AddErrorMessage(message); + AddError_Message(s); return S_OK; } -STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool encrypted) +#endif + +STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 opRes, bool encrypted) { - switch(operationResult) + switch (opRes) { case NArchive::NExtract::NOperationResult::kOK: break; default: { - UINT messageID; - UInt32 langID; - switch(operationResult) + UINT messageID = 0; + UINT id = 0; + + switch (opRes) { - case NArchive::NExtract::NOperationResult::kUnSupportedMethod: - messageID = IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_UNSUPPORTED_METHOD; - langID = 0x02000A91; + case NArchive::NExtract::NOperationResult::kUnsupportedMethod: + messageID = IDS_EXTRACT_MESSAGE_UNSUPPORTED_METHOD; + id = IDS_EXTRACT_MSG_UNSUPPORTED_METHOD; break; case NArchive::NExtract::NOperationResult::kDataError: messageID = encrypted ? - IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED: - IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_DATA_ERROR; - langID = encrypted ? 0x02000A94 : 0x02000A92; + IDS_EXTRACT_MESSAGE_DATA_ERROR_ENCRYPTED: + IDS_EXTRACT_MESSAGE_DATA_ERROR; + id = IDS_EXTRACT_MSG_DATA_ERROR; break; case NArchive::NExtract::NOperationResult::kCRCError: messageID = encrypted ? - IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC_ENCRYPTED: - IDS_MESSAGES_DIALOG_EXTRACT_MESSAGE_CRC; - langID = encrypted ? 0x02000A95 : 0x02000A93; + IDS_EXTRACT_MESSAGE_CRC_ERROR_ENCRYPTED: + IDS_EXTRACT_MESSAGE_CRC_ERROR; + id = IDS_EXTRACT_MSG_CRC_ERROR; + break; + case NArchive::NExtract::NOperationResult::kUnavailable: + id = IDS_EXTRACT_MSG_UNAVAILABLE_DATA; + break; + case NArchive::NExtract::NOperationResult::kUnexpectedEnd: + id = IDS_EXTRACT_MSG_UEXPECTED_END; break; + case NArchive::NExtract::NOperationResult::kDataAfterEnd: + id = IDS_EXTRACT_MSG_DATA_AFTER_END; + break; + case NArchive::NExtract::NOperationResult::kIsNotArc: + id = IDS_EXTRACT_MSG_IS_NOT_ARC; + break; + case NArchive::NExtract::NOperationResult::kHeadersError: + id = IDS_EXTRACT_MSG_HEADERS_ERROR; + break; + /* default: - return E_FAIL; + messageID = IDS_EXTRACT_MESSAGE_UNKNOWN_ERROR; + break; + */ } if (_needWriteArchivePath) { if (!_currentArchivePath.IsEmpty()) - AddErrorMessage(_currentArchivePath); + AddError_Message(_currentArchivePath); _needWriteArchivePath = false; } - AddErrorMessage( - MyFormatNew(messageID, - #ifdef LANG - langID, - #endif - _currentFilePath)); + + UString msg; + UString msgOld; + + #ifndef _SFX + if (id != 0) + LangString_OnlyFromLangFile(id, msg); + if (messageID != 0 && msg.IsEmpty()) + LangString_OnlyFromLangFile(messageID, msgOld); + #endif + + UString s; + if (msg.IsEmpty() && !msgOld.IsEmpty()) + s = MyFormatNew(msgOld, _currentFilePath); + else + { + if (msg.IsEmpty()) + LangString(id, msg); + if (!msg.IsEmpty()) + s += msg; + else + { + wchar_t temp[16]; + ConvertUInt32ToString(opRes, temp); + s += L"Error #"; + s += temp; + } + + if (encrypted) + { + // s += L" : "; + // s += LangString(IDS_EXTRACT_MSG_ENCRYPTED); + s += L" : "; + s += LangString(IDS_EXTRACT_MSG_WRONG_PSW); + } + s += L" : "; + s += _currentFilePath; + } + + AddError_Message(s); } } + #ifndef _SFX if (_isFolder) NumFolders++; else NumFiles++; - ProgressDialog->Sync.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.Set_NumFilesCur(NumFiles); #endif + return S_OK; } @@ -255,7 +324,8 @@ STDMETHODIMP CExtractCallbackImp::SetOperationResult(Int32 operationResult, bool HRESULT CExtractCallbackImp::BeforeOpen(const wchar_t *name) { #ifndef _SFX - ProgressDialog->Sync.SetTitleFileName(name); + RINOK(ProgressDialog->Sync.CheckStop()); + ProgressDialog->Sync.Set_TitleFileName(name); #endif _currentArchivePath = name; return S_OK; @@ -265,58 +335,157 @@ HRESULT CExtractCallbackImp::SetCurrentFilePath2(const wchar_t *path) { _currentFilePath = path; #ifndef _SFX - ProgressDialog->Sync.SetCurrentFileName(path); + ProgressDialog->Sync.Set_FilePath(path); #endif return S_OK; } +#ifndef _SFX + HRESULT CExtractCallbackImp::SetCurrentFilePath(const wchar_t *path) { #ifndef _SFX if (NeedAddFile) NumFiles++; NeedAddFile = true; - ProgressDialog->Sync.SetNumFilesCur(NumFiles); + ProgressDialog->Sync.Set_NumFilesCur(NumFiles); #endif return SetCurrentFilePath2(path); } +#endif + +UString HResultToMessage(HRESULT errorCode); + HRESULT CExtractCallbackImp::OpenResult(const wchar_t *name, HRESULT result, bool encrypted) { if (result != S_OK) { - UString message; + UString s; if (result == S_FALSE) - { - message = MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE, - #ifdef LANG - (encrypted ? 0x0200060A : 0x02000609), - #endif - name); - } + s = MyFormatNew(encrypted ? IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : IDS_CANT_OPEN_ARCHIVE, name); else { - message = name; - message += L": "; - UString message2; - if (result == E_OUTOFMEMORY) - message2 = - #ifdef LANG - LangString(IDS_MEM_ERROR, 0x0200060B); - #else - MyLoadStringW(IDS_MEM_ERROR); - #endif - else - message2 = NError::MyFormatMessageW(result); - message += message2; + s = name; + s += L": "; + s += HResultToMessage(result); } - MessageError(message); + MessageError(s); NumArchiveErrors++; } _currentArchivePath = name; _needWriteArchivePath = true; return S_OK; } + +static const UInt32 k_ErrorFlagsIds[] = +{ + IDS_EXTRACT_MSG_IS_NOT_ARC, + IDS_EXTRACT_MSG_HEADERS_ERROR, + IDS_EXTRACT_MSG_HEADERS_ERROR, + IDS_OPEN_MSG_UNAVAILABLE_START, + IDS_OPEN_MSG_UNCONFIRMED_START, + IDS_EXTRACT_MSG_UEXPECTED_END, + IDS_EXTRACT_MSG_DATA_AFTER_END, + IDS_EXTRACT_MSG_UNSUPPORTED_METHOD, + IDS_OPEN_MSG_UNSUPPORTED_FEATURE, + IDS_EXTRACT_MSG_DATA_ERROR, + IDS_EXTRACT_MSG_CRC_ERROR +}; + +UString GetOpenArcErrorMessage(UInt32 errorFlags) +{ + UString s; + for (unsigned i = 0; i < ARRAY_SIZE(k_ErrorFlagsIds); i++) + { + UInt32 f = ((UInt32)1 << i); + if ((errorFlags & f) == 0) + continue; + UInt32 id = k_ErrorFlagsIds[i]; + UString m = LangString(id); + if (m.IsEmpty()) + continue; + if (f == kpv_ErrorFlags_EncryptedHeadersError) + { + m += L" : "; + m += LangString(IDS_EXTRACT_MSG_WRONG_PSW); + } + if (!s.IsEmpty()) + s += L'\n'; + s += m; + errorFlags &= ~f; + } + if (errorFlags != 0) + { + char sz[16]; + sz[0] = '0'; + sz[1] = 'x'; + ConvertUInt32ToHex(errorFlags, sz + 2); + if (!s.IsEmpty()) + s += L'\n'; + s += GetUnicodeString(AString(sz)); + } + return s; +} + +HRESULT CExtractCallbackImp::SetError(int level, const wchar_t *name, + UInt32 errorFlags, const wchar_t *errors, + UInt32 warningFlags, const wchar_t *warnings) +{ + NumArchiveErrors++; + + if (_needWriteArchivePath) + { + if (!_currentArchivePath.IsEmpty()) + AddError_Message(_currentArchivePath); + _needWriteArchivePath = false; + } + + if (level != 0) + { + UString s; + s += name; + s += L": "; + MessageError(s); + } + + if (errorFlags != 0) + MessageError(GetOpenArcErrorMessage(errorFlags)); + + if (errors && wcslen(errors) != 0) + MessageError(errors); + + if (warningFlags != 0) + MessageError((UString)L"Warnings: " + GetOpenArcErrorMessage(warningFlags)); + + if (warnings && wcslen(warnings) != 0) + MessageError((UString)L"Warnings: " + warnings); + + return S_OK; +} + +HRESULT CExtractCallbackImp::OpenTypeWarning(const wchar_t *name, const wchar_t *okType, const wchar_t *errorType) +{ + UString s = L"Warning:\n"; + s += name; + s += L"\n"; + if (wcscmp(okType, errorType) == 0) + { + s += L"The archive is open with offset"; + } + else + { + s += L"Can not open the file as ["; + s += errorType; + s += L"] archive\n"; + s += L"The file is open as ["; + s += okType; + s += L"] archive"; + } + MessageError(s); + NumArchiveErrors++; + return S_OK; +} HRESULT CExtractCallbackImp::ThereAreNoFiles() { @@ -331,7 +500,7 @@ HRESULT CExtractCallbackImp::ExtractResult(HRESULT result) if (result == E_ABORT || result == ERROR_DISK_FULL) return result; MessageError(_currentFilePath); - MessageError(NError::MyFormatMessageW(result)); + MessageError(NError::MyFormatMessage(result)); return S_OK; } @@ -355,7 +524,7 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) dialog.ShowPassword = showPassword; #endif ProgressDialog->WaitCreating(); - if (dialog.Create(*ProgressDialog) == IDCANCEL) + if (dialog.Create(*ProgressDialog) != IDOK) return E_ABORT; Password = dialog.Password; PasswordIsDefined = true; @@ -369,7 +538,8 @@ STDMETHODIMP CExtractCallbackImp::CryptoGetTextPassword(BSTR *password) #endif -// IExtractCallBack3 +#ifndef _SFX + STDMETHODIMP CExtractCallbackImp::AskWrite( const wchar_t *srcPath, Int32 srcIsFolder, const FILETIME *srcTime, const UInt64 *srcSize, @@ -384,10 +554,10 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( *destPathResult = 0; *writeAnswer = BoolToInt(false); - UString destPathSpec = destPath; FString destPathSys = us2fs(destPath); bool srcIsFolderSpec = IntToBool(srcIsFolder); CFileInfo destFileInfo; + if (destFileInfo.Find(destPathSys)) { if (srcIsFolderSpec) @@ -400,48 +570,51 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( *writeAnswer = BoolToInt(false); return S_OK; } + if (destFileInfo.IsDir()) { RINOK(MessageError("can not replace folder with file with same name: ", destPathSys)); return E_FAIL; } - switch(OverwriteMode) + switch (OverwriteMode) { - case NExtract::NOverwriteMode::kSkipExisting: + case NExtract::NOverwriteMode::kSkip: return S_OK; - case NExtract::NOverwriteMode::kAskBefore: + case NExtract::NOverwriteMode::kAsk: { Int32 overwiteResult; + UString destPathSpec = destPath; + int slashPos = destPathSpec.ReverseFind(L'/'); + #ifdef _WIN32 + int slash1Pos = destPathSpec.ReverseFind(L'\\'); + slashPos = MyMax(slashPos, slash1Pos); + #endif + destPathSpec.DeleteFrom(slashPos + 1); + destPathSpec += fs2us(destFileInfo.Name); + RINOK(AskOverwrite( destPathSpec, &destFileInfo.MTime, &destFileInfo.Size, srcPath, srcTime, srcSize, &overwiteResult)); - switch(overwiteResult) + + switch (overwiteResult) { - case NOverwriteAnswer::kCancel: - return E_ABORT; - case NOverwriteAnswer::kNo: - return S_OK; - case NOverwriteAnswer::kNoToAll: - OverwriteMode = NExtract::NOverwriteMode::kSkipExisting; - return S_OK; - case NOverwriteAnswer::kYesToAll: - OverwriteMode = NExtract::NOverwriteMode::kWithoutPrompt; - break; - case NOverwriteAnswer::kYes: - break; - case NOverwriteAnswer::kAutoRename: - OverwriteMode = NExtract::NOverwriteMode::kAutoRename; - break; + case NOverwriteAnswer::kCancel: return E_ABORT; + case NOverwriteAnswer::kNo: return S_OK; + case NOverwriteAnswer::kNoToAll: OverwriteMode = NExtract::NOverwriteMode::kSkip; return S_OK; + case NOverwriteAnswer::kYes: break; + case NOverwriteAnswer::kYesToAll: OverwriteMode = NExtract::NOverwriteMode::kOverwrite; break; + case NOverwriteAnswer::kAutoRename: OverwriteMode = NExtract::NOverwriteMode::kRename; break; default: return E_FAIL; } } } - if (OverwriteMode == NExtract::NOverwriteMode::kAutoRename) + + if (OverwriteMode == NExtract::NOverwriteMode::kRename) { if (!AutoRenamePath(destPathSys)) { @@ -451,7 +624,7 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( destPathResultTemp = fs2us(destPathSys); } else - if (!NFile::NDirectory::DeleteFileAlways(destPathSys)) + if (!NDir::DeleteFileAlways(destPathSys)) { RINOK(MessageError("can not delete output file: ", destPathSys)); return E_ABORT; @@ -460,3 +633,266 @@ STDMETHODIMP CExtractCallbackImp::AskWrite( *writeAnswer = BoolToInt(true); return StringToBstr(destPathResultTemp, destPathResult); } + + +STDMETHODIMP CExtractCallbackImp::UseExtractToStream(Int32 *res) +{ + *res = BoolToInt(StreamMode); + return S_OK; +} + +static HRESULT GetTime(IGetProp *getProp, PROPID propID, FILETIME &ft, bool &ftDefined) +{ + ftDefined = false; + NCOM::CPropVariant prop; + RINOK(getProp->GetProp(propID, &prop)); + if (prop.vt == VT_FILETIME) + { + ft = prop.filetime; + ftDefined = (ft.dwHighDateTime != 0 || ft.dwLowDateTime != 0); + } + else if (prop.vt != VT_EMPTY) + return E_FAIL; + return S_OK; +} + + +static HRESULT GetItemBoolProp(IGetProp *getProp, PROPID propID, bool &result) +{ + NCOM::CPropVariant prop; + result = false; + RINOK(getProp->GetProp(propID, &prop)); + if (prop.vt == VT_BOOL) + result = VARIANT_BOOLToBool(prop.boolVal); + else if (prop.vt != VT_EMPTY) + return E_FAIL; + return S_OK; +} + + +STDMETHODIMP CExtractCallbackImp::GetStream7(const wchar_t *name, + Int32 isDir, + ISequentialOutStream **outStream, Int32 askExtractMode, + IGetProp *getProp) +{ + COM_TRY_BEGIN + *outStream = 0; + _newVirtFileWasAdded = false; + _hashStreamWasUsed = false; + _needUpdateStat = false; + + if (_hashStream) + _hashStreamSpec->ReleaseStream(); + + GetItemBoolProp(getProp, kpidIsAltStream, _isAltStream); + + if (!ProcessAltStreams && _isAltStream) + return S_OK; + + _filePath = name; + _isFolder = IntToBool(isDir); + _curSize = 0; + _curSizeDefined = false; + + UInt64 size = 0; + bool sizeDefined; + { + NCOM::CPropVariant prop; + RINOK(getProp->GetProp(kpidSize, &prop)); + sizeDefined = ConvertPropVariantToUInt64(prop, size); + } + + if (sizeDefined) + { + _curSize = size; + _curSizeDefined = true; + } + + if (askExtractMode != NArchive::NExtract::NAskMode::kExtract && + askExtractMode != NArchive::NExtract::NAskMode::kTest) + return S_OK; + + _needUpdateStat = true; + + CMyComPtr outStreamLoc; + + if (VirtFileSystem && askExtractMode == NArchive::NExtract::NAskMode::kExtract) + { + CVirtFile &file = VirtFileSystemSpec->AddNewFile(); + _newVirtFileWasAdded = true; + file.Name = name; + file.IsDir = IntToBool(isDir); + file.IsAltStream = _isAltStream; + file.Size = 0; + + RINOK(GetTime(getProp, kpidCTime, file.CTime, file.CTimeDefined)); + RINOK(GetTime(getProp, kpidATime, file.ATime, file.ATimeDefined)); + RINOK(GetTime(getProp, kpidMTime, file.MTime, file.MTimeDefined)); + + NCOM::CPropVariant prop; + RINOK(getProp->GetProp(kpidAttrib, &prop)); + if (prop.vt == VT_UI4) + { + file.Attrib = prop.ulVal; + file.AttribDefined = true; + } + // else if (isDir) file.Attrib = FILE_ATTRIBUTE_DIRECTORY; + + file.ExpectedSize = 0; + if (sizeDefined) + file.ExpectedSize = size; + outStreamLoc = VirtFileSystem; + } + + if (_hashStream) + { + { + _hashStreamSpec->SetStream(outStreamLoc); + outStreamLoc = _hashStream; + _hashStreamSpec->Init(true); + _hashStreamWasUsed = true; + } + } + + if (outStreamLoc) + *outStream = outStreamLoc.Detach(); + return S_OK; + COM_TRY_END +} + +STDMETHODIMP CExtractCallbackImp::PrepareOperation7(Int32 askExtractMode) +{ + COM_TRY_BEGIN + _needUpdateStat = ( + askExtractMode == NArchive::NExtract::NAskMode::kExtract || + askExtractMode == NArchive::NExtract::NAskMode::kTest); + + /* + _extractMode = false; + switch (askExtractMode) + { + case NArchive::NExtract::NAskMode::kExtract: + if (_testMode) + askExtractMode = NArchive::NExtract::NAskMode::kTest; + else + _extractMode = true; + break; + }; + */ + return SetCurrentFilePath2(_filePath); + COM_TRY_END +} + +STDMETHODIMP CExtractCallbackImp::SetOperationResult7(Int32 opRes, bool encrypted) +{ + COM_TRY_BEGIN + if (VirtFileSystem && _newVirtFileWasAdded) + { + // FIXME: probably we must request file size from VirtFileSystem + // _curSize = VirtFileSystem->GetLastFileSize() + // _curSizeDefined = true; + RINOK(VirtFileSystemSpec->CloseMemFile()); + } + if (_hashStream && _hashStreamWasUsed) + { + _hashStreamSpec->_hash->Final(_isFolder, _isAltStream, _filePath); + _curSize = _hashStreamSpec->GetSize(); + _curSizeDefined = true; + _hashStreamSpec->ReleaseStream(); + _hashStreamWasUsed = false; + } + else if (_hashCalc && _needUpdateStat) + { + _hashCalc->SetSize(_curSize); + _hashCalc->Final(_isFolder, _isAltStream, _filePath); + } + return SetOperationResult(opRes, encrypted); + COM_TRY_END +} + + +static const size_t k_SizeT_MAX = (size_t)((size_t)0 - 1); + +static const UInt32 kBlockSize = ((UInt32)1 << 31); + +STDMETHODIMP CVirtFileSystem::Write(const void *data, UInt32 size, UInt32 *processedSize) +{ + if (processedSize) + *processedSize = 0; + if (size == 0) + return S_OK; + if (!_fileMode) + { + CVirtFile &file = Files.Back(); + size_t rem = file.Data.Size() - (size_t)file.Size; + bool useMem = true; + if (rem < size) + { + UInt64 b = 0; + if (file.Data.Size() == 0) + b = file.ExpectedSize; + UInt64 a = file.Size + size; + if (b < a) + b = a; + a = (UInt64)file.Data.Size() * 2; + if (b < a) + b = a; + useMem = false; + if (b <= k_SizeT_MAX && b <= MaxTotalAllocSize) + useMem = file.Data.ReAlloc_KeepData((size_t)b, (size_t)file.Size); + } + if (useMem) + { + memcpy(file.Data + file.Size, data, size); + file.Size += size; + if (processedSize) + *processedSize = (UInt32)size; + return S_OK; + } + _fileMode = true; + } + RINOK(FlushToDisk(false)); + return _outFileStream->Write(data, size, processedSize); +} + +HRESULT CVirtFileSystem::FlushToDisk(bool closeLast) +{ + if (!_outFileStream) + { + _outFileStreamSpec = new COutFileStream; + _outFileStream = _outFileStreamSpec; + } + while (_numFlushed < Files.Size()) + { + const CVirtFile &file = Files[_numFlushed]; + const FString path = DirPrefix + us2fs(GetCorrectFsPath(file.Name)); + if (!_fileIsOpen) + { + if (!_outFileStreamSpec->Create(path, false)) + { + _outFileStream.Release(); + return E_FAIL; + // MessageBoxMyError(UString(L"Can't create file ") + fs2us(tempFilePath)); + } + _fileIsOpen = true; + RINOK(WriteStream(_outFileStream, file.Data, (size_t)file.Size)); + } + if (_numFlushed == Files.Size() - 1 && !closeLast) + break; + if (file.CTimeDefined || + file.ATimeDefined || + file.MTimeDefined) + _outFileStreamSpec->SetTime( + file.CTimeDefined ? &file.CTime : NULL, + file.ATimeDefined ? &file.ATime : NULL, + file.MTimeDefined ? &file.MTime : NULL); + _outFileStreamSpec->Close(); + _numFlushed++; + _fileIsOpen = false; + if (file.AttribDefined) + NDir::SetFileAttrib(path, file.Attrib); + } + return S_OK; +} + +#endif diff --git a/CPP/7zip/UI/FileManager/ExtractCallback.h b/CPP/7zip/UI/FileManager/ExtractCallback.h old mode 100755 new mode 100644 index 19c29e77..71e48e5e --- a/CPP/7zip/UI/FileManager/ExtractCallback.h +++ b/CPP/7zip/UI/FileManager/ExtractCallback.h @@ -3,18 +3,25 @@ #ifndef __EXTRACT_CALLBACK_H #define __EXTRACT_CALLBACK_H -#include "Common/MyCom.h" +#include "../../../../C/Alloc.h" -#include "Windows/ResourceString.h" +#include "../../../Common/MyCom.h" +#include "../../../Common/StringConvert.h" +#ifndef _SFX #include "../Agent/IFolderArchive.h" +#endif + +#include "../Common/ArchiveExtractCallback.h" #include "../Common/ArchiveOpenCallback.h" #ifndef _NO_CRYPTO #include "../../IPassword.h" #endif +#ifndef _SFX #include "IFolder.h" +#endif #include "ProgressDialog2.h" @@ -22,12 +29,145 @@ #include "LangUtils.h" #endif +#ifndef _SFX + +class CGrowBuf +{ + Byte *_items; + size_t _size; + + CGrowBuf(const CGrowBuf &buffer); + void operator=(const CGrowBuf &buffer); + +public: + bool ReAlloc_KeepData(size_t newSize, size_t keepSize) + { + void *buf = MyAlloc(newSize); + if (!buf) + return false; + memcpy(buf, _items, keepSize); + MyFree(_items); + _items = (Byte *)buf; + _size = newSize; + return true; + } + + CGrowBuf(): _items(0), _size(0) {} + ~CGrowBuf() { MyFree(_items); } + + operator Byte *() { return _items; }; + operator const Byte *() const { return _items; }; + size_t Size() const { return _size; } +}; + +struct CVirtFile +{ + CGrowBuf Data; + + UInt64 Size; // real size + UInt64 ExpectedSize; // the size from props request. 0 if unknown + + UString Name; + + bool CTimeDefined; + bool ATimeDefined; + bool MTimeDefined; + bool AttribDefined; + + bool IsDir; + bool IsAltStream; + + DWORD Attrib; + + FILETIME CTime; + FILETIME ATime; + FILETIME MTime; + + CVirtFile(): + CTimeDefined(false), + ATimeDefined(false), + MTimeDefined(false), + AttribDefined(false), + IsDir(false), + IsAltStream(false) {} +}; + +class CVirtFileSystem: + public ISequentialOutStream, + public CMyUnknownImp +{ + UInt64 _totalAllocSize; + + size_t _pos; + unsigned _numFlushed; + bool _fileIsOpen; + bool _fileMode; + COutFileStream *_outFileStreamSpec; + CMyComPtr _outFileStream; +public: + CObjectVector Files; + UInt64 MaxTotalAllocSize; + FString DirPrefix; + + CVirtFile &AddNewFile() + { + if (!Files.IsEmpty()) + { + MaxTotalAllocSize -= Files.Back().Data.Size(); + } + return Files.AddNew(); + } + HRESULT CloseMemFile() + { + if (_fileMode) + { + return FlushToDisk(true); + } + CVirtFile &file = Files.Back(); + if (file.Data.Size() != file.Size) + { + file.Data.ReAlloc_KeepData((size_t)file.Size, (size_t)file.Size); + } + return S_OK; + } + + bool IsStreamInMem() const + { + if (_fileMode) + return false; + if (Files.Size() < 1 || Files[0].IsAltStream || Files[0].IsDir) + return false; + return true; + } + size_t GetMemStreamWrittenSize() const { return _pos; } + + CVirtFileSystem(): _outFileStreamSpec(NULL), MaxTotalAllocSize((UInt64)0 - 1) {} + + void Init() + { + _totalAllocSize = 0; + _fileMode = false; + _pos = 0; + _numFlushed = 0; + _fileIsOpen = false; + } + + HRESULT CloseFile(const FString &path); + HRESULT FlushToDisk(bool closeLast); + size_t GetPos() const { return _pos; } + + MY_UNKNOWN_IMP + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); +}; + +#endif + class CExtractCallbackImp: - public IExtractCallbackUI, + public IExtractCallbackUI, // it includes IFolderArchiveExtractCallback public IOpenCallbackUI, - public IFolderOperationsExtractCallback, - // public IFolderArchiveExtractCallback, // mkultiple from IProgress #ifndef _SFX + public IFolderOperationsExtractCallback, + public IFolderExtractToStreamCallback, public ICompressProgressInfo, #endif #ifndef _NO_CRYPTO @@ -37,9 +177,10 @@ class CExtractCallbackImp: { HRESULT MessageError(const char *message, const FString &path); public: - MY_QUERYINTERFACE_BEGIN2(IFolderOperationsExtractCallback) - MY_QUERYINTERFACE_ENTRY(IFolderArchiveExtractCallback) + MY_QUERYINTERFACE_BEGIN2(IFolderArchiveExtractCallback) #ifndef _SFX + MY_QUERYINTERFACE_ENTRY(IFolderOperationsExtractCallback) + MY_QUERYINTERFACE_ENTRY(IFolderExtractToStreamCallback) MY_QUERYINTERFACE_ENTRY(ICompressProgressInfo) #endif #ifndef _NO_CRYPTO @@ -48,10 +189,6 @@ public: MY_QUERYINTERFACE_END MY_ADDREF_RELEASE - #ifndef _SFX - STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); - #endif - INTERFACE_IProgress(;) INTERFACE_IOpenCallbackUI(;) @@ -71,13 +208,18 @@ public: HRESULT BeforeOpen(const wchar_t *name); HRESULT OpenResult(const wchar_t *name, HRESULT result, bool encrypted); + HRESULT SetError(int level, const wchar_t *name, + UInt32 errorFlags, const wchar_t *errors, + UInt32 warningFlags, const wchar_t *warnings); HRESULT ThereAreNoFiles(); HRESULT ExtractResult(HRESULT result); + HRESULT OpenTypeWarning(const wchar_t *name, const wchar_t *okType, const wchar_t *errorType); #ifndef _NO_CRYPTO HRESULT SetPassword(const UString &password); #endif + #ifndef _SFX // IFolderOperationsExtractCallback STDMETHOD(AskWrite)( const wchar_t *srcPath, @@ -90,6 +232,9 @@ public: STDMETHOD(ShowMessage)(const wchar_t *message); STDMETHOD(SetCurrentFilePath)(const wchar_t *filePath); STDMETHOD(SetNumFiles)(UInt64 numFiles); + INTERFACE_IFolderExtractToStreamCallback(;) + STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); + #endif // ICryptoGetTextPassword #ifndef _NO_CRYPTO @@ -103,9 +248,37 @@ private: UString _currentFilePath; bool _isFolder; + bool _isAltStream; + UInt64 _curSize; + bool _curSizeDefined; + UString _filePath; + // bool _extractMode; + // bool _testMode; + bool _newVirtFileWasAdded; + bool _needUpdateStat; + + HRESULT SetCurrentFilePath2(const wchar_t *filePath); - void AddErrorMessage(LPCWSTR message); + void AddError_Message(LPCWSTR message); + + #ifndef _SFX + bool _hashStreamWasUsed; + COutStreamWithHash *_hashStreamSpec; + CMyComPtr _hashStream; + IHashCalc *_hashCalc; // it's for stat in Test operation + #endif + public: + + #ifndef _SFX + CVirtFileSystem *VirtFileSystemSpec; + CMyComPtr VirtFileSystem; + #endif + + bool ProcessAltStreams; + + bool StreamMode; + CProgressDialog *ProgressDialog; #ifndef _SFX UInt64 NumFolders; @@ -127,12 +300,30 @@ public: PasswordIsDefined(false), PasswordWasAsked(false), #endif - OverwriteMode(NExtract::NOverwriteMode::kAskBefore) + OverwriteMode(NExtract::NOverwriteMode::kAsk), + StreamMode(false), + ProcessAltStreams(true) + #ifndef _SFX + , _hashCalc(NULL) + #endif {} ~CExtractCallbackImp(); void Init(); + #ifndef _SFX + void SetHashCalc(IHashCalc *hashCalc) { _hashCalc = hashCalc; } + + void SetHashMethods(IHashCalc *hash) + { + if (!hash) + return; + _hashStreamSpec = new COutStreamWithHash; + _hashStream = _hashStreamSpec; + _hashStreamSpec->_hash = hash; + } + #endif + bool IsOK() const { return NumArchiveErrors == 0 && !ThereAreMessageErrors; } }; diff --git a/CPP/7zip/UI/FileManager/FM.cpp b/CPP/7zip/UI/FileManager/FM.cpp old mode 100755 new mode 100644 index 147a1fb7..537103ae --- a/CPP/7zip/UI/FileManager/FM.cpp +++ b/CPP/7zip/UI/FileManager/FM.cpp @@ -4,12 +4,17 @@ #include "../../../../C/Alloc.h" -#include "Windows/Error.h" -#include "Windows/MemoryLock.h" -#include "Windows/NtCheck.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/StringConvert.h" +#include "../../../Common/StringToInt.h" + +#include "../../../Windows/ErrorMsg.h" +#include "../../../Windows/MemoryLock.h" +#include "../../../Windows/NtCheck.h" +#include "../../../Windows/System.h" #ifndef UNDER_CE -#include "Windows/Security.h" +#include "../../../Windows/SecurityUtils.h" #endif #include "../GUI/ExtractRes.h" @@ -33,6 +38,8 @@ using namespace NFind; #define MENU_HEIGHT 26 +UInt64 g_RAM_Size; + #ifdef _WIN32 HINSTANCE g_hInstance; #endif @@ -43,7 +50,30 @@ static UString g_ArcFormat; static bool g_Maximized = false; #ifndef UNDER_CE + DWORD g_ComCtl32Version; + +static DWORD GetDllVersion(LPCTSTR dllName) +{ + DWORD dwVersion = 0; + HINSTANCE hinstDll = LoadLibrary(dllName); + if (hinstDll) + { + DLLGETVERSIONPROC pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); + if (pDllGetVersion) + { + DLLVERSIONINFO dvi; + ZeroMemory(&dvi, sizeof(dvi)); + dvi.cbSize = sizeof(dvi); + HRESULT hr = (*pDllGetVersion)(&dvi); + if (SUCCEEDED(hr)) + dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion); + } + FreeLibrary(hinstDll); + } + return dwVersion; +} + #endif bool g_IsSmallScreen = false; @@ -140,18 +170,13 @@ const wchar_t *kWindowClass = L"FM"; #endif // FUNCTION: InitInstance(HANDLE, int) -BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) +static BOOL InitInstance(int nCmdShow) { CWindow wnd; - g_hInstance = hInstance; - - ReloadLangSmart(); - // LoadString(hInstance, IDS_CLASS, windowClass, MAX_LOADSTRING); - // LoadString(hInstance, IDS_APP_TITLE, title, MAX_LOADSTRING); - UString title = LangString(IDS_APP_TITLE, 0x03000000); + UString title = L"7-Zip"; // LangString(IDS_APP_TITLE, 0x03000000); /* //If it is already running, then focus on the window @@ -170,8 +195,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hInstance = hInstance; - wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON)); + wc.hInstance = g_hInstance; + wc.hIcon = LoadIcon(g_hInstance, MAKEINTRESOURCE(IDI_ICON)); // wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.hCursor = ::LoadCursor(0, IDC_SIZEWE); @@ -196,39 +221,40 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) DWORD style = WS_OVERLAPPEDWINDOW; // DWORD style = 0; - RECT rect; - bool maximized = false; - int x , y, xSize, ySize; + CWindowInfo info; + info.maximized = false; + int x, y, xSize, ySize; x = y = xSize = ySize = CW_USEDEFAULT; - bool windowPosIsRead = ReadWindowSize(rect, maximized); + bool windowPosIsRead; + info.Read(windowPosIsRead, g_PanelsInfoDefined); if (windowPosIsRead) { // x = rect.left; // y = rect.top; - xSize = rect.right - rect.left; - ySize = rect.bottom - rect.top; + xSize = RECT_SIZE_X(info.rect); + ySize = RECT_SIZE_Y(info.rect); } - UInt32 numPanels, currentPanel; - g_PanelsInfoDefined = ReadPanelsInfo(numPanels, currentPanel, g_SplitterPos); + if (g_PanelsInfoDefined) { - if (numPanels < 1 || numPanels > 2) - numPanels = kNumDefaultPanels; - if (currentPanel >= 2) - currentPanel = 0; + g_SplitterPos = info.splitterPos; + if (info.numPanels < 1 || info.numPanels > 2) + info.numPanels = kNumDefaultPanels; + if (info.currentPanel >= 2) + info.currentPanel = 0; } else { - numPanels = kNumDefaultPanels; - currentPanel = 0; + info.numPanels = kNumDefaultPanels; + info.currentPanel = 0; } - g_App.NumPanels = numPanels; - g_App.LastFocusedPanel = currentPanel; + g_App.NumPanels = info.numPanels; + g_App.LastFocusedPanel = info.currentPanel; if (!wnd.Create(kWindowClass, title, style, - x, y, xSize, ySize, NULL, NULL, hInstance, NULL)) + x, y, xSize, ySize, NULL, NULL, g_hInstance, NULL)) return FALSE; if (nCmdShow == SW_SHOWNORMAL || @@ -238,7 +264,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) #endif ) { - if (maximized) + if (info.maximized) nCmdShow = SW_SHOWMAXIMIZED; else nCmdShow = SW_SHOWNORMAL; @@ -253,7 +279,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) if (wnd.GetPlacement(&placement)) { if (windowPosIsRead) - placement.rcNormalPosition = rect; + placement.rcNormalPosition = info.rect; placement.showCmd = nCmdShow; wnd.SetPlacement(&placement); } @@ -286,47 +312,10 @@ static void GetCommands(const UString &aCommandLine, UString &aCommands) else aProgramName += aChar; } - aCommands = aCommandLine.Mid(i); + aCommands = aCommandLine.Ptr(i); } */ -#ifndef UNDER_CE -static DWORD GetDllVersion(LPCTSTR lpszDllName) -{ - HINSTANCE hinstDll; - DWORD dwVersion = 0; - hinstDll = LoadLibrary(lpszDllName); - if (hinstDll) - { - DLLGETVERSIONPROC pDllGetVersion; - pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hinstDll, "DllGetVersion"); - - /*Because some DLLs might not implement this function, you - must test for it explicitly. Depending on the particular - DLL, the lack of a DllGetVersion function can be a useful - indicator of the version. - */ - if (pDllGetVersion) - { - DLLVERSIONINFO dvi; - HRESULT hr; - - ZeroMemory(&dvi, sizeof(dvi)); - dvi.cbSize = sizeof(dvi); - - hr = (*pDllGetVersion)(&dvi); - - if (SUCCEEDED(hr)) - { - dwVersion = MAKELONG(dvi.dwMinorVersion, dvi.dwMajorVersion); - } - } - FreeLibrary(hinstDll); - } - return dwVersion; -} -#endif - /* #ifndef _WIN64 typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); @@ -368,6 +357,7 @@ bool IsLargePageSupported() } #ifndef UNDER_CE + static void SetMemoryLock() { if (!IsLargePageSupported()) @@ -376,8 +366,27 @@ static void SetMemoryLock() NSecurity::AddLockMemoryPrivilege(); if (ReadLockMemoryEnable()) - NSecurity::EnableLockMemoryPrivilege(); + NSecurity::EnablePrivilege_LockMemory(); +} + +bool g_SymLink_Supported = false; + +static void Set_SymLink_Supported() +{ + g_SymLink_Supported = false; + OSVERSIONINFO versionInfo; + versionInfo.dwOSVersionInfoSize = sizeof(versionInfo); + if (!::GetVersionEx(&versionInfo)) + return; + if (versionInfo.dwPlatformId != VER_PLATFORM_WIN32_NT || versionInfo.dwMajorVersion < 6) + return; + g_SymLink_Supported = true; + // if (g_SymLink_Supported) + { + NSecurity::EnablePrivilege_SymLink(); + } } + #endif /* @@ -399,16 +408,18 @@ static const CSwitchForm kSwitchForms[kNumSwitches] = // int APIENTRY WinMain2(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, LPSTR /* lpCmdLine */, int /* nCmdShow */); -#define NT_CHECK_FAIL_ACTION MessageBoxW(0, L"Unsupported Windows version", L"7-zip", MB_ICONERROR); return 1; +static void ErrorMessage(const wchar_t *s) +{ + MessageBoxW(0, s, L"7-Zip", MB_ICONERROR); +} -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, - #ifdef UNDER_CE - LPWSTR - #else - LPSTR - #endif - /* lpCmdLine */, int nCmdShow) + +#define NT_CHECK_FAIL_ACTION ErrorMessage(L"Unsupported Windows version"); return 1; + +static int WINAPI WinMain2(int nCmdShow) { + g_RAM_Size = NSystem::GetRamSize(); + #ifdef _WIN32 /* @@ -440,6 +451,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, #endif + LoadLangOneTime(); + InitCommonControls(); #ifndef UNDER_CE @@ -471,8 +484,48 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, SplitStringToTwoStrings(commandsString, paramString, tailString); paramString.Trim(); tailString.Trim(); - if (tailString.Left(2) == L"-t") - g_ArcFormat = tailString.Mid(2); + if (tailString.IsPrefixedBy(L"-t")) + g_ArcFormat = tailString.Ptr(2); + + /* + UStringVector switches; + for (;;) + { + if (tailString.IsEmpty()) + break; + UString s1, s2; + SplitStringToTwoStrings(tailString, s1, s2); + if (s2.IsEmpty()) + { + tailString.Trim(); + switches.Add(tailString); + break; + } + s1.Trim(); + switches.Add(s1); + tailString = s2; + } + + FOR_VECTOR(i, switches) + { + const UString &sw = switches[i]; + if (sw.IsPrefixedBy(L"-t")) + g_ArcFormat = sw.Ptr(2); + // + else if (sw.IsPrefixedBy(L"-stp")) + { + const wchar_t *end; + UInt32 val = ConvertStringToUInt32(sw.Ptr(4), &end); + if (*end != 0) + throw 111; + g_TypeParseLevel = val; + } + else + // + throw 112; + } + */ + if (!paramString.IsEmpty()) { g_MainPath = paramString; @@ -504,18 +557,21 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, */ - #ifndef UNDER_CE + #if defined(_WIN32) && !defined(UNDER_CE) SetMemoryLock(); + Set_SymLink_Supported(); #endif + g_App.ReloadLang(); + MSG msg; - if (!InitInstance (hInstance, nCmdShow)) + if (!InitInstance (nCmdShow)) return FALSE; #ifndef _UNICODE if (g_IsNT) { - HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1)); + HACCEL hAccels = LoadAcceleratorsW(g_hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1)); while (GetMessageW(&msg, NULL, 0, 0)) { if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0) @@ -528,7 +584,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, else #endif { - HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1)); + HACCEL hAccels = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1)); while (GetMessage(&msg, NULL, 0, 0)) { if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0) @@ -548,21 +604,85 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, return (int)msg.wParam; } +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /* hPrevInstance */, + #ifdef UNDER_CE + LPWSTR + #else + LPSTR + #endif + /* lpCmdLine */, int nCmdShow) +{ + g_hInstance = hInstance; + + try + { + return WinMain2(nCmdShow); + } + catch(const CNewException &) + { + ErrorMessage(LangString(IDS_MEM_ERROR)); + return 1; + } + catch(const UString &s) + { + ErrorMessage(s); + return 1; + } + catch(const AString &s) + { + ErrorMessage(GetUnicodeString(s)); + return 1; + } + catch(const wchar_t *s) + { + ErrorMessage(s); + return 1; + } + catch(const char *s) + { + ErrorMessage(GetUnicodeString(s)); + return 1; + } + catch(int v) + { + wchar_t s[32]; + ConvertUInt32ToString(v, s); + ErrorMessage(UString(L"Error: ") + s); + return 1; + } + catch(...) + { + ErrorMessage(L"Unknown error"); + return 1; + } +} + static void SaveWindowInfo(HWND aWnd) { + CWindowInfo info; + #ifdef UNDER_CE - RECT rect; - if (!::GetWindowRect(aWnd, &rect)) + + if (!::GetWindowRect(aWnd, &info.rect)) return; - SaveWindowSize(rect, g_Maximized); + info.maximized = g_Maximized; + #else + WINDOWPLACEMENT placement; placement.length = sizeof(placement); if (!::GetWindowPlacement(aWnd, &placement)) return; - SaveWindowSize(placement.rcNormalPosition, BOOLToBool(::IsZoomed(aWnd))); + info.rect = placement.rcNormalPosition; + info.maximized = BOOLToBool(::IsZoomed(aWnd)); + #endif - SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel, g_Splitter.GetPos()); + + info.numPanels = g_App.NumPanels; + info.currentPanel = g_App.LastFocusedPanel; + info.splitterPos = g_Splitter.GetPos(); + + info.Save(); } static void ExecuteCommand(UINT commandID) @@ -572,9 +692,9 @@ static void ExecuteCommand(UINT commandID) switch (commandID) { - case kAddCommand: g_App.AddToArchive(); break; - case kExtractCommand: g_App.ExtractArchives(); break; - case kTestCommand: g_App.TestArchives(); break; + case kMenuCmdID_Toolbar_Add: g_App.AddToArchive(); break; + case kMenuCmdID_Toolbar_Extract: g_App.ExtractArchives(); break; + case kMenuCmdID_Toolbar_Test: g_App.TestArchives(); break; } } @@ -588,7 +708,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) wmEvent = HIWORD(wParam); if ((HWND) lParam != NULL && wmEvent != 0) break; - if (wmId >= kToolbarStartID) + if (wmId >= kMenuCmdID_Toolbar_Start && wmId < kMenuCmdID_Toolbar_End) { ExecuteCommand(wmId); return 0; @@ -636,7 +756,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT baseID + 2, 11, (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR, - (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]), + (LPCTBBUTTON)&tbb, ARRAY_SIZE(tbb), 0, 0, 100, 30, sizeof (TBBUTTON))); */ // HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE); @@ -679,22 +799,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) UString message = L"Error"; if (res == S_FALSE || res == S_OK) { - if (encrypted) - message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath); - else - message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath); - } - else - { - if (res != S_OK) - { - if (res == E_OUTOFMEMORY) - message = LangString(IDS_MEM_ERROR, 0x0200060B); - else - message = NError::MyFormatMessageW(res); - } + message = MyFormatNew(encrypted ? + IDS_CANT_OPEN_ENCRYPTED_ARCHIVE : + IDS_CANT_OPEN_ARCHIVE, + g_MainPath); } - MessageBoxW(0, message, L"7-zip", MB_ICONERROR); + else if (res != S_OK) + message = HResultToMessage(res); + ErrorMessage(message); return -1; } // g_SplitterPos = 0; @@ -824,7 +936,7 @@ static int Window_GetRealHeight(NWindows::CWindow &w) { RECT rect; w.GetWindowRect(&rect); - int res = rect.bottom - rect.top; + int res = RECT_SIZE_Y(rect); #ifndef UNDER_CE WINDOWPLACEMENT placement; if (w.GetPlacement(&placement)) diff --git a/CPP/7zip/UI/FileManager/FM.dsp b/CPP/7zip/UI/FileManager/FM.dsp old mode 100755 new mode 100644 index 3f3cd77c..4a7f16a6 --- a/CPP/7zip/UI/FileManager/FM.dsp +++ b/CPP/7zip/UI/FileManager/FM.dsp @@ -45,7 +45,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c +# ADD CPP /nologo /Gz /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /FAs /Yu"StdAfx.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x419 /d "NDEBUG" @@ -72,7 +72,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /Gz /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x419 /d "_DEBUG" @@ -99,7 +99,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /c -# ADD CPP /nologo /Gz /MD /W3 /GX /O1 /I "..\..\..\\" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c +# ADD CPP /nologo /Gz /MD /W4 /WX /GX /O1 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x419 /d "NDEBUG" @@ -127,7 +127,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"StdAfx.h" /FD /GZ /c -# ADD CPP /nologo /Gz /MDd /W3 /Gm /GX /ZI /Od /I "..\..\..\\" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c +# ADD CPP /nologo /Gz /MDd /W4 /WX /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "LANG" /D "WIN_LONG_PATH" /D "NEW_FOLDER_INTERFACE" /D "EXTERNAL_CODECS" /D "SUPPORT_DEVICE_FILE" /Yu"StdAfx.h" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x419 /d "_DEBUG" @@ -214,22 +214,6 @@ SOURCE=.\StdAfx.h SOURCE=.\Test.bmp # End Source File # End Group -# Begin Group "Archive" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=..\..\Archive\IArchive.h -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\OutStreamWithCRC.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\Archive\Common\OutStreamWithCRC.h -# End Source File -# End Group # Begin Group "Folders" # PROP Default_Filter "" @@ -499,6 +483,14 @@ SOURCE=.\DialogSize.h # End Source File # Begin Source File +SOURCE=.\LinkDialog.cpp +# End Source File +# Begin Source File + +SOURCE=.\LinkDialog.h +# End Source File +# Begin Source File + SOURCE=.\ListViewDialog.cpp # End Source File # Begin Source File @@ -603,6 +595,14 @@ SOURCE=.\UpdateCallback100.h # PROP Default_Filter "" # Begin Source File +SOURCE=..\..\Common\CreateCoder.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\Common\CreateCoder.h +# End Source File +# Begin Source File + SOURCE=..\..\Common\FilePathAutoRename.cpp # End Source File # Begin Source File @@ -619,131 +619,84 @@ SOURCE=..\..\Common\FileStreams.h # End Source File # Begin Source File -SOURCE=..\..\Common\ProgressUtils.cpp +SOURCE=..\..\Common\FilterCoder.cpp # End Source File # Begin Source File -SOURCE=..\..\Common\ProgressUtils.h +SOURCE=..\..\Common\FilterCoder.h # End Source File # Begin Source File -SOURCE=..\..\Common\StreamObjects.cpp +SOURCE=..\..\Common\LimitedStreams.cpp # End Source File # Begin Source File -SOURCE=..\..\Common\StreamObjects.h +SOURCE=..\..\Common\LimitedStreams.h # End Source File # Begin Source File -SOURCE=..\..\Common\StreamUtils.cpp +SOURCE=..\..\Common\MethodProps.cpp # End Source File # Begin Source File -SOURCE=..\..\Common\StreamUtils.h +SOURCE=..\..\Common\MethodProps.h # End Source File -# End Group -# Begin Group "C" - -# PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=..\..\Common\ProgressUtils.cpp # End Source File # Begin Source File -SOURCE=..\..\..\..\C\7zCrc.h +SOURCE=..\..\Common\ProgressUtils.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\7zCrcOpt.c - -!IF "$(CFG)" == "FM - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "FM - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "FM - Win32 DebugU" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - +SOURCE=..\..\Common\PropId.cpp # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.c -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=..\..\Common\StreamObjects.cpp # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Alloc.h +SOURCE=..\..\Common\StreamObjects.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\CpuArch.c - -!IF "$(CFG)" == "FM - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "FM - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "FM - Win32 DebugU" - -# SUBTRACT CPP /YX /Yc /Yu - -!ENDIF - +SOURCE=..\..\Common\StreamUtils.cpp # End Source File # Begin Source File -SOURCE=..\..\..\..\C\CpuArch.h +SOURCE=..\..\Common\StreamUtils.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Sha256.c - -!IF "$(CFG)" == "FM - Win32 Release" - -# ADD CPP /O2 -# SUBTRACT CPP /YX /Yc /Yu - -!ELSEIF "$(CFG)" == "FM - Win32 Debug" - -# SUBTRACT CPP /YX /Yc /Yu +SOURCE=..\..\Common\UniqBlocks.cpp +# End Source File +# Begin Source File -!ELSEIF "$(CFG)" == "FM - Win32 ReleaseU" +SOURCE=..\..\Common\UniqBlocks.h +# End Source File +# End Group +# Begin Group "C" -# SUBTRACT CPP /YX /Yc /Yu +# PROP Default_Filter "" +# Begin Source File -!ELSEIF "$(CFG)" == "FM - Win32 DebugU" +SOURCE=..\..\..\..\C\7zTypes.h +# End Source File +# Begin Source File +SOURCE=..\..\..\..\C\Alloc.c # SUBTRACT CPP /YX /Yc /Yu +# End Source File +# Begin Source File -!ENDIF - +SOURCE=..\..\..\..\C\Alloc.h # End Source File # Begin Source File -SOURCE=..\..\..\..\C\Sha256.h +SOURCE=..\..\..\..\C\CpuArch.h # End Source File # Begin Source File @@ -836,10 +789,6 @@ SOURCE=..\..\..\Windows\Control\ToolBar.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Control\Trackbar.h -# End Source File -# Begin Source File - SOURCE=..\..\..\Windows\Control\Window2.cpp # End Source File # Begin Source File @@ -885,11 +834,11 @@ SOURCE=..\..\..\Windows\DLL.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Error.cpp +SOURCE=..\..\..\Windows\ErrorMsg.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Error.h +SOURCE=..\..\..\Windows\ErrorMsg.h # End Source File # Begin Source File @@ -917,6 +866,10 @@ SOURCE=..\..\..\Windows\FileIO.h # End Source File # Begin Source File +SOURCE=..\..\..\Windows\FileLink.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\Windows\FileMapping.h # End Source File # Begin Source File @@ -941,11 +894,11 @@ SOURCE=..\..\..\Windows\Handle.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Memory.cpp +SOURCE=..\..\..\Windows\MemoryGlobal.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Memory.h +SOURCE=..\..\..\Windows\MemoryGlobal.h # End Source File # Begin Source File @@ -973,11 +926,15 @@ SOURCE=..\..\..\Windows\Net.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Process.cpp +SOURCE=..\..\..\Windows\NtCheck.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Process.h +SOURCE=..\..\..\Windows\ProcessUtils.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\ProcessUtils.h # End Source File # Begin Source File @@ -989,11 +946,11 @@ SOURCE=..\..\..\Windows\PropVariant.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\PropVariantConversions.cpp +SOURCE=..\..\..\Windows\PropVariantConv.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\PropVariantConversions.h +SOURCE=..\..\..\Windows\PropVariantConv.h # End Source File # Begin Source File @@ -1013,11 +970,11 @@ SOURCE=..\..\..\Windows\ResourceString.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Security.cpp +SOURCE=..\..\..\Windows\SecurityUtils.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Security.h +SOURCE=..\..\..\Windows\SecurityUtils.h # End Source File # Begin Source File @@ -1037,19 +994,23 @@ SOURCE=..\..\..\Windows\Synchronization.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Thread.h +SOURCE=..\..\..\Windows\System.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\Windows\System.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Time.cpp +SOURCE=..\..\..\Windows\Thread.h # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Time.h +SOURCE=..\..\..\Windows\TimeUtils.cpp # End Source File # Begin Source File -SOURCE=..\..\..\Windows\Timer.h +SOURCE=..\..\..\Windows\TimeUtils.h # End Source File # Begin Source File @@ -1065,18 +1026,10 @@ SOURCE=..\..\..\Windows\Window.h # PROP Default_Filter "" # Begin Source File -SOURCE=..\..\..\Common\Buffer.h -# End Source File -# Begin Source File - SOURCE=..\..\..\Common\ComTry.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\CRC.cpp -# End Source File -# Begin Source File - SOURCE=..\..\..\Common\Defs.h # End Source File # Begin Source File @@ -1105,6 +1058,10 @@ SOURCE=..\..\..\Common\Lang.h # End Source File # Begin Source File +SOURCE=..\..\..\Common\MyBuffer.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Common\MyCom.h # End Source File # Begin Source File @@ -1117,6 +1074,10 @@ SOURCE=..\..\..\Common\MyString.h # End Source File # Begin Source File +SOURCE=..\..\..\Common\MyTypes.h +# End Source File +# Begin Source File + SOURCE=..\..\..\Common\MyVector.cpp # End Source File # Begin Source File @@ -1157,18 +1118,6 @@ SOURCE=..\..\..\Common\StringToInt.h # End Source File # Begin Source File -SOURCE=..\..\..\Common\TextConfig.cpp -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\TextConfig.h -# End Source File -# Begin Source File - -SOURCE=..\..\..\Common\Types.h -# End Source File -# Begin Source File - SOURCE=..\..\..\Common\UTFConvert.cpp # End Source File # Begin Source File @@ -1260,6 +1209,14 @@ SOURCE=..\Common\ExtractMode.h # End Source File # Begin Source File +SOURCE=..\Common\HashCalc.cpp +# End Source File +# Begin Source File + +SOURCE=..\Common\HashCalc.h +# End Source File +# Begin Source File + SOURCE=..\Common\IFileExtractCallback.h # End Source File # Begin Source File @@ -1292,6 +1249,14 @@ SOURCE=..\Common\PropIDUtils.h # End Source File # Begin Source File +SOURCE=..\Common\SetProperties.cpp +# End Source File +# Begin Source File + +SOURCE=..\Common\SetProperties.h +# End Source File +# Begin Source File + SOURCE=..\Common\SortUtils.cpp # End Source File # Begin Source File @@ -1412,6 +1377,10 @@ SOURCE=..\Explorer\ContextMenu.h # End Source File # Begin Source File +SOURCE=..\Explorer\ContextMenuFlags.h +# End Source File +# Begin Source File + SOURCE=..\Explorer\RegistryContextMenu.cpp # End Source File # Begin Source File @@ -1419,6 +1388,18 @@ SOURCE=..\Explorer\RegistryContextMenu.cpp SOURCE=..\Explorer\RegistryContextMenu.h # End Source File # End Group +# Begin Group "GUI" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=..\GUI\HashGUI.cpp +# End Source File +# Begin Source File + +SOURCE=..\GUI\HashGUI.h +# End Source File +# End Group # End Group # Begin Group "Compress" @@ -1437,6 +1418,10 @@ SOURCE=..\..\Compress\CopyCoder.h # PROP Default_Filter "" # Begin Source File +SOURCE=..\..\Archive\IArchive.h +# End Source File +# Begin Source File + SOURCE=..\..\ICoder.h # End Source File # Begin Source File @@ -1451,6 +1436,14 @@ SOURCE=..\..\IPassword.h SOURCE=..\..\IProgress.h # End Source File +# Begin Source File + +SOURCE=..\..\IStream.h +# End Source File +# Begin Source File + +SOURCE=..\..\PropID.h +# End Source File # End Group # Begin Source File diff --git a/CPP/7zip/UI/FileManager/FM.dsw b/CPP/7zip/UI/FileManager/FM.dsw old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/FM.ico b/CPP/7zip/UI/FileManager/FM.ico old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/FM.mak b/CPP/7zip/UI/FileManager/FM.mak new file mode 100644 index 00000000..234a5920 --- /dev/null +++ b/CPP/7zip/UI/FileManager/FM.mak @@ -0,0 +1,81 @@ +FM_OBJS = \ + $O\App.obj \ + $O\BrowseDialog.obj \ + $O\ClassDefs.obj \ + $O\EnumFormatEtc.obj \ + $O\ExtractCallback.obj \ + $O\FileFolderPluginOpen.obj \ + $O\FilePlugins.obj \ + $O\FM.obj \ + $O\FoldersPage.obj \ + $O\FormatUtils.obj \ + $O\FSFolder.obj \ + $O\FSFolderCopy.obj \ + $O\HelpUtils.obj \ + $O\LangUtils.obj \ + $O\MenuPage.obj \ + $O\MyLoadMenu.obj \ + $O\OpenCallback.obj \ + $O\OptionsDialog.obj \ + $O\Panel.obj \ + $O\PanelCopy.obj \ + $O\PanelCrc.obj \ + $O\PanelDrag.obj \ + $O\PanelFolderChange.obj \ + $O\PanelItemOpen.obj \ + $O\PanelItems.obj \ + $O\PanelKey.obj \ + $O\PanelListNotify.obj \ + $O\PanelMenu.obj \ + $O\PanelOperations.obj \ + $O\PanelSelect.obj \ + $O\PanelSort.obj \ + $O\PanelSplitFile.obj \ + $O\ProgramLocation.obj \ + $O\PropertyName.obj \ + $O\RegistryAssociations.obj \ + $O\RegistryPlugins.obj \ + $O\RegistryUtils.obj \ + $O\RootFolder.obj \ + $O\SplitUtils.obj \ + $O\StringUtils.obj \ + $O\SysIconUtils.obj \ + $O\TextPairs.obj \ + $O\UpdateCallback100.obj \ + $O\ViewSettings.obj \ + $O\AboutDialog.obj \ + $O\ComboDialog.obj \ + $O\CopyDialog.obj \ + $O\EditPage.obj \ + $O\LangPage.obj \ + $O\ListViewDialog.obj \ + $O\MessagesDialog.obj \ + $O\OverwriteDialog.obj \ + $O\PasswordDialog.obj \ + $O\ProgressDialog2.obj \ + $O\SettingsPage.obj \ + $O\SplitDialog.obj \ + $O\SystemPage.obj \ + +!IFNDEF UNDER_CE + +FM_OBJS = $(FM_OBJS) \ + $O\FSDrives.obj \ + $O\LinkDialog.obj \ + $O\NetFolder.obj \ + +WIN_OBJS = $(WIN_OBJS) \ + $O\FileSystem.obj \ + $O\Net.obj \ + $O\SecurityUtils.obj \ + +!ENDIF + +AGENT_OBJS = \ + $O\Agent.obj \ + $O\AgentOut.obj \ + $O\AgentProxy.obj \ + $O\ArchiveFolder.obj \ + $O\ArchiveFolderOpen.obj \ + $O\ArchiveFolderOut.obj \ + $O\UpdateCallbackAgent.obj \ diff --git a/CPP/7zip/UI/FileManager/FSDrives.cpp b/CPP/7zip/UI/FileManager/FSDrives.cpp old mode 100755 new mode 100644 index 823b0826..84639de7 --- a/CPP/7zip/UI/FileManager/FSDrives.cpp +++ b/CPP/7zip/UI/FileManager/FSDrives.cpp @@ -4,14 +4,15 @@ #include "../../../../C/Alloc.h" -#include "Common/ComTry.h" -#include "Common/StringConvert.h" +#include "../../../Common/ComTry.h" +#include "../../../Common/Defs.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/StringConvert.h" -#include "Windows/Defs.h" -#include "Windows/FileDir.h" -#include "Windows/FileIO.h" -#include "Windows/FileSystem.h" -#include "Windows/PropVariant.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/FileIO.h" +#include "../../../Windows/FileSystem.h" +#include "../../../Windows/PropVariant.h" #include "../../PropID.h" @@ -26,7 +27,8 @@ using namespace NWindows; using namespace NFile; using namespace NFind; -static CFSTR kVolPrefix = FTEXT("\\\\.\\"); +static CFSTR kVolPrefix = FTEXT("\\\\.\\"); +static CFSTR kLongPrefix = FTEXT("\\\\?\\"); FString CDriveInfo::GetDeviceFileIoName() const { @@ -43,7 +45,7 @@ struct CPhysTempBuffer static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt64 fileSize, UInt32 bufferSize, UInt64 progressStart, IProgress *progress) { - NFile::NIO::CInFile inFile; + NIO::CInFile inFile; if (!inFile.Open(fromPath)) return GetLastError(); if (fileSize == (UInt64)(Int64)-1) @@ -51,7 +53,7 @@ static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt if (!inFile.GetLength(fileSize)) ::GetLastError(); } - NFile::NIO::COutFile outFile; + NIO::COutFile outFile; if (writeToDisk) { if (!outFile.Open(toPath, FILE_SHARE_WRITE, OPEN_EXISTING, 0)) @@ -62,7 +64,7 @@ static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt return GetLastError(); CPhysTempBuffer tempBuffer; tempBuffer.buffer = MidAlloc(bufferSize); - if (tempBuffer.buffer == 0) + if (!tempBuffer.buffer) return E_OUTOFMEMORY; for (UInt64 pos = 0; pos < fileSize;) @@ -94,26 +96,26 @@ static HRESULT CopyFileSpec(CFSTR fromPath, CFSTR toPath, bool writeToDisk, UInt return S_OK; } -static const STATPROPSTG kProps[] = +static const PROPID kProps[] = { - { NULL, kpidName, VT_BSTR}, - { NULL, kpidTotalSize, VT_UI8}, - { NULL, kpidFreeSpace, VT_UI8}, - { NULL, kpidType, VT_BSTR}, - { NULL, kpidVolumeName, VT_BSTR}, - { NULL, kpidFileSystem, VT_BSTR}, - { NULL, kpidClusterSize, VT_UI8} + kpidName, + kpidTotalSize, + kpidFreeSpace, + kpidType, + kpidVolumeName, + kpidFileSystem, + kpidClusterSize }; static const char *kDriveTypes[] = { - "Unknown", - "No Root Dir", - "Removable", - "Fixed", - "Remote", - "CD-ROM", - "RAM disk" + "Unknown" + , "No Root Dir" + , "Removable" + , "Fixed" + , "Remote" + , "CD-ROM" + , "RAM disk" }; STDMETHODIMP CFSDrives::LoadItems() @@ -122,7 +124,8 @@ STDMETHODIMP CFSDrives::LoadItems() FStringVector driveStrings; MyGetLogicalDriveStrings(driveStrings); - for (int i = 0; i < driveStrings.Size(); i++) + + FOR_VECTOR (i, driveStrings) { CDriveInfo di; @@ -130,12 +133,13 @@ STDMETHODIMP CFSDrives::LoadItems() di.FullSystemName = driveName; if (!driveName.IsEmpty()) - di.Name = driveName.Left(driveName.Length() - 1); + di.Name.SetFrom(driveName, driveName.Len() - 1); di.ClusterSize = 0; di.DriveSize = 0; di.FreeSpace = 0; - di.DriveType = NFile::NSystem::MyGetDriveType(driveName); + di.DriveType = NSystem::MyGetDriveType(driveName); bool needRead = true; + if (di.DriveType == DRIVE_CDROM || di.DriveType == DRIVE_REMOVABLE) { /* @@ -143,25 +147,59 @@ STDMETHODIMP CFSDrives::LoadItems() if (!::GetVolumeInformation(di.FullSystemName, NULL, 0, &dwSerialNumber, NULL, NULL, NULL, 0)) */ - di.KnownSizes = false; { needRead = false; } } + if (needRead) { DWORD volumeSerialNumber, maximumComponentLength, fileSystemFlags; - NFile::NSystem::MyGetVolumeInformation(driveName, + NSystem::MyGetVolumeInformation(driveName, di.VolumeName, &volumeSerialNumber, &maximumComponentLength, &fileSystemFlags, di.FileSystemName); - NFile::NSystem::MyGetDiskFreeSpace(driveName, + NSystem::MyGetDiskFreeSpace(driveName, di.ClusterSize, di.DriveSize, di.FreeSpace); di.KnownSizes = true; + di.KnownSize = true; } + _drives.Add(di); } + + if (_volumeMode) + { + // we must use IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS + for (unsigned n = 0; n < 16; n++) // why 16 ? + { + FChar temp[16]; + ConvertUInt32ToString(n, temp); + FString name = FTEXT("PhysicalDrive"); + name += temp; + FString fullPath = kVolPrefix; + fullPath += name; + + CFileInfo fi; + if (!fi.Find(fullPath)) + continue; + + CDriveInfo di; + di.Name = name; + di.FullSystemName = fullPath; + di.ClusterSize = 0; + di.DriveSize = fi.Size; + di.FreeSpace = 0; + di.DriveType = 0; + + di.IsPhysicalDrive = true; + di.KnownSize = true; + + _drives.Add(di); + } + } + return S_OK; } @@ -177,15 +215,15 @@ STDMETHODIMP CFSDrives::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT return E_INVALIDARG; NCOM::CPropVariant prop; const CDriveInfo &di = _drives[itemIndex]; - switch(propID) + switch (propID) { case kpidIsDir: prop = !_volumeMode; break; case kpidName: prop = di.Name; break; - case kpidTotalSize: if (di.KnownSizes) prop = di.DriveSize; break; + case kpidTotalSize: if (di.KnownSize) prop = di.DriveSize; break; case kpidFreeSpace: if (di.KnownSizes) prop = di.FreeSpace; break; case kpidClusterSize: if (di.KnownSizes) prop = di.ClusterSize; break; case kpidType: - if (di.DriveType < sizeof(kDriveTypes) / sizeof(kDriveTypes[0])) + if (di.DriveType < ARRAY_SIZE(kDriveTypes)) prop = kDriveTypes[di.DriveType]; break; case kpidVolumeName: prop = di.VolumeName; break; @@ -202,7 +240,14 @@ HRESULT CFSDrives::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder) return S_OK; NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; CMyComPtr subFolder = fsFolderSpec; - RINOK(fsFolderSpec->Init(name, 0)); + if (_longMode) + { + RINOK(fsFolderSpec->Init((FString)kLongPrefix + name, 0)); + } + else + { + RINOK(fsFolderSpec->Init(name, 0)); + } *resultFolder = subFolder.Detach(); return S_OK; } @@ -243,15 +288,17 @@ IMP_IFolderFolder_Props(CFSDrives) STDMETHODIMP CFSDrives::GetFolderProperty(PROPID propID, PROPVARIANT *value) { COM_TRY_BEGIN - NWindows::NCOM::CPropVariant prop; - switch(propID) + NCOM::CPropVariant prop; + switch (propID) { - case kpidType: prop = L"FSDrives"; break; + case kpidType: prop = "FSDrives"; break; case kpidPath: if (_volumeMode) - prop = fs2us(kVolPrefix); + prop = kVolPrefix; + else if (_longMode) + prop = kLongPrefix; else - prop = LangString(IDS_COMPUTER, 0x03020300) + UString(WCHAR_PATH_SEPARATOR); + prop = (UString)LangString(IDS_COMPUTER) + WCHAR_PATH_SEPARATOR; break; } prop.Detach(value); @@ -264,6 +311,8 @@ STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) { *iconIndex = 0; const CDriveInfo &di = _drives[index]; + if (di.IsPhysicalDrive) + return S_OK; int iconIndexTemp; if (GetRealIconIndex(di.FullSystemName, 0, iconIndexTemp) != 0) { @@ -273,10 +322,10 @@ STDMETHODIMP CFSDrives::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) return GetLastError(); } -UString CFSDrives::GetExt(int index) const +const wchar_t *CFSDrives::GetExt(unsigned index) const { const CDriveInfo &di = _drives[index]; - const wchar_t *ext = NULL; + const wchar_t *ext; if (di.DriveType == DRIVE_CDROM) ext = L"iso"; else if (di.FileSystemName.Find(L"NTFS") >= 0) @@ -285,23 +334,27 @@ UString CFSDrives::GetExt(int index) const ext = L"fat"; else ext = L"img"; - return (UString)L'.' + ext; + return ext; } -HRESULT CFSDrives::GetLength(int index, UInt64 &length) const +HRESULT CFSDrives::GetFileSize(unsigned index, UInt64 &fileSize) const { - NFile::NIO::CInFile inFile; + NIO::CInFile inFile; if (!inFile.Open(_drives[index].GetDeviceFileIoName())) return GetLastError(); - if (!inFile.LengthDefined) + if (!inFile.SizeDefined) return E_FAIL; - length = inFile.Length; + fileSize = inFile.Size; return S_OK; } -STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems, +STDMETHODIMP CFSDrives::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems, + Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */, const wchar_t *path, IFolderOperationsExtractCallback *callback) { + if (moveMode) + return E_NOTIMPL; + if (numItems == 0) return S_OK; @@ -313,7 +366,7 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems, for (i = 0; i < numItems; i++) { const CDriveInfo &di = _drives[indices[i]]; - if (di.KnownSizes) + if (di.KnownSize) totalSize += di.DriveSize; } RINOK(callback->SetTotal(totalSize)); @@ -331,9 +384,10 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems, UInt64 completedSize = 0; RINOK(callback->SetCompleted(&completedSize)); + for (i = 0; i < numItems; i++) { - int index = indices[i]; + unsigned index = indices[i]; const CDriveInfo &di = _drives[index]; UString destPath2 = destPath; UString name = fs2us(di.Name); @@ -343,6 +397,7 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems, if (!destName.IsEmpty() && destName.Back() == L':') { destName.DeleteBack(); + destName += L'.'; destName += GetExt(index); } destPath2 += destName; @@ -350,11 +405,11 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems, FString srcPath = di.GetDeviceFileIoName(); UInt64 fileSize = 0; - if (GetLength(index, fileSize) != S_OK) + if (GetFileSize(index, fileSize) != S_OK) { return E_FAIL; } - if (!di.KnownSizes) + if (!di.KnownSize) totalSize += fileSize; RINOK(callback->SetTotal(totalSize)); @@ -375,16 +430,7 @@ STDMETHODIMP CFSDrives::CopyTo(const UInt32 *indices, UInt32 numItems, return S_OK; } -STDMETHODIMP CFSDrives::MoveTo( - const UInt32 * /* indices */, - UInt32 /* numItems */, - const wchar_t * /* path */, - IFolderOperationsExtractCallback * /* callback */) -{ - return E_NOTIMPL; -} - -STDMETHODIMP CFSDrives::CopyFrom(const wchar_t * /* fromFolderPath */, +STDMETHODIMP CFSDrives::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */, const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */) { return E_NOTIMPL; diff --git a/CPP/7zip/UI/FileManager/FSDrives.h b/CPP/7zip/UI/FileManager/FSDrives.h old mode 100755 new mode 100644 index a0cfd9be..a8e25d7d --- a/CPP/7zip/UI/FileManager/FSDrives.h +++ b/CPP/7zip/UI/FileManager/FSDrives.h @@ -3,8 +3,8 @@ #ifndef __FS_DRIVES_H #define __FS_DRIVES_H -#include "Common/MyCom.h" -#include "Common/MyString.h" +#include "../../../Common/MyCom.h" +#include "../../../Common/MyString.h" #include "IFolder.h" @@ -12,7 +12,6 @@ struct CDriveInfo { FString Name; FString FullSystemName; - bool KnownSizes; UInt64 DriveSize; UInt64 FreeSpace; UInt64 ClusterSize; @@ -21,7 +20,12 @@ struct CDriveInfo UString FileSystemName; UINT DriveType; + bool KnownSize; + bool KnownSizes; + bool IsPhysicalDrive; + FString GetDeviceFileIoName() const; + CDriveInfo(): KnownSize(false), KnownSizes(false), IsPhysicalDrive(false) {} }; class CFSDrives: @@ -32,10 +36,11 @@ class CFSDrives: { CObjectVector _drives; bool _volumeMode; + bool _longMode; HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder); - UString GetExt(int index) const; - HRESULT GetLength(int index, UInt64 &length) const; + const wchar_t *GetExt(unsigned index) const; + HRESULT GetFileSize(unsigned index, UInt64 &fileSize) const; public: MY_UNKNOWN_IMP2(IFolderGetSystemIconIndex, IFolderOperations) @@ -44,9 +49,10 @@ public: STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex); - void Init(bool volMode = false) + void Init(bool volMode = false, bool longMode = false) { _volumeMode = volMode; + _longMode = longMode; } }; diff --git a/CPP/7zip/UI/FileManager/FSFolder.cpp b/CPP/7zip/UI/FileManager/FSFolder.cpp old mode 100755 new mode 100644 index e4cb9f27..a8541eb2 --- a/CPP/7zip/UI/FileManager/FSFolder.cpp +++ b/CPP/7zip/UI/FileManager/FSFolder.cpp @@ -2,13 +2,15 @@ #include "StdAfx.h" -#include "Common/ComTry.h" -#include "Common/StringConvert.h" -#include "Common/UTFConvert.h" +#include "../../../Common/ComTry.h" +#include "../../../Common/Defs.h" +#include "../../../Common/StringConvert.h" +#include "../../../Common/UTFConvert.h" -#include "Windows/FileDir.h" -#include "Windows/FileIO.h" -#include "Windows/PropVariant.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/FileIO.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/PropVariant.h" #include "../../PropID.h" @@ -21,30 +23,49 @@ #include "SysIconUtils.h" -namespace NWindows { -namespace NFile { - -bool GetLongPath(CFSTR path, UString &longPath); - -}} +#if _WIN32_WINNT < 0x0501 +#ifdef _APISETFILE_ +// Windows SDK 8.1 defines in fileapi.h the function GetCompressedFileSizeW only if _WIN32_WINNT >= 0x0501 +// But real support version for that function is NT 3.1 (probably) +// So we must define GetCompressedFileSizeW +EXTERN_C_BEGIN +WINBASEAPI DWORD WINAPI GetCompressedFileSizeW(LPCWSTR lpFileName, LPDWORD lpFileSizeHigh ); +EXTERN_C_END +#endif +#endif using namespace NWindows; using namespace NFile; using namespace NFind; +using namespace NDir; +using namespace NName; + +#ifndef USE_UNICODE_FSTRING +int CompareFileNames_ForFolderList(const FChar *s1, const FChar *s2) +{ + return CompareFileNames_ForFolderList(fs2us(s1), fs2us(s2)); +} +#endif namespace NFsFolder { -static STATPROPSTG kProps[] = -{ - { NULL, kpidName, VT_BSTR}, - { NULL, kpidSize, VT_UI8}, - { NULL, kpidMTime, VT_FILETIME}, - { NULL, kpidCTime, VT_FILETIME}, - { NULL, kpidATime, VT_FILETIME}, - { NULL, kpidAttrib, VT_UI4}, - { NULL, kpidPackSize, VT_UI8}, - { NULL, kpidComment, VT_BSTR}, - { NULL, kpidPrefix, VT_BSTR} +static const Byte kProps[] = +{ + kpidName, + kpidSize, + kpidMTime, + kpidCTime, + kpidATime, + kpidAttrib, + kpidPackSize, + #ifdef FS_SHOW_LINKS_INFO + kpidINode, + kpidLinks, + #endif + kpidComment, + kpidNumSubDirs, + kpidNumSubFiles, + kpidPrefix }; HRESULT CFSFolder::Init(const FString &path, IFolderFolder *parentFolder) @@ -72,96 +93,173 @@ HRESULT CFSFolder::Init(const FString &path, IFolderFolder *parentFolder) return S_OK; } -static HRESULT GetFolderSize(const FString &path, UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress) +HRESULT CFsFolderStat::Enumerate() { - RINOK(progress->SetCompleted(NULL)); - numFiles = numFolders = size = 0; - CEnumerator enumerator(path + FSTRING_PATH_SEPARATOR FSTRING_ANY_MASK); + if (Progress) + { + RINOK(Progress->SetCompleted(NULL)); + } + Path += FCHAR_PATH_SEPARATOR; + unsigned len = Path.Len(); + Path += FCHAR_ANY_MASK; + CEnumerator enumerator(Path); CFileInfo fi; while (enumerator.Next(fi)) { if (fi.IsDir()) { - UInt64 subFolders, subFiles, subSize; - RINOK(GetFolderSize(path + FCHAR_PATH_SEPARATOR + fi.Name, subFolders, subFiles, subSize, progress)); - numFolders += subFolders; - numFolders++; - numFiles += subFiles; - size += subSize; + Path.DeleteFrom(len); + Path += fi.Name; + RINOK(Enumerate()); + NumFolders++; } else { - numFiles++; - size += fi.Size; + NumFiles++; + Size += fi.Size; } } return S_OK; } -HRESULT CFSFolder::LoadSubItems(CDirItem &dirItem, const FString &path) +#ifndef UNDER_CE + +static bool MyGetCompressedFileSizeW(CFSTR path, UInt64 &size) +{ + DWORD highPart; + DWORD lowPart = INVALID_FILE_SIZE; + IF_USE_MAIN_PATH + { + lowPart = ::GetCompressedFileSizeW(fs2us(path), &highPart); + if (lowPart != INVALID_FILE_SIZE || ::GetLastError() == NO_ERROR) + { + size = ((UInt64)highPart << 32) | lowPart; + return true; + } + } + #ifdef WIN_LONG_PATH + if (USE_SUPER_PATH) + { + UString longPath; + if (GetSuperPath(path, longPath, USE_MAIN_PATH)) + { + lowPart = ::GetCompressedFileSizeW(longPath, &highPart); + if (lowPart != INVALID_FILE_SIZE || ::GetLastError() == NO_ERROR) + { + size = ((UInt64)highPart << 32) | lowPart; + return true; + } + } + } + #endif + return false; +} + +#endif + +HRESULT CFSFolder::LoadSubItems(int dirItem, const FString &relPrefix) { + unsigned startIndex = Folders.Size(); { - CEnumerator enumerator(path + FCHAR_ANY_MASK); + CEnumerator enumerator(_path + relPrefix + FCHAR_ANY_MASK); CDirItem fi; + fi.FolderStat_Defined = false; + fi.NumFolders = 0; + fi.NumFiles = 0; + fi.Parent = dirItem; + while (enumerator.Next(fi)) { - #ifndef UNDER_CE - fi.CompressedSizeIsDefined = false; - /* - if (!GetCompressedFileSize(_path + fi.Name, - fi.CompressedSize)) - fi.CompressedSize = fi.Size; - */ - #endif if (fi.IsDir()) { - // fi.Size = GetFolderSize(_path + fi.Name); fi.Size = 0; + if (_flatMode) + Folders.Add(relPrefix + fi.Name + FCHAR_PATH_SEPARATOR); + } + else + { + /* + fi.PackSize_Defined = true; + if (!MyGetCompressedFileSizeW(_path + relPrefix + fi.Name, fi.PackSize)) + fi.PackSize = fi.Size; + */ + } + + #ifndef UNDER_CE + + fi.Reparse.Free(); + fi.PackSize_Defined = false; + + #ifdef FS_SHOW_LINKS_INFO + fi.FileInfo_Defined = false; + fi.FileInfo_WasRequested = false; + fi.FileIndex = 0; + fi.NumLinks = 0; + #endif + + fi.PackSize = fi.Size; + if (fi.HasReparsePoint()) + { + fi.FileInfo_WasRequested = true; + BY_HANDLE_FILE_INFORMATION info; + NIO::GetReparseData(_path + relPrefix + fi.Name, fi.Reparse, &info); + fi.NumLinks = info.nNumberOfLinks; + fi.FileIndex = (((UInt64)info.nFileIndexHigh) << 32) + info.nFileIndexLow; + fi.FileInfo_Defined = true; } - dirItem.Files.Add(fi); + + #endif + + /* unsigned fileIndex = */ Files.Add(fi); + + #if defined(_WIN32) && !defined(UNDER_CE) + /* + if (_scanAltStreams) + { + CStreamEnumerator enumerator(_path + relPrefix + fi.Name); + CStreamInfo si; + for (;;) + { + bool found; + if (!enumerator.Next(si, found)) + { + // if (GetLastError() == ERROR_ACCESS_DENIED) + // break; + // return E_FAIL; + break; + } + if (!found) + break; + if (si.IsMainStream()) + continue; + CAltStream ss; + ss.Parent = fileIndex; + ss.Name = si.GetReducedName(); + ss.Size = si.Size; + ss.PackSize_Defined = false; + ss.PackSize = si.Size; + Streams.Add(ss); + } + } + */ + #endif } } if (!_flatMode) return S_OK; - for (int i = 0; i < dirItem.Files.Size(); i++) - { - CDirItem &item = dirItem.Files[i]; - if (item.IsDir()) - LoadSubItems(item, path + item.Name + FCHAR_PATH_SEPARATOR); - } + unsigned endIndex = Folders.Size(); + for (unsigned i = startIndex; i < endIndex; i++) + LoadSubItems(i, Folders[i]); return S_OK; } -void CFSFolder::AddRefs(CDirItem &dirItem) -{ - int i; - for (i = 0; i < dirItem.Files.Size(); i++) - { - CDirItem &item = dirItem.Files[i]; - item.Parent = &dirItem; - _refs.Add(&item); - } - if (!_flatMode) - return; - for (i = 0; i < dirItem.Files.Size(); i++) - { - CDirItem &item = dirItem.Files[i]; - if (item.IsDir()) - AddRefs(item); - } -} - STDMETHODIMP CFSFolder::LoadItems() { - // OutputDebugString(TEXT("Start\n")); Int32 dummy; WasChanged(&dummy); Clear(); - RINOK(LoadSubItems(_root, _path)); - AddRefs(_root); - - // OutputDebugString(TEXT("Finish\n")); + RINOK(LoadSubItems(-1, FString())); _commentsAreLoaded = false; return S_OK; } @@ -170,25 +268,23 @@ static CFSTR kDescriptionFileName = FTEXT("descript.ion"); bool CFSFolder::LoadComments() { - if (_commentsAreLoaded) - return true; _comments.Clear(); _commentsAreLoaded = true; NIO::CInFile file; if (!file.Open(_path + kDescriptionFileName)) return false; - UInt64 length; - if (!file.GetLength(length)) + UInt64 len; + if (!file.GetLength(len)) return false; - if (length >= (1 << 28)) + if (len >= (1 << 28)) return false; AString s; - char *p = s.GetBuffer((int)((size_t)length + 1)); + char *p = s.GetBuffer((unsigned)((size_t)len + 1)); UInt32 processedSize; - file.Read(p, (UInt32)length, processedSize); - p[length] = 0; + file.Read(p, (UInt32)len, processedSize); + p[len] = 0; s.ReleaseBuffer(); - if (processedSize != length) + if (processedSize != len) return false; file.Close(); UString unicodeString; @@ -197,122 +293,394 @@ bool CFSFolder::LoadComments() return _comments.ReadFromString(unicodeString); } -static bool IsAscii(const UString &testString) +static bool IsAscii(const AString &s) { - for (int i = 0; i < testString.Length(); i++) - if (testString[i] >= 0x80) + for (unsigned i = 0; i < s.Len(); i++) + if ((Byte)s[i] >= 0x80) return false; return true; } bool CFSFolder::SaveComments() { - NIO::COutFile file; - if (!file.Create(_path + kDescriptionFileName, true)) - return false; - UString unicodeString; - _comments.SaveToString(unicodeString); - AString utfString; - ConvertUnicodeToUTF8(unicodeString, utfString); - UInt32 processedSize; - if (!IsAscii(unicodeString)) + AString utf; { - Byte bom [] = { 0xEF, 0xBB, 0xBF, 0x0D, 0x0A }; - file.Write(bom , sizeof(bom), processedSize); + UString unicode; + _comments.SaveToString(unicode); + ConvertUnicodeToUTF8(unicode, utf); + } + if (!IsAscii(utf)) + utf.Insert(0, "\xEF\xBB\xBF" "\r\n"); + + FString path = _path + kDescriptionFileName; + // We must set same attrib. COutFile::CreateAlways can fail, if file has another attrib. + DWORD attrib = FILE_ATTRIBUTE_NORMAL; + { + CFileInfo fi; + if (fi.Find(path)) + attrib = fi.Attrib; } - file.Write(utfString, utfString.Length(), processedSize); + NIO::COutFile file; + if (!file.CreateAlways(path, attrib)) + return false; + UInt32 processed; + file.Write(utf, utf.Len(), processed); _commentsAreLoaded = false; return true; } STDMETHODIMP CFSFolder::GetNumberOfItems(UInt32 *numItems) { - *numItems = _refs.Size(); + *numItems = Files.Size() /* + Streams.Size() */; return S_OK; } -/* -STDMETHODIMP CFSFolder::GetNumberOfSubFolders(UInt32 *numSubFolders) +#ifdef USE_UNICODE_FSTRING + +STDMETHODIMP CFSFolder::GetItemPrefix(UInt32 index, const wchar_t **name, unsigned *len) { - UInt32 numSubFoldersLoc = 0; - for (int i = 0; i < _files.Size(); i++) - if (_files[i].IsDir()) - numSubFoldersLoc++; - *numSubFolders = numSubFoldersLoc; + *name = 0; + *len = 0; + /* + if (index >= Files.Size()) + index = Streams[index - Files.Size()].Parent; + */ + CDirItem &fi = Files[index]; + if (fi.Parent >= 0) + { + const FString &fo = Folders[fi.Parent]; + USE_UNICODE_FSTRING + *name = fo; + *len = fo.Len(); + } return S_OK; } -*/ -#ifndef UNDER_CE -static bool MyGetCompressedFileSizeW(CFSTR fileName, UInt64 &size) +STDMETHODIMP CFSFolder::GetItemName(UInt32 index, const wchar_t **name, unsigned *len) { - DWORD highPart; - DWORD lowPart = ::GetCompressedFileSizeW(fs2us(fileName), &highPart); - if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR) + *name = 0; + *len = 0; + if (index < Files.Size()) { - #ifdef WIN_LONG_PATH - { - UString longPath; - if (GetLongPath(fileName, longPath)) - lowPart = ::GetCompressedFileSizeW(longPath, &highPart); - } - #endif - if (lowPart == INVALID_FILE_SIZE && ::GetLastError() != NO_ERROR) - return false; + CDirItem &fi = Files[index]; + *name = fi.Name; + *len = fi.Name.Len(); + return S_OK; + } + else + { + // const CAltStream &ss = Streams[index - Files.Size()]; + // *name = ss.Name; + // *len = ss.Name.Len(); + // + // change it; } - size = (UInt64(highPart) << 32) | lowPart; + return S_OK; +} + +STDMETHODIMP_(UInt64) CFSFolder::GetItemSize(UInt32 index) +{ + /* + if (index >= Files.Size()) + return Streams[index - Files.Size()].Size; + */ + CDirItem &fi = Files[index]; + return fi.IsDir() ? 0 : fi.Size; +} + +#endif + +#ifdef FS_SHOW_LINKS_INFO +bool CFSFolder::ReadFileInfo(CDirItem &di) +{ + di.FileInfo_WasRequested = true; + BY_HANDLE_FILE_INFORMATION info; + if (!NIO::CFileBase::GetFileInformation(_path + GetRelPath(di), &info)) + return false; + di.NumLinks = info.nNumberOfLinks; + di.FileIndex = (((UInt64)info.nFileIndexHigh) << 32) + info.nFileIndexLow; + di.FileInfo_Defined = true; return true; } #endif -STDMETHODIMP CFSFolder::GetProperty(UInt32 itemIndex, PROPID propID, PROPVARIANT *value) +STDMETHODIMP CFSFolder::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *value) { NCOM::CPropVariant prop; - if (itemIndex >= (UInt32)_refs.Size()) - return E_INVALIDARG; - CDirItem &fi = *_refs[itemIndex]; - switch(propID) + /* + if (index >= (UInt32)Files.Size()) + { + CAltStream &ss = Streams[index - Files.Size()]; + CDirItem &fi = Files[ss.Parent]; + switch (propID) + { + case kpidIsDir: prop = false; break; + case kpidIsAltStream: prop = true; break; + case kpidName: prop = fs2us(fi.Name) + ss.Name; break; + case kpidSize: prop = ss.Size; break; + case kpidPackSize: + #ifdef UNDER_CE + prop = ss.Size; + #else + if (!ss.PackSize_Defined) + { + ss.PackSize_Defined = true; + if (!MyGetCompressedFileSizeW(_path + GetRelPath(fi) + us2fs(ss.Name), ss.PackSize)) + ss.PackSize = ss.Size; + } + prop = ss.PackSize; + #endif + break; + case kpidComment: break; + default: index = ss.Parent; + } + if (index >= (UInt32)Files.Size()) + { + prop.Detach(value); + return S_OK; + } + } + */ + CDirItem &fi = Files[index]; + switch (propID) { case kpidIsDir: prop = fi.IsDir(); break; + case kpidIsAltStream: prop = false; break; case kpidName: prop = fs2us(fi.Name); break; - case kpidSize: if (!fi.IsDir()) prop = fi.Size; break; + case kpidSize: if (!fi.IsDir() || fi.FolderStat_Defined) prop = fi.Size; break; case kpidPackSize: #ifdef UNDER_CE prop = fi.Size; #else - if (!fi.CompressedSizeIsDefined) + if (!fi.PackSize_Defined) { - fi.CompressedSizeIsDefined = true; - if (fi.IsDir () || - !MyGetCompressedFileSizeW(_path + GetRelPath(fi), fi.CompressedSize)) - fi.CompressedSize = fi.Size; + fi.PackSize_Defined = true; + if (fi.IsDir () || !MyGetCompressedFileSizeW(_path + GetRelPath(fi), fi.PackSize)) + fi.PackSize = fi.Size; } - prop = fi.CompressedSize; + prop = fi.PackSize; #endif break; + + #ifdef FS_SHOW_LINKS_INFO + + case kpidLinks: + #ifdef UNDER_CE + // prop = fi.NumLinks; + #else + if (!fi.FileInfo_WasRequested) + ReadFileInfo(fi); + if (fi.FileInfo_Defined) + prop = fi.NumLinks; + #endif + break; + + case kpidINode: + #ifdef UNDER_CE + // prop = fi.FileIndex; + #else + if (!fi.FileInfo_WasRequested) + ReadFileInfo(fi); + if (fi.FileInfo_Defined) + prop = fi.FileIndex; + #endif + break; + + #endif + case kpidAttrib: prop = (UInt32)fi.Attrib; break; case kpidCTime: prop = fi.CTime; break; case kpidATime: prop = fi.ATime; break; case kpidMTime: prop = fi.MTime; break; case kpidComment: { - LoadComments(); + if (!_commentsAreLoaded) + LoadComments(); UString comment; if (_comments.GetValue(fs2us(GetRelPath(fi)), comment)) + { + int pos = comment.Find((wchar_t)4); + if (pos >= 0) + comment.DeleteFrom(pos); prop = comment; + } break; } case kpidPrefix: - { - if (_flatMode) - prop = GetPrefix(fi); + if (fi.Parent >= 0) + prop = Folders[fi.Parent]; break; - } + case kpidNumSubDirs: if (fi.IsDir() && fi.FolderStat_Defined) prop = fi.NumFolders; break; + case kpidNumSubFiles: if (fi.IsDir() && fi.FolderStat_Defined) prop = fi.NumFiles; break; } prop.Detach(value); return S_OK; } + +// ---------- IArchiveGetRawProps ---------- + + +STDMETHODIMP CFSFolder::GetNumRawProps(UInt32 *numProps) +{ + *numProps = 1; + return S_OK; +} + +STDMETHODIMP CFSFolder::GetRawPropInfo(UInt32 index, BSTR *name, PROPID *propID) +{ + index = index; + *name = NULL; + *propID = kpidNtReparse; + return S_OK; +} + +STDMETHODIMP CFSFolder::GetParent(UInt32 /* index */, UInt32 * /* parent */, UInt32 * /* parentType */) +{ + return E_FAIL; +} + +STDMETHODIMP CFSFolder::GetRawProp(UInt32 + #ifndef UNDER_CE + index + #endif + , PROPID + #ifndef UNDER_CE + propID + #endif + , const void **data, UInt32 *dataSize, UInt32 *propType) +{ + *data = NULL; + *dataSize = 0; + *propType = 0; + + #ifndef UNDER_CE + if (propID == kpidNtReparse) + { + const CDirItem &fi = Files[index]; + const CByteBuffer &buf = fi.Reparse; + if (buf.Size() == 0) + return S_OK; + *data = buf; + *dataSize = (UInt32)buf.Size(); + *propType = NPropDataType::kRaw; + return S_OK; + } + #endif + + return S_OK; +} + + +// returns Position of extension including '.' + +static inline CFSTR GetExtensionPtr(const FString &name) +{ + int dotPos = name.ReverseFind(FTEXT('.')); + return name.Ptr((dotPos < 0) ? name.Len() : dotPos); +} + +STDMETHODIMP_(Int32) CFSFolder::CompareItems(UInt32 index1, UInt32 index2, PROPID propID, Int32 /* propIsRaw */) +{ + /* + const CAltStream *ss1 = NULL; + const CAltStream *ss2 = NULL; + if (index1 >= (UInt32)Files.Size()) { ss1 = &Streams[index1 - Files.Size()]; index1 = ss1->Parent; } + if (index2 >= (UInt32)Files.Size()) { ss2 = &Streams[index2 - Files.Size()]; index2 = ss2->Parent; } + */ + CDirItem &fi1 = Files[index1]; + CDirItem &fi2 = Files[index2]; + + switch (propID) + { + case kpidName: + { + int comp = CompareFileNames_ForFolderList(fi1.Name, fi2.Name); + /* + if (comp != 0) + return comp; + if (!ss1) + return ss2 ? -1 : 0; + if (!ss2) + return 1; + return MyStringCompareNoCase(ss1->Name, ss2->Name); + */ + return comp; + } + case kpidSize: + return MyCompare( + /* ss1 ? ss1->Size : */ fi1.Size, + /* ss2 ? ss2->Size : */ fi2.Size); + case kpidAttrib: return MyCompare(fi1.Attrib, fi2.Attrib); + case kpidCTime: return CompareFileTime(&fi1.CTime, &fi2.CTime); + case kpidATime: return CompareFileTime(&fi1.ATime, &fi2.ATime); + case kpidMTime: return CompareFileTime(&fi1.MTime, &fi2.MTime); + case kpidIsDir: + { + bool isDir1 = /* ss1 ? false : */ fi1.IsDir(); + bool isDir2 = /* ss2 ? false : */ fi2.IsDir(); + if (isDir1 == isDir2) + return 0; + return isDir1 ? -1 : 1; + } + case kpidPackSize: + { + #ifdef UNDER_CE + return MyCompare(fi1.Size, fi2.Size); + #else + // PackSize can be undefined here + return MyCompare( + /* ss1 ? ss1->PackSize : */ fi1.PackSize, + /* ss2 ? ss2->PackSize : */ fi2.PackSize); + #endif + } + + #ifdef FS_SHOW_LINKS_INFO + case kpidINode: + { + #ifndef UNDER_CE + if (!fi1.FileInfo_WasRequested) ReadFileInfo(fi1); + if (!fi2.FileInfo_WasRequested) ReadFileInfo(fi2); + return MyCompare( + fi1.FileIndex, + fi2.FileIndex); + #endif + } + case kpidLinks: + { + #ifndef UNDER_CE + if (!fi1.FileInfo_WasRequested) ReadFileInfo(fi1); + if (!fi2.FileInfo_WasRequested) ReadFileInfo(fi2); + return MyCompare( + fi1.NumLinks, + fi2.NumLinks); + #endif + } + #endif + + case kpidComment: + { + // change it ! + UString comment1, comment2; + _comments.GetValue(fs2us(GetRelPath(fi1)), comment1); + _comments.GetValue(fs2us(GetRelPath(fi2)), comment2); + return MyStringCompareNoCase(comment1, comment2); + } + case kpidPrefix: + if (fi1.Parent < 0) return (fi2.Parent < 0) ? 0 : -1; + if (fi2.Parent < 0) return 1; + return CompareFileNames_ForFolderList( + Folders[fi1.Parent], + Folders[fi2.Parent]); + case kpidExtension: + return CompareFileNames_ForFolderList( + GetExtensionPtr(fi1.Name), + GetExtensionPtr(fi2.Name)); + } + + return 0; +} + HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder) { *resultFolder = 0; @@ -323,27 +691,57 @@ HRESULT CFSFolder::BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder) return S_OK; } -FString CFSFolder::GetPrefix(const CDirItem &item) const +/* +void CFSFolder::GetPrefix(const CDirItem &item, FString &prefix) const { - FString path; - CDirItem *cur = item.Parent; - while (cur->Parent != 0) + if (item.Parent >= 0) + prefix = Folders[item.Parent]; + else + prefix.Empty(); +} +*/ +/* +void CFSFolder::GetPrefix(const CDirItem &item, FString &prefix) const +{ + int parent = item.Parent; + + unsigned len = 0; + + while (parent >= 0) + { + const CDirItem &cur = Files[parent]; + len += cur.Name.Len() + 1; + parent = cur.Parent; + } + + unsigned totalLen = len; + wchar_t *p = prefix.GetBuffer(len); + parent = item.Parent; + + while (parent >= 0) { - path = cur->Name + FCHAR_PATH_SEPARATOR + path; - cur = cur->Parent; + const CDirItem &cur = Files[parent]; + // path = cur->Name + FCHAR_PATH_SEPARATOR + path; + MyStringCopy(p + len - cur.Name.Len() - 1, (const wchar_t *)cur.Name); + p[--len] = FCHAR_PATH_SEPARATOR; + len -= cur.Name.Len(); + parent = cur.Parent; } - return path; + prefix.ReleaseBuffer(totalLen); } +*/ FString CFSFolder::GetRelPath(const CDirItem &item) const { - return GetPrefix(item) + item.Name; + if (item.Parent < 0) + return item.Name; + return Folders[item.Parent] + item.Name; } STDMETHODIMP CFSFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolder) { *resultFolder = 0; - const CDirItem &fi = *_refs[index]; + const CDirItem &fi = Files[index]; if (!fi.IsDir()) return E_INVALIDARG; return BindToFolderSpec(GetRelPath(fi), resultFolder); @@ -354,6 +752,8 @@ STDMETHODIMP CFSFolder::BindToFolder(const wchar_t *name, IFolderFolder **result return BindToFolderSpec(us2fs(name), resultFolder); } +static CFSTR kLongPrefix = FTEXT("\\\\?\\"); + STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) { *resultFolder = 0; @@ -366,7 +766,7 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) if (_path.IsEmpty()) return E_INVALIDARG; int pos = _path.ReverseFind(FCHAR_PATH_SEPARATOR); - if (pos < 0 || pos != _path.Length() - 1) + if (pos < 0 || pos != (int)_path.Len() - 1) return E_FAIL; FString parentPath = _path.Left(pos); pos = parentPath.ReverseFind(FCHAR_PATH_SEPARATOR); @@ -382,8 +782,24 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) #endif return S_OK; } + + parentPath.DeleteFrom(pos + 1); + + if (parentPath == kLongPrefix) + { + #ifdef UNDER_CE + *resultFolder = 0; + #else + CFSDrives *drivesFolderSpec = new CFSDrives; + CMyComPtr drivesFolder = drivesFolderSpec; + drivesFolderSpec->Init(false, true); + *resultFolder = drivesFolder.Detach(); + #endif + return S_OK; + } + FString parentPathReduced = parentPath.Left(pos); - parentPath = parentPath.Left(pos + 1); + #ifndef UNDER_CE pos = parentPathReduced.ReverseFind(FCHAR_PATH_SEPARATOR); if (pos == 1) @@ -397,6 +813,7 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) return S_OK; } #endif + CFSFolder *parentFolderSpec = new CFSFolder; CMyComPtr parentFolder = parentFolderSpec; RINOK(parentFolderSpec->Init(parentPath, 0)); @@ -406,7 +823,7 @@ STDMETHODIMP CFSFolder::BindToParentFolder(IFolderFolder **resultFolder) STDMETHODIMP CFSFolder::GetNumberOfProperties(UInt32 *numProperties) { - *numProperties = sizeof(kProps) / sizeof(kProps[0]); + *numProperties = ARRAY_SIZE(kProps); if (!_flatMode) (*numProperties)--; return S_OK; @@ -418,7 +835,7 @@ STDMETHODIMP CFSFolder::GetFolderProperty(PROPID propID, PROPVARIANT *value) { COM_TRY_BEGIN NWindows::NCOM::CPropVariant prop; - switch(propID) + switch (propID) { case kpidType: prop = L"FSFolder"; break; case kpidPath: prop = fs2us(_path); break; @@ -462,58 +879,49 @@ STDMETHODIMP CFSFolder::Clone(IFolderFolder **resultFolder) return S_OK; } -HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, - UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress) +HRESULT CFSFolder::GetItemsFullSize(const UInt32 *indices, UInt32 numItems, CFsFolderStat &stat) { - numFiles = numFolders = size = 0; - UInt32 i; - for (i = 0; i < numItems; i++) + for (UInt32 i = 0; i < numItems; i++) { - int index = indices[i]; - if (index >= _refs.Size()) - return E_INVALIDARG; - const CDirItem &fi = *_refs[index]; + UInt32 index = indices[i]; + /* + if (index >= Files.Size()) + { + size += Streams[index - Files.Size()].Size; + // numFiles++; + continue; + } + */ + const CDirItem &fi = Files[index]; if (fi.IsDir()) { - UInt64 subFolders, subFiles, subSize; - RINOK(GetFolderSize(_path + GetRelPath(fi), subFolders, subFiles, subSize, progress)); - numFolders += subFolders; - numFolders++; - numFiles += subFiles; - size += subSize; + stat.Path = _path; + stat.Path += GetRelPath(fi); + RINOK(stat.Enumerate()); + stat.NumFolders++; } else { - numFiles++; - size += fi.Size; + stat.NumFiles++; + stat.Size += fi.Size; } } return S_OK; } -HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) +/* +HRESULT CFSFolder::GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress) { - const CDirItem &fi = *_refs[index]; + if (index >= Files.Size()) + { + size = Streams[index - Files.Size()].Size; + return S_OK; + } + const CDirItem &fi = Files[index]; if (fi.IsDir()) { - /* - CMyComPtr subFolder; - RINOK(BindToFolder(index, &subFolder)); - CMyComPtr aFolderReload; - subFolder.QueryInterface(&aFolderReload); - aFolderReload->Reload(); - UInt32 numItems; - RINOK(subFolder->GetNumberOfItems(&numItems)); - CMyComPtr aGetItemFullSize; - subFolder.QueryInterface(&aGetItemFullSize); - for (UInt32 i = 0; i < numItems; i++) - { - UInt64 size; - RINOK(aGetItemFullSize->GetItemFullSize(i, &size)); - *totalSize += size; - } - */ - UInt64 numFolders, numFiles; + UInt64 numFolders = 0, numFiles = 0; + size = 0; return GetFolderSize(_path + GetRelPath(fi), numFolders, numFiles, size, progress); } size = fi.Size; @@ -523,61 +931,72 @@ HRESULT CFSFolder::GetItemFullSize(int index, UInt64 &size, IProgress *progress) STDMETHODIMP CFSFolder::GetItemFullSize(UInt32 index, PROPVARIANT *value, IProgress *progress) { NCOM::CPropVariant prop; - if (index >= (UInt32)_refs.Size()) - return E_INVALIDARG; UInt64 size = 0; HRESULT result = GetItemFullSize(index, size, progress); prop = size; prop.Detach(value); return result; } +*/ -HRESULT CFSFolder::GetComplexName(CFSTR name, FString &resultPath) +STDMETHODIMP CFSFolder::CalcItemFullSize(UInt32 index, IProgress *progress) { - FString newName = name; - resultPath = _path + newName; - if (newName.Length() < 1) - return S_OK; - if (newName[0] == FCHAR_PATH_SEPARATOR) - { - resultPath = newName; + if (index >= (UInt32)Files.Size()) return S_OK; - } - if (newName.Length() < 2) + CDirItem &fi = Files[index]; + if (!fi.IsDir()) return S_OK; - if (newName[1] == L':') - resultPath = newName; + CFsFolderStat stat(_path + GetRelPath(fi), progress); + RINOK(stat.Enumerate()); + fi.Size = stat.Size; + fi.NumFolders = stat.NumFolders; + fi.NumFiles = stat.NumFiles; + fi.FolderStat_Defined = true; return S_OK; } +void CFSFolder::GetAbsPath(const wchar_t *name, FString &absPath) +{ + absPath.Empty(); + if (!IsAbsolutePath(name)) + absPath += _path; + absPath += us2fs(name); +} + STDMETHODIMP CFSFolder::CreateFolder(const wchar_t *name, IProgress * /* progress */) { - FString processedName; - RINOK(GetComplexName(us2fs(name), processedName)); - if (NDirectory::MyCreateDirectory(processedName)) + FString absPath; + GetAbsPath(name, absPath); + if (CreateDir(absPath)) return S_OK; if (::GetLastError() == ERROR_ALREADY_EXISTS) return ::GetLastError(); - if (!NDirectory::CreateComplexDirectory(processedName)) + if (!CreateComplexDir(absPath)) return ::GetLastError(); return S_OK; } STDMETHODIMP CFSFolder::CreateFile(const wchar_t *name, IProgress * /* progress */) { - FString processedName; - RINOK(GetComplexName(us2fs(name), processedName)); + FString absPath; + GetAbsPath(name, absPath); NIO::COutFile outFile; - if (!outFile.Create(processedName, false)) + if (!outFile.Create(absPath, false)) return ::GetLastError(); return S_OK; } STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * /* progress */) { - const CDirItem &fi = *_refs[index]; - const FString fullPrefix = _path + GetPrefix(fi); - if (!NDirectory::MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName))) + if (index >= (UInt32)Files.Size()) + return E_NOTIMPL; + const CDirItem &fi = Files[index]; + // FString prefix; + // GetPrefix(fi, prefix); + FString fullPrefix = _path; + if (fi.Parent >= 0) + fullPrefix += Folders[fi.Parent]; + if (!MyMoveFile(fullPrefix + fi.Name, fullPrefix + us2fs(newName))) return GetLastError(); return S_OK; } @@ -585,15 +1004,33 @@ STDMETHODIMP CFSFolder::Rename(UInt32 index, const wchar_t *newName, IProgress * STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress *progress) { RINOK(progress->SetTotal(numItems)); + int prevDeletedFileIndex = -1; for (UInt32 i = 0; i < numItems; i++) { - const CDirItem &fi = *_refs[indices[i]]; - const FString fullPath = _path + GetRelPath(fi); - bool result; - if (fi.IsDir()) - result = NDirectory::RemoveDirectoryWithSubItems(fullPath); + // Sleep(200); + UInt32 index = indices[i]; + bool result = true; + /* + if (index >= (UInt32)Files.Size()) + { + const CAltStream &ss = Streams[index - (UInt32)Files.Size()]; + if (prevDeletedFileIndex != ss.Parent) + { + const CDirItem &fi = Files[ss.Parent]; + result = DeleteFileAlways(_path + GetRelPath(fi) + us2fs(ss.Name)); + } + } else - result = NDirectory::DeleteFileAlways(fullPath); + */ + { + const CDirItem &fi = Files[index]; + const FString fullPath = _path + GetRelPath(fi); + prevDeletedFileIndex = index; + if (fi.IsDir()) + result = RemoveDirWithSubItems(fullPath); + else + result = DeleteFileAlways(fullPath); + } if (!result) return GetLastError(); UInt64 completed = i; @@ -605,12 +1042,12 @@ STDMETHODIMP CFSFolder::Delete(const UInt32 *indices, UInt32 numItems,IProgress STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress * /* progress */) { - if (index >= (UInt32)_refs.Size()) + if (index >= (UInt32)Files.Size()) return E_INVALIDARG; - CDirItem &fi = *_refs[index]; - if (fi.Parent->Parent != 0) + CDirItem &fi = Files[index]; + if (fi.Parent >= 0) return E_NOTIMPL; - switch(propID) + switch (propID) { case kpidComment: { @@ -643,9 +1080,9 @@ STDMETHODIMP CFSFolder::SetProperty(UInt32 index, PROPID propID, STDMETHODIMP CFSFolder::GetSystemIconIndex(UInt32 index, Int32 *iconIndex) { - if (index >= (UInt32)_refs.Size()) + if (index >= (UInt32)Files.Size()) return E_INVALIDARG; - const CDirItem &fi = *_refs[index]; + const CDirItem &fi = Files[index]; *iconIndex = 0; int iconIndexTemp; if (GetRealIconIndex(_path + GetRelPath(fi), fi.Attrib, iconIndexTemp) != 0) @@ -662,4 +1099,12 @@ STDMETHODIMP CFSFolder::SetFlatMode(Int32 flatMode) return S_OK; } +/* +STDMETHODIMP CFSFolder::SetShowNtfsStreamsMode(Int32 showStreamsMode) +{ + _scanAltStreams = IntToBool(showStreamsMode); + return S_OK; +} +*/ + } diff --git a/CPP/7zip/UI/FileManager/FSFolder.h b/CPP/7zip/UI/FileManager/FSFolder.h old mode 100755 new mode 100644 index 13e9e018..cb0d4ec2 --- a/CPP/7zip/UI/FileManager/FSFolder.h +++ b/CPP/7zip/UI/FileManager/FSFolder.h @@ -3,116 +3,188 @@ #ifndef __FS_FOLDER_H #define __FS_FOLDER_H -#include "Common/MyCom.h" +#include "../../../Common/MyCom.h" +#include "../../../Common/MyBuffer.h" -#include "Windows/FileFind.h" +#include "../../../Windows/FileFind.h" #include "IFolder.h" #include "TextPairs.h" +#include "..\..\Archive\IArchive.h" namespace NFsFolder { class CFSFolder; -struct CFileInfoEx: public NWindows::NFile::NFind::CFileInfo +#define FS_SHOW_LINKS_INFO + +struct CDirItem: public NWindows::NFile::NFind::CFileInfo { #ifndef UNDER_CE - bool CompressedSizeIsDefined; - UInt64 CompressedSize; + UInt64 PackSize; + #endif + + #ifdef FS_SHOW_LINKS_INFO + UInt64 FileIndex; + UInt32 NumLinks; + bool FileInfo_Defined; + bool FileInfo_WasRequested; + #endif + + #ifndef UNDER_CE + bool PackSize_Defined; #endif + + bool FolderStat_Defined; + + #ifndef UNDER_CE + CByteBuffer Reparse; + #endif + + UInt64 NumFolders; + UInt64 NumFiles; + + int Parent; }; -struct CDirItem; +/* +struct CAltStream +{ + UInt64 Size; + UInt64 PackSize; + bool PackSize_Defined; + int Parent; + UString Name; +}; +*/ -struct CDirItem: public CFileInfoEx +struct CFsFolderStat { - CDirItem *Parent; - CObjectVector Files; + UInt64 NumFolders; + UInt64 NumFiles; + UInt64 Size; + IProgress *Progress; + FString Path; - CDirItem(): Parent(0) {} - void Clear() - { - Files.Clear(); - Parent = 0; - } + CFsFolderStat(): NumFolders(0), NumFiles(0), Size(0), Progress(NULL) {} + CFsFolderStat(const FString &path, IProgress *progress = NULL): + NumFolders(0), NumFiles(0), Size(0), Progress(progress), Path(path) {} + + HRESULT Enumerate(); }; class CFSFolder: public IFolderFolder, + public IArchiveGetRawProps, + public IFolderCompare, + #ifdef USE_UNICODE_FSTRING + public IFolderGetItemName, + #endif public IFolderWasChanged, public IFolderOperations, // public IFolderOperationsDeleteToRecycleBin, - public IFolderGetItemFullSize, + public IFolderCalcItemFullSize, public IFolderClone, public IFolderGetSystemIconIndex, public IFolderSetFlatMode, + // public IFolderSetShowNtfsStreamsMode, public CMyUnknownImp { - UInt64 GetSizeOfItem(int anIndex) const; public: MY_QUERYINTERFACE_BEGIN2(IFolderFolder) + MY_QUERYINTERFACE_ENTRY(IArchiveGetRawProps) + MY_QUERYINTERFACE_ENTRY(IFolderCompare) + #ifdef USE_UNICODE_FSTRING + MY_QUERYINTERFACE_ENTRY(IFolderGetItemName) + #endif MY_QUERYINTERFACE_ENTRY(IFolderWasChanged) // MY_QUERYINTERFACE_ENTRY(IFolderOperationsDeleteToRecycleBin) MY_QUERYINTERFACE_ENTRY(IFolderOperations) - MY_QUERYINTERFACE_ENTRY(IFolderGetItemFullSize) + MY_QUERYINTERFACE_ENTRY(IFolderCalcItemFullSize) MY_QUERYINTERFACE_ENTRY(IFolderClone) MY_QUERYINTERFACE_ENTRY(IFolderGetSystemIconIndex) MY_QUERYINTERFACE_ENTRY(IFolderSetFlatMode) + // MY_QUERYINTERFACE_ENTRY(IFolderSetShowNtfsStreamsMode) MY_QUERYINTERFACE_END MY_ADDREF_RELEASE INTERFACE_FolderFolder(;) + INTERFACE_IArchiveGetRawProps(;) INTERFACE_FolderOperations(;) + STDMETHOD_(Int32, CompareItems)(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw); + + #ifdef USE_UNICODE_FSTRING + INTERFACE_IFolderGetItemName(;) + #endif STDMETHOD(WasChanged)(Int32 *wasChanged); STDMETHOD(Clone)(IFolderFolder **resultFolder); - STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress); + STDMETHOD(CalcItemFullSize)(UInt32 index, IProgress *progress); STDMETHOD(SetFlatMode)(Int32 flatMode); + // STDMETHOD(SetShowNtfsStreamsMode)(Int32 showStreamsMode); STDMETHOD(GetSystemIconIndex)(UInt32 index, Int32 *iconIndex); private: FString _path; - CDirItem _root; - CRecordVector _refs; - + + CObjectVector Files; + FStringVector Folders; + // CObjectVector Streams; CMyComPtr _parentFolder; bool _commentsAreLoaded; CPairsStorage _comments; + // bool _scanAltStreams; bool _flatMode; NWindows::NFile::NFind::CFindChangeNotification _findChangeNotification; - HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems, - UInt64 &numFolders, UInt64 &numFiles, UInt64 &size, IProgress *progress); - HRESULT GetItemFullSize(int index, UInt64 &size, IProgress *progress); - HRESULT GetComplexName(CFSTR name, FString &resultPath); + HRESULT GetItemsFullSize(const UInt32 *indices, UInt32 numItems, CFsFolderStat &stat); + + HRESULT GetItemFullSize(unsigned index, UInt64 &size, IProgress *progress); + void GetAbsPath(const wchar_t *name, FString &absPath); HRESULT BindToFolderSpec(CFSTR name, IFolderFolder **resultFolder); bool LoadComments(); bool SaveComments(); - HRESULT LoadSubItems(CDirItem &dirItem, const FString &path); - void AddRefs(CDirItem &dirItem); + HRESULT LoadSubItems(int dirItem, const FString &path); + + #ifdef FS_SHOW_LINKS_INFO + bool ReadFileInfo(CDirItem &di); + #endif + public: HRESULT Init(const FString &path, IFolderFolder *parentFolder); #ifdef UNDER_CE HRESULT InitToRoot() { return Init(FTEXT("\\"), NULL); } #endif - CFSFolder() : _flatMode(false) {} + CFSFolder() : _flatMode(false) + // , _scanAltStreams(false) + {} - FString GetPrefix(const CDirItem &item) const; + void GetFullPath(const CDirItem &item, FString &path) const + { + // FString prefix; + // GetPrefix(item, prefix); + path = _path; + if (item.Parent >= 0) + path += Folders[item.Parent]; + path += item.Name; + } + + // void GetPrefix(const CDirItem &item, FString &prefix) const; FString GetRelPath(const CDirItem &item) const; - FString GetRelPath(UInt32 index) const { return GetRelPath(*_refs[index]); } void Clear() { - _root.Clear(); - _refs.Clear(); + Files.Clear(); + Folders.Clear(); + // Streams.Clear(); } }; diff --git a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp old mode 100755 new mode 100644 index c31498c7..0ef3c724 --- a/CPP/7zip/UI/FileManager/FSFolderCopy.cpp +++ b/CPP/7zip/UI/FileManager/FSFolderCopy.cpp @@ -4,11 +4,14 @@ #include -#include "Common/StringConvert.h" +#include "../../../Common/Defs.h" +#include "../../../Common/StringConvert.h" +#include "../../../Common/Wildcard.h" -#include "Windows/DLL.h" -#include "Windows/Error.h" -#include "Windows/FileDir.h" +#include "../../../Windows/DLL.h" +#include "../../../Windows/ErrorMsg.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/FileName.h" #include "../../Common/FilePathAutoRename.h" @@ -16,6 +19,8 @@ using namespace NWindows; using namespace NFile; +using namespace NDir; +using namespace NName; using namespace NFind; #ifndef _UNICODE @@ -102,7 +107,7 @@ typedef BOOL (WINAPI * CopyFileExPointerW)( IN DWORD dwCopyFlags ); -static bool MyCopyFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize) +static bool FsCopyFile(CFSTR oldFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize) { CProgressInfo progressInfo; progressInfo.Progress = progress; @@ -121,18 +126,25 @@ static bool MyCopyFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, U ; CopyFileExPointerW copyFunctionW = (CopyFileExPointerW) My_GetProcAddress(::GetModuleHandleW(k_DllName), "CopyFileExW"); - if (copyFunctionW == 0) - return BOOLToBool(::CopyFileW(fs2us(existingFile), fs2us(newFile), TRUE)); - if (copyFunctionW(fs2us(existingFile), fs2us(newFile), CopyProgressRoutine, - &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS)) - return true; + + IF_USE_MAIN_PATH_2(oldFile, newFile) + { + if (copyFunctionW == 0) + return BOOLToBool(::CopyFileW(fs2us(oldFile), fs2us(newFile), TRUE)); + if (copyFunctionW(fs2us(oldFile), fs2us(newFile), CopyProgressRoutine, + &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS)) + return true; + } #ifdef WIN_LONG_PATH - UString longPathExisting, longPathNew; - if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew)) - return false; - if (copyFunctionW(longPathExisting, longPathNew, CopyProgressRoutine, - &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS)) - return true; + if (USE_SUPER_PATH_2) + { + UString longPathExisting, longPathNew; + if (!GetSuperPaths(oldFile, newFile, longPathExisting, longPathNew, USE_MAIN_PATH_2)) + return false; + if (copyFunctionW(longPathExisting, longPathNew, CopyProgressRoutine, + &progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS)) + return true; + } #endif return false; } @@ -144,13 +156,13 @@ static bool MyCopyFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, U "CopyFileExA"); if (copyFunction != 0) { - if (copyFunction(fs2fas(existingFile), fs2fas(newFile), + if (copyFunction(fs2fas(oldFile), fs2fas(newFile), CopyProgressRoutine,&progressInfo, &CancelFlag, COPY_FILE_FAIL_IF_EXISTS)) return true; if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) return false; } - return BOOLToBool(::CopyFile(fs2fas(existingFile), fs2fas(newFile), TRUE)); + return BOOLToBool(::CopyFile(fs2fas(oldFile), fs2fas(newFile), TRUE)); } #endif } @@ -163,7 +175,15 @@ typedef BOOL (WINAPI * MoveFileWithProgressPointer)( IN DWORD dwFlags ); -static bool MyMoveFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, UInt64 &completedSize) +#ifdef UNDER_CE +#define NON_CE_VAR(_v_) +#else +#define NON_CE_VAR(_v_) _v_ +#endif + +static bool FsMoveFile(CFSTR oldFile, CFSTR newFile, + IProgress * NON_CE_VAR(progress), + UInt64 & NON_CE_VAR(completedSize)) { #ifndef UNDER_CE // if (IsItWindows2000orHigher()) @@ -177,28 +197,30 @@ static bool MyMoveFile(CFSTR existingFile, CFSTR newFile, IProgress *progress, U "MoveFileWithProgressW"); if (moveFunction != 0) { - if (moveFunction( - fs2us(existingFile), fs2us(newFile), CopyProgressRoutine, - &progressInfo, MOVEFILE_COPY_ALLOWED)) - return true; - if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + IF_USE_MAIN_PATH_2(oldFile, newFile) + { + if (moveFunction(fs2us(oldFile), fs2us(newFile), CopyProgressRoutine, + &progressInfo, MOVEFILE_COPY_ALLOWED)) + return true; + } + #ifdef WIN_LONG_PATH + if ((!(USE_MAIN_PATH_2) || ::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) && USE_SUPER_PATH_2) { - #ifdef WIN_LONG_PATH UString longPathExisting, longPathNew; - if (!NDirectory::GetLongPaths(existingFile, newFile, longPathExisting, longPathNew)) + if (!GetSuperPaths(oldFile, newFile, longPathExisting, longPathNew, USE_MAIN_PATH_2)) return false; if (moveFunction(longPathExisting, longPathNew, CopyProgressRoutine, &progressInfo, MOVEFILE_COPY_ALLOWED)) return true; - #endif - if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) - return false; } + #endif + if (::GetLastError() != ERROR_CALL_NOT_IMPLEMENTED) + return false; } // } // else #endif - return NDirectory::MyMoveFile(existingFile, newFile); + return MyMoveFile(oldFile, newFile); } static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback, @@ -213,7 +235,7 @@ static HRESULT SendMessageError(IFolderOperationsExtractCallback *callback, return SendMessageError(callback, MultiByteToUnicodeString(message), fileName); } -static HRESULT MyCopyFile( +static HRESULT FsCopyFile( const FString &srcPath, const CFileInfo &srcFileInfo, const FString &destPathSpec, @@ -221,7 +243,7 @@ static HRESULT MyCopyFile( UInt64 &completedSize) { FString destPath = destPathSpec; - if (destPath.CompareNoCase(srcPath) == 0) + if (CompareFileNames(destPath, srcPath) == 0) { RINOK(SendMessageError(callback, "can not copy file onto itself: ", destPath)); return E_ABORT; @@ -240,9 +262,9 @@ static HRESULT MyCopyFile( { FString destPathNew = us2fs(destPathResult); RINOK(callback->SetCurrentFilePath(fs2us(srcPath))); - if (!MyCopyFile(srcPath, destPathNew, callback, completedSize)) + if (!FsCopyFile(srcPath, destPathNew, callback, completedSize)) { - RINOK(SendMessageError(callback, NError::MyFormatMessageW(GetLastError()) + L" : ", destPathNew)); + RINOK(SendMessageError(callback, NError::MyFormatMessage(GetLastError()) + L" : ", destPathNew)); return E_ABORT; } } @@ -255,32 +277,37 @@ static FString CombinePath(const FString &folderPath, const FString &fileName) return folderPath + FCHAR_PATH_SEPARATOR + fileName; } +static bool IsDestChild(const FString &src, const FString &dest) +{ + unsigned len = src.Len(); + if (dest.Len() < len) + return false; + if (dest.Len() != len && dest[len] != FCHAR_PATH_SEPARATOR) + return false; + return CompareFileNames(dest.Left(len), src) == 0; +} + static HRESULT CopyFolder( const FString &srcPath, - const FString &destPathSpec, + const FString &destPath, IFolderOperationsExtractCallback *callback, UInt64 &completedSize) { RINOK(callback->SetCompleted(&completedSize)); - const FString destPath = destPathSpec; - int len = srcPath.Length(); - if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0) + if (IsDestChild(srcPath, destPath)) { - if (destPath.Length() == len || destPath[len] == FCHAR_PATH_SEPARATOR) - { - RINOK(SendMessageError(callback, "can not copy folder onto itself: ", destPath)); - return E_ABORT; - } + RINOK(SendMessageError(callback, "can not copy folder onto itself: ", destPath)); + return E_ABORT; } - if (!NDirectory::CreateComplexDirectory(destPath)) + if (!CreateComplexDir(destPath)) { RINOK(SendMessageError(callback, "can not create folder: ", destPath)); return E_ABORT; } CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK)); - CFileInfoEx fi; + CDirItem fi; while (enumerator.Next(fi)) { const FString srcPath2 = CombinePath(srcPath, fi.Name); @@ -291,61 +318,7 @@ static HRESULT CopyFolder( } else { - RINOK(MyCopyFile(srcPath2, fi, destPath2, callback, completedSize)); - } - } - return S_OK; -} - -STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems, - const wchar_t *path, IFolderOperationsExtractCallback *callback) -{ - if (numItems == 0) - return S_OK; - - UInt64 numFolders, numFiles, totalSize; - GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback); - RINOK(callback->SetTotal(totalSize)); - RINOK(callback->SetNumFiles(numFiles)); - - UString destPath = path; - if (destPath.IsEmpty()) - return E_INVALIDARG; - bool directName = (destPath.Back() != WCHAR_PATH_SEPARATOR); - if (directName) - { - if (numItems > 1) - return E_INVALIDARG; - } - /* - // doesn't work in network - else - if (!NDirectory::CreateComplexDirectory(destPath))) - { - DWORD lastError = ::GetLastError(); - UString message = UString(L"can not create folder ") + - destPath; - RINOK(callback->ShowMessage(message)); - return E_ABORT; - } - */ - - UInt64 completedSize = 0; - RINOK(callback->SetCompleted(&completedSize)); - for (UInt32 i = 0; i < numItems; i++) - { - const CDirItem &fi = *_refs[indices[i]]; - FString destPath2 = us2fs(destPath); - if (!directName) - destPath2 += fi.Name; - FString srcPath = _path + GetPrefix(fi) + fi.Name; - if (fi.IsDir()) - { - RINOK(CopyFolder(srcPath, destPath2, callback, completedSize)); - } - else - { - RINOK(MyCopyFile(srcPath, fi, destPath2, callback, completedSize)); + RINOK(FsCopyFile(srcPath2, fi, destPath2, callback, completedSize)); } } return S_OK; @@ -354,14 +327,14 @@ STDMETHODIMP CFSFolder::CopyTo(const UInt32 *indices, UInt32 numItems, ///////////////////////////////////////////////// // Move Operations -static HRESULT MyMoveFile( +static HRESULT FsMoveFile( const FString &srcPath, const CFileInfo &srcFileInfo, const FString &destPath, IFolderOperationsExtractCallback *callback, UInt64 &completedSize) { - if (destPath.CompareNoCase(srcPath) == 0) + if (CompareFileNames(destPath, srcPath) == 0) { RINOK(SendMessageError(callback, "can not move file onto itself: ", srcPath)); return E_ABORT; @@ -380,7 +353,7 @@ static HRESULT MyMoveFile( { FString destPathNew = us2fs(destPathResult); RINOK(callback->SetCurrentFilePath(fs2us(srcPath))); - if (!MyMoveFile(srcPath, destPathNew, callback, completedSize)) + if (!FsMoveFile(srcPath, destPathNew, callback, completedSize)) { RINOK(SendMessageError(callback, "can not move to file: ", destPathNew)); } @@ -390,48 +363,44 @@ static HRESULT MyMoveFile( return S_OK; } -static HRESULT MyMoveFolder( +static HRESULT FsMoveFolder( const FString &srcPath, const FString &destPath, IFolderOperationsExtractCallback *callback, UInt64 &completedSize) { - int len = srcPath.Length(); - if (destPath.Length() >= len && srcPath.CompareNoCase(destPath.Left(len)) == 0) + if (IsDestChild(srcPath, destPath)) { - if (destPath.Length() == len || destPath[len] == FCHAR_PATH_SEPARATOR) - { - RINOK(SendMessageError(callback, "can not move folder onto itself: ", destPath)); - return E_ABORT; - } + RINOK(SendMessageError(callback, "can not move folder onto itself: ", destPath)); + return E_ABORT; } - if (MyMoveFile(srcPath, destPath, callback, completedSize)) + if (FsMoveFile(srcPath, destPath, callback, completedSize)) return S_OK; - if (!NDirectory::CreateComplexDirectory(destPath)) + if (!CreateComplexDir(destPath)) { RINOK(SendMessageError(callback, "can not create folder: ", destPath)); return E_ABORT; } { CEnumerator enumerator(CombinePath(srcPath, FSTRING_ANY_MASK)); - CFileInfoEx fi; + CDirItem fi; while (enumerator.Next(fi)) { const FString srcPath2 = CombinePath(srcPath, fi.Name); const FString destPath2 = CombinePath(destPath, fi.Name); if (fi.IsDir()) { - RINOK(MyMoveFolder(srcPath2, destPath2, callback, completedSize)); + RINOK(FsMoveFolder(srcPath2, destPath2, callback, completedSize)); } else { - RINOK(MyMoveFile(srcPath2, fi, destPath2, callback, completedSize)); + RINOK(FsMoveFile(srcPath2, fi, destPath2, callback, completedSize)); } } } - if (!NDirectory::MyRemoveDirectory(srcPath)) + if (!RemoveDir(srcPath)) { RINOK(SendMessageError(callback, "can not remove folder: ", srcPath)); return E_ABORT; @@ -439,19 +408,18 @@ static HRESULT MyMoveFolder( return S_OK; } -STDMETHODIMP CFSFolder::MoveTo( - const UInt32 *indices, - UInt32 numItems, - const wchar_t *path, - IFolderOperationsExtractCallback *callback) +STDMETHODIMP CFSFolder::CopyTo(Int32 moveMode, const UInt32 *indices, UInt32 numItems, + Int32 /* includeAltStreams */, Int32 /* replaceAltStreamColon */, + const wchar_t *path, IFolderOperationsExtractCallback *callback) { if (numItems == 0) return S_OK; - UInt64 numFolders, numFiles, totalSize; - GetItemsFullSize(indices, numItems, numFolders, numFiles, totalSize, callback); - RINOK(callback->SetTotal(totalSize)); - RINOK(callback->SetNumFiles(numFiles)); + CFsFolderStat stat; + stat.Progress = callback; + RINOK(GetItemsFullSize(indices, numItems, stat)); + RINOK(callback->SetTotal(stat.Size)); + RINOK(callback->SetNumFiles(stat.NumFiles)); FString destPath = us2fs(path); if (destPath.IsEmpty()) @@ -463,34 +431,55 @@ STDMETHODIMP CFSFolder::MoveTo( return E_INVALIDARG; } else - if (!NDirectory::CreateComplexDirectory(destPath)) + { + // Does CreateComplexDir work in network ? + if (!CreateComplexDir(destPath)) { RINOK(SendMessageError(callback, "can not create folder: ", destPath)); return E_ABORT; } + } UInt64 completedSize = 0; RINOK(callback->SetCompleted(&completedSize)); for (UInt32 i = 0; i < numItems; i++) { - const CDirItem &fi = *_refs[indices[i]]; + UInt32 index = indices[i]; + if (index >= (UInt32)Files.Size()) + continue; + const CDirItem &fi = Files[index]; FString destPath2 = destPath; if (!directName) destPath2 += fi.Name; - FString srcPath = _path + GetPrefix(fi) + fi.Name; + FString srcPath; + GetFullPath(fi, srcPath); if (fi.IsDir()) { - RINOK(MyMoveFolder(srcPath, destPath2, callback, completedSize)); + if (moveMode) + { + RINOK(FsMoveFolder(srcPath, destPath2, callback, completedSize)); + } + else + { + RINOK(CopyFolder(srcPath, destPath2, callback, completedSize)); + } } else { - RINOK(MyMoveFile(srcPath, fi, destPath2, callback, completedSize)); + if (moveMode) + { + RINOK(FsMoveFile(srcPath, fi, destPath2, callback, completedSize)); + } + else + { + RINOK(FsCopyFile(srcPath, fi, destPath2, callback, completedSize)); + } } } return S_OK; } -STDMETHODIMP CFSFolder::CopyFrom(const wchar_t * /* fromFolderPath */, +STDMETHODIMP CFSFolder::CopyFrom(Int32 /* moveMode */, const wchar_t * /* fromFolderPath */, const wchar_t ** /* itemsPaths */, UInt32 /* numItems */, IProgress * /* progress */) { /* diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp old mode 100755 new mode 100644 index d29ac44c..2d3b1d92 --- a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp +++ b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.cpp @@ -4,8 +4,8 @@ #include "resource.h" -#include "Windows/FileName.h" -#include "Windows/Thread.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/Thread.h" #include "../Agent/Agent.h" @@ -69,9 +69,9 @@ static void SplitNameToPureNameAndExtension(const FString &fullName, } else { - pureName = fullName.Left(index); + pureName.SetFrom(fullName, index); extensionDelimiter = kExtensionDelimiter; - extension = fullName.Mid(index + 1); + extension = fullName.Ptr(index + 1); } } @@ -94,8 +94,8 @@ HRESULT OpenFileFolderPlugin( FString fileName; if (slashPos >= 0) { - dirPrefix = path.Left(slashPos + 1); - fileName = path.Mid(slashPos + 1); + dirPrefix.SetFrom(path, slashPos + 1); + fileName = path.Ptr(slashPos + 1); } else fileName = path; @@ -122,7 +122,7 @@ HRESULT OpenFileFolderPlugin( } */ - for (int i = 0; i < plugins.Size(); i++) + FOR_VECTOR (i, plugins) { const CPluginInfo &plugin = plugins[i]; if (!plugin.ClassIDDefined) @@ -151,10 +151,10 @@ HRESULT OpenFileFolderPlugin( t.Path = fs2us(path); t.ArcFormat = arcFormat; - UString progressTitle = LangString(IDS_OPENNING, 0x03020283); + UString progressTitle = LangString(IDS_OPENNING); t.OpenCallbackSpec->ProgressDialog.MainWindow = parentWindow; - t.OpenCallbackSpec->ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); - t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + UString(L" "); + t.OpenCallbackSpec->ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE); + t.OpenCallbackSpec->ProgressDialog.MainAddTitle = progressTitle + L' '; t.OpenCallbackSpec->ProgressDialog.WaitMode = true; { @@ -166,11 +166,11 @@ HRESULT OpenFileFolderPlugin( if (t.Result == E_ABORT) return t.Result; + encrypted = t.OpenCallbackSpec->PasswordIsDefined; if (t.Result == S_OK) { // if (openCallbackSpec->PasswordWasAsked) { - encrypted = t.OpenCallbackSpec->PasswordIsDefined; password = t.OpenCallbackSpec->Password; } *module = library.Detach(); diff --git a/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h b/CPP/7zip/UI/FileManager/FileFolderPluginOpen.h old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/FilePlugins.cpp b/CPP/7zip/UI/FileManager/FilePlugins.cpp old mode 100755 new mode 100644 index b81850fd..556c54fd --- a/CPP/7zip/UI/FileManager/FilePlugins.cpp +++ b/CPP/7zip/UI/FileManager/FilePlugins.cpp @@ -10,8 +10,8 @@ int CExtDatabase::FindExt(const UString &ext) { - for (int i = 0; i < Exts.Size(); i++) - if (Exts[i].Ext.CompareNoCase(ext) == 0) + FOR_VECTOR (i, Exts) + if (Exts[i].Ext.IsEqualToNoCase(ext)) return i; return -1; } @@ -19,7 +19,7 @@ int CExtDatabase::FindExt(const UString &ext) void CExtDatabase::Read() { ReadFileFolderPluginInfoList(Plugins); - for (int pluginIndex = 0; pluginIndex < Plugins.Size(); pluginIndex++) + FOR_VECTOR (pluginIndex, Plugins) { const CPluginInfo &plugin = Plugins[pluginIndex]; @@ -35,7 +35,7 @@ void CExtDatabase::Read() return; UStringVector exts; SplitString((const wchar_t *)extBSTR, exts); - for (int i = 0; i < exts.Size(); i++) + FOR_VECTOR (i, exts) { const UString &ext = exts[i]; #ifdef UNDER_CE diff --git a/CPP/7zip/UI/FileManager/FilePlugins.h b/CPP/7zip/UI/FileManager/FilePlugins.h old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/FoldersPage.cpp b/CPP/7zip/UI/FileManager/FoldersPage.cpp old mode 100755 new mode 100644 index b7366fed..8c0b5a0c --- a/CPP/7zip/UI/FileManager/FoldersPage.cpp +++ b/CPP/7zip/UI/FileManager/FoldersPage.cpp @@ -11,36 +11,36 @@ using namespace NWindows; -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_FOLDERS_STATIC_WORKING_FOLDER, 0x01000210 }, - { IDC_FOLDERS_WORK_RADIO_SYSTEM, 0x01000211 }, - { IDC_FOLDERS_WORK_RADIO_CURRENT, 0x01000212 }, - { IDC_FOLDERS_WORK_RADIO_SPECIFIED, 0x01000213 }, - { IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, 0x01000214 } + IDT_FOLDERS_WORKING_FOLDER, + IDR_FOLDERS_WORK_SYSTEM, + IDR_FOLDERS_WORK_CURRENT, + IDR_FOLDERS_WORK_SPECIFIED, + IDX_FOLDERS_WORK_FOR_REMOVABLE }; static const int kWorkModeButtons[] = { - IDC_FOLDERS_WORK_RADIO_SYSTEM, - IDC_FOLDERS_WORK_RADIO_CURRENT, - IDC_FOLDERS_WORK_RADIO_SPECIFIED + IDR_FOLDERS_WORK_SYSTEM, + IDR_FOLDERS_WORK_CURRENT, + IDR_FOLDERS_WORK_SPECIFIED }; -static const int kNumWorkModeButtons = sizeof(kWorkModeButtons) / sizeof(kWorkModeButtons[0]); +static const int kNumWorkModeButtons = ARRAY_SIZE(kWorkModeButtons); bool CFoldersPage::OnInit() { - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); m_WorkDirInfo.Load(); - CheckButton(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly); + CheckButton(IDX_FOLDERS_WORK_FOR_REMOVABLE, m_WorkDirInfo.ForRemovableOnly); CheckRadioButton(kWorkModeButtons[0], kWorkModeButtons[kNumWorkModeButtons - 1], kWorkModeButtons[m_WorkDirInfo.Mode]); - m_WorkPath.Init(*this, IDC_FOLDERS_WORK_EDIT_PATH); - m_ButtonSetWorkPath.Init(*this, IDC_FOLDERS_WORK_BUTTON_PATH); + m_WorkPath.Init(*this, IDE_FOLDERS_WORK_PATH); + m_ButtonSetWorkPath.Init(*this, IDB_FOLDERS_WORK_PATH); m_WorkPath.SetText(fs2us(m_WorkDirInfo.Path)); @@ -69,7 +69,7 @@ void CFoldersPage::GetWorkDir(NWorkDir::CInfo &workDirInfo) UString s; m_WorkPath.GetText(s); workDirInfo.Path = us2fs(s); - workDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE); + workDirInfo.ForRemovableOnly = IsButtonCheckedBool(IDX_FOLDERS_WORK_FOR_REMOVABLE); workDirInfo.Mode = NWorkDir::NMode::EEnum(GetWorkMode()); } @@ -106,10 +106,10 @@ bool CFoldersPage::OnButtonClicked(int buttonID, HWND buttonHWND) } switch(buttonID) { - case IDC_FOLDERS_WORK_BUTTON_PATH: + case IDB_FOLDERS_WORK_PATH: OnFoldersWorkButtonPath(); break; - case IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE: + case IDX_FOLDERS_WORK_FOR_REMOVABLE: break; default: return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); @@ -120,7 +120,7 @@ bool CFoldersPage::OnButtonClicked(int buttonID, HWND buttonHWND) bool CFoldersPage::OnCommand(int code, int itemID, LPARAM lParam) { - if (code == EN_CHANGE && itemID == IDC_FOLDERS_WORK_EDIT_PATH) + if (code == EN_CHANGE && itemID == IDE_FOLDERS_WORK_PATH) { ModifiedEvent(); return true; @@ -132,9 +132,9 @@ void CFoldersPage::OnFoldersWorkButtonPath() { UString currentPath; m_WorkPath.GetText(currentPath); - UString title = LangString(IDS_FOLDERS_SET_WORK_PATH_TITLE, 0x01000281); + UString title = LangString(IDS_FOLDERS_SET_WORK_PATH_TITLE); UString resultPath; - if (MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (MyBrowseForFolder(*this, title, currentPath, resultPath)) m_WorkPath.SetText(resultPath); } diff --git a/CPP/7zip/UI/FileManager/FoldersPage.h b/CPP/7zip/UI/FileManager/FoldersPage.h old mode 100755 new mode 100644 index d8456a40..7aaa80f7 --- a/CPP/7zip/UI/FileManager/FoldersPage.h +++ b/CPP/7zip/UI/FileManager/FoldersPage.h @@ -3,7 +3,7 @@ #ifndef __FOLDERS_PAGE_H #define __FOLDERS_PAGE_H -#include "Windows/Control/PropertyPage.h" +#include "../../../Windows/Control/PropertyPage.h" #include "../Common/ZipRegistry.h" diff --git a/CPP/7zip/UI/FileManager/FoldersPage.rc b/CPP/7zip/UI/FileManager/FoldersPage.rc old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/FoldersPage2.rc b/CPP/7zip/UI/FileManager/FoldersPage2.rc old mode 100755 new mode 100644 index 0b73ec9f..9b9276ef --- a/CPP/7zip/UI/FileManager/FoldersPage2.rc +++ b/CPP/7zip/UI/FileManager/FoldersPage2.rc @@ -1,16 +1,16 @@ CAPTION "Folders" BEGIN - // GROUPBOX "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, m, m, xc, 98 + // GROUPBOX "&Working folder", IDT_FOLDERS_WORKING_FOLDER, m, m, xc, 98 - LTEXT "&Working folder", IDC_FOLDERS_STATIC_WORKING_FOLDER, m, m, xc, 8 - CONTROL "&System temp folder", IDC_FOLDERS_WORK_RADIO_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP, + LTEXT "&Working folder", IDT_FOLDERS_WORKING_FOLDER, m, m, xc, 8 + CONTROL "&System temp folder", IDR_FOLDERS_WORK_SYSTEM, "Button", BS_AUTORADIOBUTTON | WS_GROUP, m, 20, xc, 10 - CONTROL "&Current", IDC_FOLDERS_WORK_RADIO_CURRENT, "Button", BS_AUTORADIOBUTTON, + CONTROL "&Current", IDR_FOLDERS_WORK_CURRENT, "Button", BS_AUTORADIOBUTTON, m, 34, xc, 10 - CONTROL "Specified:", IDC_FOLDERS_WORK_RADIO_SPECIFIED, "Button", BS_AUTORADIOBUTTON, + CONTROL "Specified:", IDR_FOLDERS_WORK_SPECIFIED, "Button", BS_AUTORADIOBUTTON, m, 48, xc, 10 - EDITTEXT IDC_FOLDERS_WORK_EDIT_PATH, m + m, 62, xc - m - m - bxsDots, 14, ES_AUTOHSCROLL - PUSHBUTTON "...", IDC_FOLDERS_WORK_BUTTON_PATH, xs - m - bxsDots, 61, bxsDots, bys - CONTROL "Use for removable drives only", IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE, MY_CHECKBOX, + EDITTEXT IDE_FOLDERS_WORK_PATH, m + m, 62, xc - m - m - bxsDots, 14, ES_AUTOHSCROLL + PUSHBUTTON "...", IDB_FOLDERS_WORK_PATH, xs - m - bxsDots, 61, bxsDots, bys + CONTROL "Use for removable drives only", IDX_FOLDERS_WORK_FOR_REMOVABLE, MY_CHECKBOX, m, 86, xc, 10 END diff --git a/CPP/7zip/UI/FileManager/FoldersPageRes.h b/CPP/7zip/UI/FileManager/FoldersPageRes.h old mode 100755 new mode 100644 index 896f197a..ba9ab73e --- a/CPP/7zip/UI/FileManager/FoldersPageRes.h +++ b/CPP/7zip/UI/FileManager/FoldersPageRes.h @@ -1,13 +1,12 @@ -#define IDD_FOLDERS 571 -#define IDD_FOLDERS_2 671 +#define IDD_FOLDERS 2400 +#define IDD_FOLDERS_2 12400 -#define IDS_FOLDERS_SET_WORK_PATH_TITLE 877 +#define IDT_FOLDERS_WORKING_FOLDER 2401 +#define IDR_FOLDERS_WORK_SYSTEM 2402 +#define IDR_FOLDERS_WORK_CURRENT 2403 +#define IDR_FOLDERS_WORK_SPECIFIED 2404 +#define IDX_FOLDERS_WORK_FOR_REMOVABLE 2405 +#define IDS_FOLDERS_SET_WORK_PATH_TITLE 2406 -#define IDC_FOLDERS_STATIC_WORKING_FOLDER 1001 - -#define IDC_FOLDERS_WORK_RADIO_SYSTEM 1011 -#define IDC_FOLDERS_WORK_RADIO_CURRENT 1012 -#define IDC_FOLDERS_WORK_RADIO_SPECIFIED 1013 -#define IDC_FOLDERS_WORK_EDIT_PATH 1014 -#define IDC_FOLDERS_WORK_BUTTON_PATH 1015 -#define IDC_FOLDERS_WORK_CHECK_FOR_REMOVABLE 1017 +#define IDE_FOLDERS_WORK_PATH 100 +#define IDB_FOLDERS_WORK_PATH 101 diff --git a/CPP/7zip/UI/FileManager/FormatUtils.cpp b/CPP/7zip/UI/FileManager/FormatUtils.cpp old mode 100755 new mode 100644 index 98bb043e..2143c3f1 --- a/CPP/7zip/UI/FileManager/FormatUtils.cpp +++ b/CPP/7zip/UI/FileManager/FormatUtils.cpp @@ -2,13 +2,11 @@ #include "StdAfx.h" +#include "../../../Common/IntToString.h" + #include "FormatUtils.h" -#include "Common/IntToString.h" -#include "Windows/ResourceString.h" -#ifdef LANG #include "LangUtils.h" -#endif UString NumberToString(UInt64 number) { @@ -24,17 +22,7 @@ UString MyFormatNew(const UString &format, const UString &argument) return result; } -UString MyFormatNew(UINT resourceID, - #ifdef LANG - UInt32 langID, - #endif - const UString &argument) +UString MyFormatNew(UINT resourceID, const UString &argument) { - return MyFormatNew( - #ifdef LANG - LangString(resourceID, langID), - #else - NWindows::MyLoadStringW(resourceID), - #endif - argument); + return MyFormatNew(LangString(resourceID), argument); } diff --git a/CPP/7zip/UI/FileManager/FormatUtils.h b/CPP/7zip/UI/FileManager/FormatUtils.h old mode 100755 new mode 100644 index 70a44434..993e8033 --- a/CPP/7zip/UI/FileManager/FormatUtils.h +++ b/CPP/7zip/UI/FileManager/FormatUtils.h @@ -1,18 +1,14 @@ // FormatUtils.h -#ifndef __FORMATUTILS_H -#define __FORMATUTILS_H +#ifndef __FORMAT_UTILS_H +#define __FORMAT_UTILS_H -#include "Common/Types.h" -#include "Common/MyString.h" +#include "../../../Common/MyTypes.h" +#include "../../../Common/MyString.h" UString NumberToString(UInt64 number); UString MyFormatNew(const UString &format, const UString &argument); -UString MyFormatNew(UINT resourceID, - #ifdef LANG - UInt32 langID, - #endif - const UString &argument); +UString MyFormatNew(UINT resourceID, const UString &argument); #endif diff --git a/CPP/7zip/UI/FileManager/HelpUtils.cpp b/CPP/7zip/UI/FileManager/HelpUtils.cpp old mode 100755 new mode 100644 index 3128cb28..fb6fcdd0 --- a/CPP/7zip/UI/FileManager/HelpUtils.cpp +++ b/CPP/7zip/UI/FileManager/HelpUtils.cpp @@ -4,8 +4,10 @@ #include -#include "Common/StringConvert.h" -#include "Windows/DLL.h" +#include "../../../Common/StringConvert.h" + +#include "../../../Windows/DLL.h" + #include "HelpUtils.h" static LPCWSTR kHelpFileName = L"7-zip.chm::/"; diff --git a/CPP/7zip/UI/FileManager/HelpUtils.h b/CPP/7zip/UI/FileManager/HelpUtils.h old mode 100755 new mode 100644 index 2a7b85af..52b1418a --- a/CPP/7zip/UI/FileManager/HelpUtils.h +++ b/CPP/7zip/UI/FileManager/HelpUtils.h @@ -1,9 +1,9 @@ // HelpUtils.h -#ifndef __HELPUTILS_H -#define __HELPUTILS_H +#ifndef __HELP_UTILS_H +#define __HELP_UTILS_H -#include "Common/MyString.h" +#include "../../../Common/MyString.h" void ShowHelpWindow(HWND hwnd, LPCWSTR topicFile); diff --git a/CPP/7zip/UI/FileManager/IFolder.h b/CPP/7zip/UI/FileManager/IFolder.h old mode 100755 new mode 100644 index d6cce88f..60991a71 --- a/CPP/7zip/UI/FileManager/IFolder.h +++ b/CPP/7zip/UI/FileManager/IFolder.h @@ -63,16 +63,15 @@ FOLDER_INTERFACE_SUB(IFolderOperationsExtractCallback, IProgress, 0x0B) STDMETHOD(CreateFile)(const wchar_t *name, IProgress *progress) x; \ STDMETHOD(Rename)(UInt32 index, const wchar_t *newName, IProgress *progress) x; \ STDMETHOD(Delete)(const UInt32 *indices, UInt32 numItems, IProgress *progress) x; \ - STDMETHOD(CopyTo)(const UInt32 *indices, UInt32 numItems, \ + STDMETHOD(CopyTo)(Int32 moveMode, const UInt32 *indices, UInt32 numItems, \ + Int32 includeAltStreams, Int32 replaceAltStreamCharsMode, \ const wchar_t *path, IFolderOperationsExtractCallback *callback) x; \ - STDMETHOD(MoveTo)(const UInt32 *indices, UInt32 numItems, \ - const wchar_t *path, IFolderOperationsExtractCallback *callback) x; \ - STDMETHOD(CopyFrom)(const wchar_t *fromFolderPath, \ + STDMETHOD(CopyFrom)(Int32 moveMode, const wchar_t *fromFolderPath, \ const wchar_t **itemsPaths, UInt32 numItems, IProgress *progress) x; \ STDMETHOD(SetProperty)(UInt32 index, PROPID propID, const PROPVARIANT *value, IProgress *progress) x; \ STDMETHOD(CopyFromFile)(UInt32 index, const wchar_t *fullFilePath, IProgress *progress) x; \ -FOLDER_INTERFACE(IFolderOperations, 0x12) +FOLDER_INTERFACE(IFolderOperations, 0x13) { INTERFACE_FolderOperations(PURE) }; @@ -94,6 +93,11 @@ FOLDER_INTERFACE(IFolderGetItemFullSize, 0x08) STDMETHOD(GetItemFullSize)(UInt32 index, PROPVARIANT *value, IProgress *progress) PURE; }; +FOLDER_INTERFACE(IFolderCalcItemFullSize, 0x14) +{ + STDMETHOD(CalcItemFullSize)(UInt32 index, IProgress *progress) PURE; +}; + FOLDER_INTERFACE(IFolderClone, 0x09) { STDMETHOD(Clone)(IFolderFolder **resultFolder) PURE; @@ -104,6 +108,13 @@ FOLDER_INTERFACE(IFolderSetFlatMode, 0x0A) STDMETHOD(SetFlatMode)(Int32 flatMode) PURE; }; +/* +FOLDER_INTERFACE(IFolderSetShowNtfsStreamsMode, 0xFA) +{ + STDMETHOD(SetShowNtfsStreamsMode)(Int32 showStreamsMode) PURE; +}; +*/ + #define INTERFACE_FolderProperties(x) \ STDMETHOD(GetNumberOfFolderProperties)(UInt32 *numProperties) x; \ STDMETHOD(GetFolderPropertyInfo)(UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) x; \ @@ -132,6 +143,21 @@ FOLDER_INTERFACE(IGetFolderArcProps, 0x11) STDMETHOD(GetFolderArcProps)(IFolderArcProps **object) PURE; }; +FOLDER_INTERFACE(IFolderCompare, 0x15) +{ + STDMETHOD_(Int32, CompareItems)(UInt32 index1, UInt32 index2, PROPID propID, Int32 propIsRaw) PURE; +}; + +#define INTERFACE_IFolderGetItemName(x) \ + STDMETHOD(GetItemName)(UInt32 index, const wchar_t **name, unsigned *len) x; \ + STDMETHOD(GetItemPrefix)(UInt32 index, const wchar_t **name, unsigned *len) x; \ + STDMETHOD_(UInt64, GetItemSize)(UInt32 index) x; \ + +FOLDER_INTERFACE(IFolderGetItemName, 0x16) +{ + INTERFACE_IFolderGetItemName(PURE) +}; + #define FOLDER_MANAGER_INTERFACE(i, x) DECL_INTERFACE(i, 9, x) #define INTERFACE_IFolderManager(x) \ @@ -147,16 +173,31 @@ FOLDER_MANAGER_INTERFACE(IFolderManager, 0x05) INTERFACE_IFolderManager(PURE); }; - +/* #define IMP_IFolderFolder_GetProp(k) \ (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \ - { if(index >= sizeof(k) / sizeof(k[0])) return E_INVALIDARG; \ - const STATPROPSTG &srcItem = k[index]; \ + { if (index >= ARRAY_SIZE(k)) return E_INVALIDARG; \ + const CMy_STATPROPSTG_2 &srcItem = k[index]; \ *propID = srcItem.propid; *varType = srcItem.vt; *name = 0; return S_OK; } \ #define IMP_IFolderFolder_Props(c) \ STDMETHODIMP c::GetNumberOfProperties(UInt32 *numProperties) \ - { *numProperties = sizeof(kProps) / sizeof(kProps[0]); return S_OK; } \ + { *numProperties = ARRAY_SIZE(kProps); return S_OK; } \ + STDMETHODIMP c::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps) +*/ + +#define IMP_IFolderFolder_GetProp(k) \ + (UInt32 index, BSTR *name, PROPID *propID, VARTYPE *varType) \ + { if (index >= ARRAY_SIZE(k)) return E_INVALIDARG; \ + *propID = k[index]; *varType = k7z_PROPID_To_VARTYPE[(unsigned)*propID]; *name = 0; return S_OK; } \ + +#define IMP_IFolderFolder_Props(c) \ + STDMETHODIMP c::GetNumberOfProperties(UInt32 *numProperties) \ + { *numProperties = ARRAY_SIZE(kProps); return S_OK; } \ STDMETHODIMP c::GetPropertyInfo IMP_IFolderFolder_GetProp(kProps) + +int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2); +// int CompareFileNames_ForFolderList(const FChar *s1, const FChar *s2); + #endif diff --git a/CPP/7zip/UI/FileManager/Info.bmp b/CPP/7zip/UI/FileManager/Info.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/Info2.bmp b/CPP/7zip/UI/FileManager/Info2.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/LangPage.cpp b/CPP/7zip/UI/FileManager/LangPage.cpp old mode 100755 new mode 100644 index 85829368..54253295 --- a/CPP/7zip/UI/FileManager/LangPage.cpp +++ b/CPP/7zip/UI/FileManager/LangPage.cpp @@ -2,9 +2,10 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" +#include "../../../Common/Lang.h" -#include "Windows/ResourceString.h" +#include "../../../Windows/FileFind.h" +#include "../../../Windows/ResourceString.h" #include "HelpUtils.h" #include "LangPage.h" @@ -12,55 +13,85 @@ #include "LangUtils.h" #include "RegistryUtils.h" -static CIDLangPair kIDLangPairs[] = +using namespace NWindows; + +static const UInt32 kLangIDs[] = { - { IDC_LANG_STATIC_LANG, 0x01000401} + IDT_LANG_LANG }; static LPCWSTR kLangTopic = L"fm/options.htm#language"; -static UString NativeLangString(const UString &s) +static void NativeLangString(UString &dest, const wchar_t *s) { - return L" (" + s + L')'; + dest += L" ("; + dest += s; + dest += L')'; } +bool LangOpen(CLang &lang, CFSTR fileName); + bool CLangPage::OnInit() { - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); - _langCombo.Attach(GetItem(IDC_LANG_COMBO_LANG)); + _langCombo.Attach(GetItem(IDC_LANG_LANG)); - UString s = NWindows::MyLoadStringW(IDS_LANG_ENGLISH) + - NativeLangString(NWindows::MyLoadStringW(IDS_LANG_NATIVE)); - int index = (int)_langCombo.AddString(s); + UString temp = MyLoadString(IDS_LANG_ENGLISH); + NativeLangString(temp, MyLoadString(IDS_LANG_NATIVE)); + int index = (int)_langCombo.AddString(temp); _langCombo.SetItemData(index, _paths.Size()); _paths.Add(L"-"); _langCombo.SetCurSel(0); - CObjectVector langs; - LoadLangs(langs); - for (int i = 0; i < langs.Size(); i++) + const FString dirPrefix = GetLangDirPrefix(); + NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt")); + NFile::NFind::CFileInfo fi; + CLang lang; + UString error; + + while (enumerator.Next(fi)) { - const CLangEx &lang = langs[i]; - UString name, nationalName; - if (!lang.Lang.GetMessage(0, name)) - name = lang.ShortName; - if (lang.Lang.GetMessage(1, nationalName) && !nationalName.IsEmpty()) - name += NativeLangString(nationalName); - - index = (int)_langCombo.AddString(name); + if (fi.IsDir()) + continue; + const int kExtSize = 4; + if (fi.Name.Len() < kExtSize) + continue; + unsigned pos = fi.Name.Len() - kExtSize; + if (!StringsAreEqualNoCase_Ascii(fi.Name.Ptr(pos), ".txt")) + continue; + + if (!LangOpen(lang, dirPrefix + fi.Name)) + { + if (!error.IsEmpty()) + error += L' '; + error += fs2us(fi.Name); + continue; + } + + const UString shortName = fs2us(fi.Name.Left(pos)); + UString s = shortName; + const wchar_t *eng = lang.Get(IDS_LANG_ENGLISH); + if (eng) + s = eng; + const wchar_t *native = lang.Get(IDS_LANG_NATIVE); + if (native) + NativeLangString(s, native); + index = (int)_langCombo.AddString(s); _langCombo.SetItemData(index, _paths.Size()); - _paths.Add(lang.ShortName); - if (g_LangID.CompareNoCase(lang.ShortName) == 0) + _paths.Add(shortName); + if (g_LangID.IsEqualToNoCase(shortName)) _langCombo.SetCurSel(index); } + + if (!error.IsEmpty()) + MessageBoxW(0, error, L"Error in Lang file", MB_OK | MB_ICONSTOP); return CPropertyPage::OnInit(); } LONG CLangPage::OnApply() { - int selectedIndex = _langCombo.GetCurSel(); - int pathIndex = (int)_langCombo.GetItemData(selectedIndex); + int pathIndex = (int)_langCombo.GetItemData_of_CurSel(); SaveRegLang(_paths[pathIndex]); ReloadLang(); LangWasChanged = true; @@ -74,7 +105,7 @@ void CLangPage::OnNotifyHelp() bool CLangPage::OnCommand(int code, int itemID, LPARAM param) { - if (code == CBN_SELCHANGE && itemID == IDC_LANG_COMBO_LANG) + if (code == CBN_SELCHANGE && itemID == IDC_LANG_LANG) { Changed(); return true; diff --git a/CPP/7zip/UI/FileManager/LangPage.h b/CPP/7zip/UI/FileManager/LangPage.h old mode 100755 new mode 100644 index e58f5098..589941b2 --- a/CPP/7zip/UI/FileManager/LangPage.h +++ b/CPP/7zip/UI/FileManager/LangPage.h @@ -3,8 +3,8 @@ #ifndef __LANG_PAGE_H #define __LANG_PAGE_H -#include "Windows/Control/PropertyPage.h" -#include "Windows/Control/ComboBox.h" +#include "../../../Windows/Control/PropertyPage.h" +#include "../../../Windows/Control/ComboBox.h" class CLangPage: public NWindows::NControl::CPropertyPage { @@ -12,6 +12,7 @@ class CLangPage: public NWindows::NControl::CPropertyPage UStringVector _paths; public: bool LangWasChanged; + CLangPage() { LangWasChanged = false; } virtual bool OnInit(); virtual void OnNotifyHelp(); diff --git a/CPP/7zip/UI/FileManager/LangPage.rc b/CPP/7zip/UI/FileManager/LangPage.rc old mode 100755 new mode 100644 index 327b33e2..5aeaf406 --- a/CPP/7zip/UI/FileManager/LangPage.rc +++ b/CPP/7zip/UI/FileManager/LangPage.rc @@ -4,11 +4,11 @@ #define xc 148 #define yc 100 -IDD_LANG MY_PAGE +IDD_LANG DIALOG 0, 0, xs, ys MY_PAGE_STYLE MY_FONT CAPTION "Language" { - LTEXT "Language:", IDC_LANG_STATIC_LANG, m, m, xc, 8 - COMBOBOX IDC_LANG_COMBO_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED + LTEXT "Language:", IDT_LANG_LANG, m, m, xc, 8 + COMBOBOX IDC_LANG_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED } @@ -23,8 +23,8 @@ CAPTION "Language" IDD_LANG_2 MY_PAGE CAPTION "Language" { - LTEXT "Language:", IDC_LANG_STATIC_LANG, m, m, xc, 8 - COMBOBOX IDC_LANG_COMBO_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED + LTEXT "Language:", IDT_LANG_LANG, m, m, xc, 8 + COMBOBOX IDC_LANG_LANG, m, 20, xc, yc - 20, MY_COMBO_SORTED } #endif diff --git a/CPP/7zip/UI/FileManager/LangPageRes.h b/CPP/7zip/UI/FileManager/LangPageRes.h old mode 100755 new mode 100644 index eb704dbf..d7a39d75 --- a/CPP/7zip/UI/FileManager/LangPageRes.h +++ b/CPP/7zip/UI/FileManager/LangPageRes.h @@ -1,8 +1,8 @@ -#define IDD_LANG 544 -#define IDD_LANG_2 644 +#define IDD_LANG 2101 +#define IDD_LANG_2 12101 -#define IDS_LANG_ENGLISH 995 -#define IDS_LANG_NATIVE 996 +#define IDS_LANG_ENGLISH 1 +#define IDS_LANG_NATIVE 2 -#define IDC_LANG_STATIC_LANG 1000 -#define IDC_LANG_COMBO_LANG 1001 +#define IDT_LANG_LANG 2102 +#define IDC_LANG_LANG 100 diff --git a/CPP/7zip/UI/FileManager/LangUtils.cpp b/CPP/7zip/UI/FileManager/LangUtils.cpp old mode 100755 new mode 100644 index 20f4655b..15d68f43 --- a/CPP/7zip/UI/FileManager/LangUtils.cpp +++ b/CPP/7zip/UI/FileManager/LangUtils.cpp @@ -2,51 +2,37 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" -#include "Common/StringToInt.h" +#include "../../../Common/Lang.h" -#include "Windows/DLL.h" -#include "Windows/FileFind.h" -#include "Windows/Synchronization.h" -#include "Windows/Window.h" +#include "../../../Windows/DLL.h" +#include "../../../Windows/Synchronization.h" +#include "../../../Windows/Window.h" #include "LangUtils.h" #include "RegistryUtils.h" using namespace NWindows; -static CLang g_Lang; -UString g_LangID; - #ifndef _UNICODE extern bool g_IsNT; #endif -static FString GetLangDirPrefix() +UString g_LangID; + +static CLang g_Lang; +static bool g_Loaded = false; +static NSynchronization::CCriticalSection g_CriticalSection; + +bool LangOpen(CLang &lang, CFSTR fileName) { - return NDLL::GetModuleDirPrefix() + FString(FTEXT("Lang") FSTRING_PATH_SEPARATOR); + return lang.Open(fileName, L"7-Zip"); } -void ReloadLang() +FString GetLangDirPrefix() { - ReadRegLang(g_LangID); - g_Lang.Clear(); - if (!g_LangID.IsEmpty() && g_LangID != L"-") - { - FString langPath = us2fs(g_LangID); - if (langPath.Find(WCHAR_PATH_SEPARATOR) < 0) - { - if (langPath.Find(FTEXT('.')) < 0) - langPath += FTEXT(".txt"); - langPath = GetLangDirPrefix() + langPath; - } - g_Lang.Open(langPath); - } + return NDLL::GetModuleDirPrefix() + FTEXT("Lang") FSTRING_PATH_SEPARATOR; } -static bool g_Loaded = false; -static NSynchronization::CCriticalSection g_CriticalSection; - void LoadLangOneTime() { NSynchronization::CCriticalSectionLock lock(g_CriticalSection); @@ -56,154 +42,210 @@ void LoadLangOneTime() ReloadLang(); } -void LangSetDlgItemsText(HWND dialogWindow, const CIDLangPair *idLangPairs, int numItems) +void LangSetDlgItemText(HWND dialog, UInt32 controlID, UInt32 langID) +{ + const wchar_t *s = g_Lang.Get(langID); + if (s) + { + CWindow window(GetDlgItem(dialog, controlID)); + window.SetText(s); + } +} + +static const CIDLangPair kLangPairs[] = +{ + { IDOK, 401 }, + { IDCANCEL, 402 }, + { IDYES, 406 }, + { IDNO, 407 }, + { IDHELP, 409 } +}; + + +void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems) { - for (int i = 0; i < numItems; i++) + unsigned i; + for (i = 0; i < ARRAY_SIZE(kLangPairs); i++) { - const CIDLangPair &idLangPair = idLangPairs[i]; - UString message; - if (g_Lang.GetMessage(idLangPair.LangID, message)) + const CIDLangPair &pair = kLangPairs[i]; + CWindow window(GetDlgItem(dialog, pair.ControlID)); + if (window) { - NWindows::CWindow window(GetDlgItem(dialogWindow, idLangPair.ControlID)); - window.SetText(message); + const wchar_t *s = g_Lang.Get(pair.LangID); + if (s) + window.SetText(s); } } + + for (i = 0; i < numItems; i++) + { + UInt32 id = ids[i]; + LangSetDlgItemText(dialog, id, id); + } } -void LangSetWindowText(HWND window, UInt32 langID) +void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems) { - UString message; - if (g_Lang.GetMessage(langID, message)) - MySetWindowText(window, message); + for (unsigned i = 0; i < numItems; i++) + { + UInt32 id = ids[i]; + const wchar_t *s = g_Lang.Get(id); + if (s) + { + CWindow window(GetDlgItem(dialog, id)); + UString s2 = s; + s2 += L':'; + window.SetText(s2); + } + } } -UString LangString(UInt32 langID) +void LangSetWindowText(HWND window, UInt32 langID) { - UString message; - if (g_Lang.GetMessage(langID, message)) - return message; - return UString(); + const wchar_t *s = g_Lang.Get(langID); + if (s) + MySetWindowText(window, s); } -UString LangString(UINT resourceID, UInt32 langID) +UString LangString(UInt32 langID) { - UString message; - if (g_Lang.GetMessage(langID, message)) - return message; - return MyLoadStringW(resourceID); + const wchar_t *s = g_Lang.Get(langID); + if (s) + return s; + return MyLoadString(langID); } -void LoadLangs(CObjectVector &langs) +void LangString(UInt32 langID, UString &dest) { - langs.Clear(); - const FString dirPrefix = GetLangDirPrefix(); - NFile::NFind::CEnumerator enumerator(dirPrefix + FTEXT("*.txt")); - NFile::NFind::CFileInfo fi; - while (enumerator.Next(fi)) + const wchar_t *s = g_Lang.Get(langID); + if (s) { - if (fi.IsDir()) - continue; - const int kExtSize = 4; - const FString ext = fi.Name.Right(kExtSize); - if (ext.CompareNoCase(FTEXT(".txt")) != 0) - continue; - CLangEx lang; - lang.ShortName = fs2us(fi.Name.Left(fi.Name.Length() - kExtSize)); - if (lang.Lang.Open(dirPrefix + fi.Name)) - langs.Add(lang); + dest = s; + return; } + MyLoadString(langID, dest); } -bool SplidID(const UString &id, WORD &primID, WORD &subID) +void LangString_OnlyFromLangFile(UInt32 langID, UString &dest) { - primID = 0; - subID = 0; - const wchar_t *start = id; - const wchar_t *end; - UInt64 value = ConvertStringToUInt64(start, &end); - if (start == end) - return false; - primID = (WORD)value; - if (*end == 0) - return true; - if (*end != L'-') - return false; - start = end + 1; - value = ConvertStringToUInt64(start, &end); - if (start == end) - return false; - subID = (WORD)value; - return (*end == 0); + dest.Empty(); + const wchar_t *s = g_Lang.Get(langID); + if (s) + dest = s; } -typedef LANGID (WINAPI *GetUserDefaultUILanguageP)(); +static const char *kLangs = +"ar.bg.ca.zh.-tw.-cn.cs.da.de.el.en.es.fi.fr.he.hu.is.it.ja.ko.nl.no.=nb.=nn." +"pl.pt.-br.rm.ro.ru.sr.=hr.-spl.-spc.sk.sq.sv.th.tr.ur.id.uk.be.sl.et.lv.lt.tg." +"fa.vi.hy.az.eu.hsb.mk...tn..xh.zu.af.ka.fo.hi.mt.se.ga." +".ms.kk.ky.sw.tk.uz.tt.bn.pa.-in.gu.or.ta.te.kn.ml.as.mr.sa.mn.=mn.=mng" +"bo.cy.kh.lo..gl.kok..sd.syr.si..iu.am.tzm.ks.ne.fy.ps.fil." +"dv...ha..yo.quz.nso.ba.lb.kl.ig...ti.....ii." +".arn..moh..br..ug.mi.oc.co.gsw.sah.qut.rw.wo....prs."; -void FindMatchLang(UString &shortName) +static void FindShortNames(UInt32 primeLang, UStringVector &names) { - shortName.Empty(); + UInt32 index = 0; + for (const char *p = kLangs; *p != 0;) + { + const char *p2 = p; + for (; *p2 != '.'; p2++); + bool isSub = (p[0] == '-' || p[0] == '='); + if (!isSub) + index++; + if (index > primeLang) + break; + if (index == primeLang) + { + UString s; + if (isSub) + { + if (p[0] == '-') + s = names[0]; + else + p++; + } + while (p != p2) + s += (wchar_t)*p++; + names.Add(s); + } + p = p2 + 1; + } +} - LANGID SystemDefaultLangID = GetSystemDefaultLangID(); // Lang for non-Unicode in XP64 - LANGID UserDefaultLangID = GetUserDefaultLangID(); // Standarts and formats in XP64 +// typedef LANGID (WINAPI *GetUserDefaultUILanguageP)(); - if (SystemDefaultLangID != UserDefaultLangID) +static void OpenDefaultLang() +{ + LANGID sysLang = GetSystemDefaultLangID(); // "Language for non-Unicode programs" in XP64 + LANGID userLang = GetUserDefaultLangID(); // "Standards and formats" language in XP64 + + if (sysLang != userLang) return; - LANGID langID = UserDefaultLangID; + LANGID langID = userLang; + /* - LANGID SystemDefaultUILanguage; // english in XP64 - LANGID UserDefaultUILanguage; // english in XP64 + LANGID sysUILang; // english in XP64 + LANGID userUILang; // english in XP64 GetUserDefaultUILanguageP fn = (GetUserDefaultUILanguageP)GetProcAddress( GetModuleHandle("kernel32"), "GetUserDefaultUILanguage"); - if (fn != NULL) - UserDefaultUILanguage = fn(); + if (fn) + userUILang = fn(); fn = (GetUserDefaultUILanguageP)GetProcAddress( GetModuleHandle("kernel32"), "GetSystemDefaultUILanguage"); - if (fn != NULL) - SystemDefaultUILanguage = fn(); + if (fn) + sysUILang = fn(); */ WORD primLang = (WORD)(PRIMARYLANGID(langID)); WORD subLang = (WORD)(SUBLANGID(langID)); - CObjectVector langs; - LoadLangs(langs); - for (int i = 0; i < langs.Size(); i++) { - const CLangEx &lang = langs[i]; - UString id; - if (lang.Lang.GetMessage(0x00000002, id)) + UStringVector names; + FindShortNames(primLang, names); + const FString dirPrefix = GetLangDirPrefix(); + for (unsigned i = 0; i < 2; i++) { - WORD primID; - WORD subID; - if (SplidID(id, primID, subID)) - if (primID == primLang) + unsigned index = (i == 0 ? subLang : 0); + if (index < names.Size()) + { + const UString &name = names[index]; + if (!name.IsEmpty()) { - if (subID == 0) - shortName = lang.ShortName; - if (subLang == subID) + if (LangOpen(g_Lang, dirPrefix + us2fs(name) + FTEXT(".txt"))) { - shortName = lang.ShortName; + g_LangID = name; return; } } + } } } } -void ReloadLangSmart() +void ReloadLang() { + g_Lang.Clear(); + ReadRegLang(g_LangID); #ifndef _UNICODE if (g_IsNT) #endif { - ReadRegLang(g_LangID); if (g_LangID.IsEmpty()) { - UString shortName; - FindMatchLang(shortName); - if (shortName.IsEmpty()) - shortName = L"-"; - SaveRegLang(shortName); + OpenDefaultLang(); + return; } } - ReloadLang(); + if (g_LangID.Len() > 1 || g_LangID[0] != L'-') + { + FString s = us2fs(g_LangID); + if (s.Find(FCHAR_PATH_SEPARATOR) < 0) + { + if (s.Find(FTEXT('.')) < 0) + s += FTEXT(".txt"); + s.Insert(0, GetLangDirPrefix()); + } + LangOpen(g_Lang, s); + } } diff --git a/CPP/7zip/UI/FileManager/LangUtils.h b/CPP/7zip/UI/FileManager/LangUtils.h old mode 100755 new mode 100644 index d11082f6..509a5ae3 --- a/CPP/7zip/UI/FileManager/LangUtils.h +++ b/CPP/7zip/UI/FileManager/LangUtils.h @@ -3,39 +3,36 @@ #ifndef __LANG_UTILS_H #define __LANG_UTILS_H -#include "Common/Lang.h" -#include "Windows/ResourceString.h" +#include "../../../Windows/ResourceString.h" + +#ifdef LANG extern UString g_LangID; struct CIDLangPair { - int ControlID; + UInt32 ControlID; UInt32 LangID; }; void ReloadLang(); void LoadLangOneTime(); -void ReloadLangSmart(); - -struct CLangEx -{ - CLang Lang; - UString ShortName; -}; +FString GetLangDirPrefix(); -void LoadLangs(CObjectVector &langs); - -void LangSetDlgItemsText(HWND dialogWindow, const CIDLangPair *idLangPairs, int numItems); +void LangSetDlgItemText(HWND dialog, UInt32 controlID, UInt32 langID); +void LangSetDlgItems(HWND dialog, const UInt32 *ids, unsigned numItems); +void LangSetDlgItems_Colon(HWND dialog, const UInt32 *ids, unsigned numItems); void LangSetWindowText(HWND window, UInt32 langID); UString LangString(UInt32 langID); -UString LangString(UINT resourceID, UInt32 langID); +void LangString(UInt32 langID, UString &dest); +void LangString_OnlyFromLangFile(UInt32 langID, UString &dest); -#ifdef LANG -#define LangStringSpec(resourceID, langID) LangString(resourceID, langID) #else -#define LangStringSpec(resourceID, langID) NWindows::MyLoadStringW(resourceID) + +inline UString LangString(UInt32 langID) { return NWindows::MyLoadString(langID); } +inline void LangString(UInt32 langID, UString &dest) { NWindows::MyLoadString(langID, dest); } + #endif #endif diff --git a/CPP/7zip/UI/FileManager/LinkDialog.cpp b/CPP/7zip/UI/FileManager/LinkDialog.cpp new file mode 100644 index 00000000..a24ec601 --- /dev/null +++ b/CPP/7zip/UI/FileManager/LinkDialog.cpp @@ -0,0 +1,342 @@ +// LinkDialog.cpp + +#include "StdAfx.h" + +#include "../../../Windows/ErrorMsg.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/FileFind.h" +#include "../../../Windows/FileIO.h" +#include "../../../Windows/FileName.h" + +#ifdef LANG +#include "LangUtils.h" +#endif + +#include "BrowseDialog.h" +#include "CopyDialogRes.h" +#include "LinkDialog.h" +#include "resourceGui.h" + +#include "App.h" + +#include "resource.h" + +extern bool g_SymLink_Supported; + +using namespace NWindows; +using namespace NFile; + +#ifdef LANG +static const UInt32 kLangIDs[] = +{ + IDB_LINK_LINK, + IDT_LINK_PATH_FROM, + IDT_LINK_PATH_TO, + IDG_LINK_TYPE, + IDR_LINK_TYPE_HARD, + IDR_LINK_TYPE_SYM_FILE, + IDR_LINK_TYPE_SYM_DIR, + IDR_LINK_TYPE_JUNCTION +}; +#endif + +static bool GetSymLink(CFSTR path, CReparseAttr &attr) +{ + NFile::NIO::CInFile file; + if (!file.Open(path, + FILE_SHARE_READ, + OPEN_EXISTING, + FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS)) + return false; + + const unsigned kBufSize = MAXIMUM_REPARSE_DATA_BUFFER_SIZE; + CByteArr buf(kBufSize); + DWORD returnedSize; + if (!file.DeviceIoControlOut(my_FSCTL_GET_REPARSE_POINT, buf, kBufSize, &returnedSize)) + return false; + + if (!attr.Parse(buf, returnedSize)) + return false; + + CByteBuffer data2; + if (!FillLinkData(data2, attr.GetPath(), attr.IsSymLink())) + return false; + + if (data2.Size() != returnedSize || + memcmp(data2, buf, returnedSize) != 0) + return false; + + return true; +} + +static const int k_LinkType_Buttons[] = +{ + IDR_LINK_TYPE_HARD, + IDR_LINK_TYPE_SYM_FILE, + IDR_LINK_TYPE_SYM_DIR, + IDR_LINK_TYPE_JUNCTION +}; + +void CLinkDialog::Set_LinkType_Radio(int idb) +{ + CheckRadioButton(k_LinkType_Buttons[0], k_LinkType_Buttons[ARRAY_SIZE(k_LinkType_Buttons) - 1], idb); +} + +bool CLinkDialog::OnInit() +{ + #ifdef LANG + LangSetWindowText(*this, IDD_LINK); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); + #endif + _pathFromCombo.Attach(GetItem(IDC_LINK_PATH_FROM)); + _pathToCombo.Attach(GetItem(IDC_LINK_PATH_TO)); + + if (!FilePath.IsEmpty()) + { + NFile::NFind::CFileInfo fi; + int linkType = 0; + if (!fi.Find(us2fs(FilePath))) + linkType = IDR_LINK_TYPE_SYM_FILE; + else + { + if (fi.HasReparsePoint()) + { + CReparseAttr attr; + bool res = GetSymLink(us2fs(FilePath), attr); + + UString s = attr.PrintName; + if (!attr.IsOkNamePair()) + { + s += L" : "; + s += attr.SubsName; + } + if (!res) + s = L"ERROR: " + s; + + SetItemText(IDT_LINK_PATH_TO_CUR, s); + + UString destPath = attr.GetPath(); + _pathFromCombo.SetText(FilePath); + _pathToCombo.SetText(destPath); + + if (res) + { + if (attr.IsMountPoint()) + linkType = IDR_LINK_TYPE_JUNCTION; + if (attr.IsSymLink()) + { + linkType = + fi.IsDir() ? + IDR_LINK_TYPE_SYM_DIR : + IDR_LINK_TYPE_SYM_FILE; + // if (attr.IsRelative()) linkType = IDR_LINK_TYPE_SYM_RELATIVE; + } + + if (linkType != 0) + Set_LinkType_Radio(linkType); + } + } + else + { + _pathFromCombo.SetText(AnotherPath); + _pathToCombo.SetText(FilePath); + if (fi.IsDir()) + linkType = g_SymLink_Supported ? + IDR_LINK_TYPE_SYM_DIR : + IDR_LINK_TYPE_JUNCTION; + else + linkType = IDR_LINK_TYPE_HARD; + } + } + if (linkType != 0) + Set_LinkType_Radio(linkType); + } + + NormalizeSize(); + return CModalDialog::OnInit(); +} + +bool CLinkDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) +{ + int mx, my; + GetMargins(8, mx, my); + int bx1, bx2, by; + GetItemSizes(IDCANCEL, bx1, by); + GetItemSizes(IDB_LINK_LINK, bx2, by); + int yPos = ySize - my - by; + int xPos = xSize - mx - bx1; + + InvalidateRect(NULL); + + { + RECT r, r2; + GetClientRectOfItem(IDB_LINK_PATH_FROM, r); + GetClientRectOfItem(IDB_LINK_PATH_TO, r2); + int bx = RECT_SIZE_X(r); + int newButtonXpos = xSize - mx - bx; + + MoveItem(IDB_LINK_PATH_FROM, newButtonXpos, r.top, bx, RECT_SIZE_Y(r)); + MoveItem(IDB_LINK_PATH_TO, newButtonXpos, r2.top, bx, RECT_SIZE_Y(r2)); + + int newComboXsize = newButtonXpos - mx - mx; + ChangeSubWindowSizeX(_pathFromCombo, newComboXsize); + ChangeSubWindowSizeX(_pathToCombo, newComboXsize); + } + + MoveItem(IDCANCEL, xPos, yPos, bx1, by); + MoveItem(IDB_LINK_LINK, xPos - mx - bx2, yPos, bx2, by); + + return false; +} + +bool CLinkDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + switch (buttonID) + { + case IDB_LINK_PATH_FROM: + OnButton_SetPath(false); + return true; + case IDB_LINK_PATH_TO: + OnButton_SetPath(true); + return true; + case IDB_LINK_LINK: + OnButton_Link(); + return true; + } + return CModalDialog::OnButtonClicked(buttonID, buttonHWND); +} + +void CLinkDialog::OnButton_SetPath(bool to) +{ + UString currentPath; + NWindows::NControl::CComboBox &combo = to ? + _pathToCombo : + _pathFromCombo; + combo.GetText(currentPath); + // UString title = L"Specify a location for output folder"; + UString title = LangString(IDS_SET_FOLDER); + + UString resultPath; + if (!MyBrowseForFolder(*this, title, currentPath, resultPath)) + return; + NFile::NName::NormalizeDirPathPrefix(resultPath); + combo.SetCurSel(-1); + combo.SetText(resultPath); +} + +void CLinkDialog::ShowError(const wchar_t *s) +{ + ::MessageBoxW(*this, s, L"7-Zip", MB_ICONERROR); +} + +void CLinkDialog::ShowLastErrorMessage() +{ + ShowError(NError::MyFormatMessage(GetLastError())); +} + +void CLinkDialog::OnButton_Link() +{ + UString from, to; + _pathFromCombo.GetText(from); + _pathToCombo.GetText(to); + int i; + for (i = 0; i < ARRAY_SIZE(k_LinkType_Buttons); i++) + if (IsButtonCheckedBool(k_LinkType_Buttons[i])) + break; + if (i >= ARRAY_SIZE(k_LinkType_Buttons)) + return; + + int idb = k_LinkType_Buttons[i]; + + NFile::NFind::CFileInfo info1, info2; + bool finded1 = info1.Find(us2fs(from)); + bool finded2 = info2.Find(us2fs(to)); + + bool isDirLink = ( + idb == IDR_LINK_TYPE_SYM_DIR || + idb == IDR_LINK_TYPE_JUNCTION); + + if (finded1 && info1.IsDir() != isDirLink || + finded2 && info2.IsDir() != isDirLink) + { + ShowError(L"Incorrect linkType"); + return; + } + + if (idb == IDR_LINK_TYPE_HARD) + { + bool res = NFile::NDir::MyCreateHardLink(us2fs(from), us2fs(to)); + if (!res) + { + ShowLastErrorMessage(); + return; + } + } + else + { + bool isSymLink = (idb != IDR_LINK_TYPE_JUNCTION); + + CByteBuffer data; + if (!FillLinkData(data, to, isSymLink)) + { + ShowError(L"Incorrect link"); + return; + } + + CReparseAttr attr; + if (!attr.Parse(data, data.Size())) + { + ShowError(L"Internal conversion error"); + return; + } + + + if (!NFile::NIO::SetReparseData(us2fs(from), isDirLink, data, (DWORD)data.Size())) + { + ShowLastErrorMessage(); + } + } + + End(IDOK); +} + +void CApp::Link() +{ + int srcPanelIndex = GetFocusedPanelIndex(); + CPanel &srcPanel = Panels[srcPanelIndex]; + if (!srcPanel.IsFSFolder()) + { + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); + return; + } + CRecordVector indices; + srcPanel.GetOperatedItemIndices(indices); + if (indices.IsEmpty()) + return; + if (indices.Size() != 1) + { + srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE); + return; + } + int index = indices[0]; + const UString itemName = srcPanel.GetItemName(index); + + UString srcPath = srcPanel._currentFolderPrefix + srcPanel.GetItemPrefix(index); + UString path = srcPath; + { + int destPanelIndex = (NumPanels <= 1) ? srcPanelIndex : (1 - srcPanelIndex); + CPanel &destPanel = Panels[destPanelIndex]; + if (NumPanels > 1) + if (destPanel.IsFSFolder()) + path = destPanel._currentFolderPrefix; + } + + CLinkDialog dlg; + dlg.FilePath = srcPath + itemName; + dlg.AnotherPath = path; + + if (dlg.Create(srcPanel.GetParent()) != IDOK) + return; + + RefreshTitleAlways(); +} diff --git a/CPP/7zip/UI/FileManager/LinkDialog.h b/CPP/7zip/UI/FileManager/LinkDialog.h new file mode 100644 index 00000000..8417fac8 --- /dev/null +++ b/CPP/7zip/UI/FileManager/LinkDialog.h @@ -0,0 +1,33 @@ +// LinkDialog.h + +#ifndef __LINK_DIALOG_H +#define __LINK_DIALOG_H + +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/ComboBox.h" + +#include "LinkDialogRes.h" + +class CLinkDialog: public NWindows::NControl::CModalDialog +{ + NWindows::NControl::CComboBox _pathFromCombo; + NWindows::NControl::CComboBox _pathToCombo; + + virtual bool OnInit(); + virtual bool OnSize(WPARAM wParam, int xSize, int ySize); + virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); + void OnButton_SetPath(bool to); + void OnButton_Link(); + + void ShowLastErrorMessage(); + void ShowError(const wchar_t *s); + void Set_LinkType_Radio(int idb); +public: + UString FilePath; + UString AnotherPath; + + INT_PTR Create(HWND parentWindow = 0) + { return CModalDialog::Create(IDD_LINK, parentWindow); } +}; + +#endif diff --git a/CPP/7zip/UI/FileManager/LinkDialog.rc b/CPP/7zip/UI/FileManager/LinkDialog.rc new file mode 100644 index 00000000..3d481d4d --- /dev/null +++ b/CPP/7zip/UI/FileManager/LinkDialog.rc @@ -0,0 +1,36 @@ +#include "LinkDialogRes.h" +#include "../../GuiCommon.rc" + +#define xc 288 +#define yc 200 + +#undef xRadioSize +#define xRadioSize xc - m - 2 + +IDD_LINK DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT +CAPTION "Link" +BEGIN + LTEXT "Link from:", IDT_LINK_PATH_FROM, m, m, xc, 8 + COMBOBOX IDC_LINK_PATH_FROM, m, 20, xc - bxsDots - m, 64, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDB_LINK_PATH_FROM, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP + + LTEXT "Link to:", IDT_LINK_PATH_TO, m, 48, xc, 8 + COMBOBOX IDC_LINK_PATH_TO, m, 60, xc - bxsDots - m, 64, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDB_LINK_PATH_TO, xs - m - bxsDots, 58, bxsDots, bys, WS_GROUP + + LTEXT "", IDT_LINK_PATH_TO_CUR, m, 78, xc, 8 + + GROUPBOX "Link Type", IDG_LINK_TYPE, m, 104, xc, 76 + + CONTROL "Hard Link", IDR_LINK_TYPE_HARD, "Button", BS_AUTORADIOBUTTON | WS_GROUP, + m + m, 120, xRadioSize, 10 + CONTROL "File Symbolic Link", IDR_LINK_TYPE_SYM_FILE, "Button", BS_AUTORADIOBUTTON, + m + m, 134, xRadioSize, 10 + CONTROL "Directory Symbolic Link", IDR_LINK_TYPE_SYM_DIR, "Button", BS_AUTORADIOBUTTON, + m + m, 148, xRadioSize, 10 + CONTROL "Directory Junction", IDR_LINK_TYPE_JUNCTION, "Button", BS_AUTORADIOBUTTON, + m + m, 162, xRadioSize, 10 + + DEFPUSHBUTTON "Link", IDB_LINK_LINK, bx2, by, bxs, bys + PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys +END diff --git a/CPP/7zip/UI/FileManager/LinkDialogRes.h b/CPP/7zip/UI/FileManager/LinkDialogRes.h new file mode 100644 index 00000000..6b2dc2cf --- /dev/null +++ b/CPP/7zip/UI/FileManager/LinkDialogRes.h @@ -0,0 +1,21 @@ +#define IDD_LINK 7700 + +#define IDB_LINK_LINK 7701 + +#define IDT_LINK_PATH_FROM 7702 +#define IDT_LINK_PATH_TO 7703 + +#define IDG_LINK_TYPE 7710 +#define IDR_LINK_TYPE_HARD 7711 +#define IDR_LINK_TYPE_SYM_FILE 7712 +#define IDR_LINK_TYPE_SYM_DIR 7713 +#define IDR_LINK_TYPE_JUNCTION 7714 + + +#define IDC_LINK_PATH_FROM 100 +#define IDC_LINK_PATH_TO 101 + +#define IDT_LINK_PATH_TO_CUR 102 + +#define IDB_LINK_PATH_FROM 103 +#define IDB_LINK_PATH_TO 104 diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.cpp b/CPP/7zip/UI/FileManager/ListViewDialog.cpp old mode 100755 new mode 100644 index b3e989c4..78c9562a --- a/CPP/7zip/UI/FileManager/ListViewDialog.cpp +++ b/CPP/7zip/UI/FileManager/ListViewDialog.cpp @@ -7,19 +7,16 @@ #ifdef LANG #include "LangUtils.h" -static CIDLangPair kIDLangPairs[] = -{ - { IDOK, 0x02000702 }, - { IDCANCEL, 0x02000710 } -}; #endif +using namespace NWindows; + bool CListViewDialog::OnInit() { #ifdef LANG - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, NULL, 0); #endif - _listView.Attach(GetItem(IDC_LISTVIEW_LIST)); + _listView.Attach(GetItem(IDL_LISTVIEW)); if (ReadSingleClick()) _listView.SetExtendedListViewStyle(LVS_EX_ONECLICKACTIVATE | LVS_EX_TRACKSELECT); @@ -34,7 +31,7 @@ bool CListViewDialog::OnInit() _listView.InsertColumn(0, &columnInfo); - for (int i = 0; i < Strings.Size(); i++) + FOR_VECTOR (i, Strings) _listView.InsertItem(i, Strings[i]); if (Strings.Size() > 0) @@ -125,8 +122,7 @@ bool CListViewDialog::OnNotify(UINT /* controlID */, LPNMHDR header) } case 'A': { - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - if (ctrl) + if (IsKeyDown(VK_CONTROL)) { _listView.SelectAll(); return true; diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.h b/CPP/7zip/UI/FileManager/ListViewDialog.h old mode 100755 new mode 100644 index 6be51c7e..b7ba3830 --- a/CPP/7zip/UI/FileManager/ListViewDialog.h +++ b/CPP/7zip/UI/FileManager/ListViewDialog.h @@ -3,8 +3,8 @@ #ifndef __LISTVIEW_DIALOG_H #define __LISTVIEW_DIALOG_H -#include "Windows/Control/Dialog.h" -#include "Windows/Control/ListView.h" +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/ListView.h" #include "ListViewDialogRes.h" @@ -22,7 +22,7 @@ public: UStringVector Strings; int FocusedItemIndex; - INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_DIALOG_LISTVIEW, wndParent); } + INT_PTR Create(HWND wndParent = 0) { return CModalDialog::Create(IDD_LISTVIEW, wndParent); } CListViewDialog(): DeleteIsAllowed(false) {} }; diff --git a/CPP/7zip/UI/FileManager/ListViewDialog.rc b/CPP/7zip/UI/FileManager/ListViewDialog.rc old mode 100755 new mode 100644 index 8f963bf1..14d3b2e6 --- a/CPP/7zip/UI/FileManager/ListViewDialog.rc +++ b/CPP/7zip/UI/FileManager/ListViewDialog.rc @@ -4,10 +4,10 @@ #define xc 320 #define yc 240 -IDD_DIALOG_LISTVIEW MY_RESIZE_DIALOG +IDD_LISTVIEW DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT CAPTION "ListView" { - CONTROL "List1", IDC_LISTVIEW_LIST, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | + CONTROL "List1", IDL_LISTVIEW, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | LVS_AUTOARRANGE | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP, m, m, xc, yc - bys - m OK_CANCEL diff --git a/CPP/7zip/UI/FileManager/ListViewDialogRes.h b/CPP/7zip/UI/FileManager/ListViewDialogRes.h old mode 100755 new mode 100644 index aaa6521f..9abdb9d2 --- a/CPP/7zip/UI/FileManager/ListViewDialogRes.h +++ b/CPP/7zip/UI/FileManager/ListViewDialogRes.h @@ -1,2 +1,2 @@ -#define IDD_DIALOG_LISTVIEW 508 -#define IDC_LISTVIEW_LIST 1000 +#define IDD_LISTVIEW 99 +#define IDL_LISTVIEW 100 diff --git a/CPP/7zip/UI/FileManager/MenuPage.cpp b/CPP/7zip/UI/FileManager/MenuPage.cpp old mode 100755 new mode 100644 index c3e013b5..0784f92c --- a/CPP/7zip/UI/FileManager/MenuPage.cpp +++ b/CPP/7zip/UI/FileManager/MenuPage.cpp @@ -14,13 +14,16 @@ #include "MenuPageRes.h" #include "FormatUtils.h" +#include "../FileManager/PropertyNameRes.h" + using namespace NContextMenuFlags; -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, 0x01000301}, - { IDC_SYSTEM_CASCADED_MENU, 0x01000302}, - { IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, 0x01000310} + IDX_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, + IDX_SYSTEM_CASCADED_MENU, + IDX_SYSTEM_ICON_IN_MENU, + IDT_SYSTEM_CONTEXT_MENU_ITEMS }; static LPCWSTR kSystemTopic = L"fm/options.htm#sevenZip"; @@ -28,77 +31,80 @@ static LPCWSTR kSystemTopic = L"fm/options.htm#sevenZip"; struct CContextMenuItem { int ControlID; - UInt32 LangID; UInt32 Flag; }; static CContextMenuItem kMenuItems[] = { - { IDS_CONTEXT_OPEN, 0x02000103, kOpen}, - { IDS_CONTEXT_OPEN, 0x02000103, kOpenAs}, - { IDS_CONTEXT_EXTRACT, 0x02000105, kExtract}, - { IDS_CONTEXT_EXTRACT_HERE, 0x0200010B, kExtractHere }, - { IDS_CONTEXT_EXTRACT_TO, 0x0200010D, kExtractTo }, + { IDS_CONTEXT_OPEN, kOpen}, + { IDS_CONTEXT_OPEN, kOpenAs}, + { IDS_CONTEXT_EXTRACT, kExtract}, + { IDS_CONTEXT_EXTRACT_HERE, kExtractHere }, + { IDS_CONTEXT_EXTRACT_TO, kExtractTo }, - { IDS_CONTEXT_TEST, 0x02000109, kTest}, + { IDS_CONTEXT_TEST, kTest}, - { IDS_CONTEXT_COMPRESS, 0x02000107, kCompress }, - { IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressTo7z }, - { IDS_CONTEXT_COMPRESS_TO, 0x0200010F, kCompressToZip } + { IDS_CONTEXT_COMPRESS, kCompress }, + { IDS_CONTEXT_COMPRESS_TO, kCompressTo7z }, + { IDS_CONTEXT_COMPRESS_TO, kCompressToZip } #ifndef UNDER_CE , - { IDS_CONTEXT_COMPRESS_EMAIL, 0x02000111, kCompressEmail }, - { IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressTo7zEmail }, - { IDS_CONTEXT_COMPRESS_TO_EMAIL, 0x02000113, kCompressToZipEmail } + { IDS_CONTEXT_COMPRESS_EMAIL, kCompressEmail }, + { IDS_CONTEXT_COMPRESS_TO_EMAIL, kCompressTo7zEmail }, + { IDS_CONTEXT_COMPRESS_TO_EMAIL, kCompressToZipEmail } #endif -}; -const int kNumMenuItems = sizeof(kMenuItems) / sizeof(kMenuItems[0]); + , { IDS_PROP_CHECKSUM, kCRC } +}; bool CMenuPage::OnInit() { _initMode = true; - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); #ifdef UNDER_CE - EnableItem(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, false); + EnableItem(IDX_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, false); #else - CheckButton(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, NZipRootRegistry::CheckContextMenuHandler()); + CheckButton(IDX_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, NZipRootRegistry::CheckContextMenuHandler()); #endif CContextMenuInfo ci; ci.Load(); - CheckButton(IDC_SYSTEM_CASCADED_MENU, ci.Cascaded); + CheckButton(IDX_SYSTEM_CASCADED_MENU, ci.Cascaded); + CheckButton(IDX_SYSTEM_ICON_IN_MENU, ci.MenuIcons); - _listView.Attach(GetItem(IDC_SYSTEM_OPTIONS_LIST)); + _listView.Attach(GetItem(IDL_SYSTEM_OPTIONS)); UInt32 newFlags = LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT; _listView.SetExtendedListViewStyle(newFlags, newFlags); _listView.InsertColumn(0, L"", 100); - for (int i = 0; i < kNumMenuItems; i++) + for (int i = 0; i < ARRAY_SIZE(kMenuItems); i++) { CContextMenuItem &menuItem = kMenuItems[i]; - UString s = LangString(menuItem.ControlID, menuItem.LangID); - if (menuItem.Flag == kOpenAs) + UString s = LangString(menuItem.ControlID); + if (menuItem.Flag == kCRC) + s = L"CRC SHA"; + if (menuItem.Flag == kOpenAs || + menuItem.Flag == kCRC) s += L" >"; - switch(menuItem.ControlID) + switch (menuItem.ControlID) { case IDS_CONTEXT_EXTRACT_TO: { - s = MyFormatNew(s, LangString(IDS_CONTEXT_FOLDER, 0x02000140)); + s = MyFormatNew(s, LangString(IDS_CONTEXT_FOLDER)); break; } case IDS_CONTEXT_COMPRESS_TO: case IDS_CONTEXT_COMPRESS_TO_EMAIL: { - UString s2 = LangString(IDS_CONTEXT_ARCHIVE, 0x02000141); - switch(menuItem.Flag) + UString s2 = LangString(IDS_CONTEXT_ARCHIVE); + switch (menuItem.Flag) { case kCompressTo7z: case kCompressTo7zEmail: @@ -133,7 +139,7 @@ LONG CMenuPage::OnApply() { #ifndef UNDER_CE g_MenuPageHWND = *this; - if (IsButtonCheckedBool(IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU)) + if (IsButtonCheckedBool(IDX_SYSTEM_INTEGRATE_TO_CONTEXT_MENU)) { DllRegisterServer(); NZipRootRegistry::AddContextMenuHandler(); @@ -146,9 +152,10 @@ LONG CMenuPage::OnApply() #endif CContextMenuInfo ci; - ci.Cascaded = IsButtonCheckedBool(IDC_SYSTEM_CASCADED_MENU); + ci.Cascaded = IsButtonCheckedBool(IDX_SYSTEM_CASCADED_MENU); + ci.MenuIcons = IsButtonCheckedBool(IDX_SYSTEM_ICON_IN_MENU); ci.Flags = 0; - for (int i = 0; i < kNumMenuItems; i++) + for (int i = 0; i < ARRAY_SIZE(kMenuItems); i++) if (_listView.GetCheckState(i)) ci.Flags |= kMenuItems[i].Flag; ci.Save(); @@ -163,10 +170,11 @@ void CMenuPage::OnNotifyHelp() bool CMenuPage::OnButtonClicked(int buttonID, HWND buttonHWND) { - switch(buttonID) + switch (buttonID) { - case IDC_SYSTEM_CASCADED_MENU: - case IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU: + case IDX_SYSTEM_INTEGRATE_TO_CONTEXT_MENU: + case IDX_SYSTEM_CASCADED_MENU: + case IDX_SYSTEM_ICON_IN_MENU: Changed(); return true; } @@ -178,7 +186,7 @@ bool CMenuPage::OnNotify(UINT controlID, LPNMHDR lParam) { if (lParam->hwndFrom == HWND(_listView)) { - switch(lParam->code) + switch (lParam->code) { case (LVN_ITEMCHANGED): return OnItemChanged((const NMLISTVIEW *)lParam); diff --git a/CPP/7zip/UI/FileManager/MenuPage.h b/CPP/7zip/UI/FileManager/MenuPage.h old mode 100755 new mode 100644 index 5005ea9c..1363687f --- a/CPP/7zip/UI/FileManager/MenuPage.h +++ b/CPP/7zip/UI/FileManager/MenuPage.h @@ -3,8 +3,8 @@ #ifndef __MENU_PAGE_H #define __MENU_PAGE_H -#include "Windows/Control/PropertyPage.h" -#include "Windows/Control/ListView.h" +#include "../../../Windows/Control/PropertyPage.h" +#include "../../../Windows/Control/ListView.h" #include "../Common/LoadCodecs.h" diff --git a/CPP/7zip/UI/FileManager/MenuPage.rc b/CPP/7zip/UI/FileManager/MenuPage.rc old mode 100755 new mode 100644 index 791a1c08..626f415e --- a/CPP/7zip/UI/FileManager/MenuPage.rc +++ b/CPP/7zip/UI/FileManager/MenuPage.rc @@ -2,7 +2,7 @@ #include "../../GuiCommon.rc" #define xc 196 -#define yc 174 +#define yc 196 IDD_MENU MY_PAGE #include "MenuPage2.rc" diff --git a/CPP/7zip/UI/FileManager/MenuPage2.rc b/CPP/7zip/UI/FileManager/MenuPage2.rc old mode 100755 new mode 100644 index 1862aa06..442d1bdd --- a/CPP/7zip/UI/FileManager/MenuPage2.rc +++ b/CPP/7zip/UI/FileManager/MenuPage2.rc @@ -1,14 +1,13 @@ -#define y 40 +#define y 54 CAPTION "7-Zip" BEGIN - CONTROL "Integrate 7-Zip to shell context menu", IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, - MY_CHECKBOX, m, m, xc, 10 - CONTROL "Cascaded context menu", IDC_SYSTEM_CASCADED_MENU, - MY_CHECKBOX, m, m + 14, xc, 10 - LTEXT "Context menu items:", IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS, - m, m + 28, xc, 8 - CONTROL "List", IDC_SYSTEM_OPTIONS_LIST, "SysListView32", + CONTROL "Integrate 7-Zip to shell context menu", IDX_SYSTEM_INTEGRATE_TO_CONTEXT_MENU, MY_CHECKBOX, m, m, xc, 10 + CONTROL "Cascaded context menu", IDX_SYSTEM_CASCADED_MENU, MY_CHECKBOX, m, m + 14, xc, 10 + CONTROL "Icons in context menu", IDX_SYSTEM_ICON_IN_MENU, MY_CHECKBOX, m, m + 28, xc, 10 + + LTEXT "Context menu items:", IDT_SYSTEM_CONTEXT_MENU_ITEMS, m, m + 42, xc, 8 + CONTROL "List", IDL_SYSTEM_OPTIONS, "SysListView32", LVS_REPORT | LVS_SINGLESEL | LVS_NOCOLUMNHEADER | WS_BORDER | WS_TABSTOP, m, m + y, xc, yc - y END diff --git a/CPP/7zip/UI/FileManager/MenuPageRes.h b/CPP/7zip/UI/FileManager/MenuPageRes.h old mode 100755 new mode 100644 index f1220bfd..91f75710 --- a/CPP/7zip/UI/FileManager/MenuPageRes.h +++ b/CPP/7zip/UI/FileManager/MenuPageRes.h @@ -1,7 +1,9 @@ -#define IDD_MENU 570 -#define IDD_MENU_2 670 +#define IDD_MENU 2300 +#define IDD_MENU_2 12300 -#define IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 1010 -#define IDC_SYSTEM_CASCADED_MENU 1011 -#define IDC_SYSTEM_STATIC_CONTEXT_MENU_ITEMS 1020 -#define IDC_SYSTEM_OPTIONS_LIST 1022 +#define IDX_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 2301 +#define IDX_SYSTEM_CASCADED_MENU 2302 +#define IDT_SYSTEM_CONTEXT_MENU_ITEMS 2303 +#define IDX_SYSTEM_ICON_IN_MENU 2304 + +#define IDL_SYSTEM_OPTIONS 100 diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.cpp b/CPP/7zip/UI/FileManager/MessagesDialog.cpp old mode 100755 new mode 100644 index 05aa823f..41248277 --- a/CPP/7zip/UI/FileManager/MessagesDialog.cpp +++ b/CPP/7zip/UI/FileManager/MessagesDialog.cpp @@ -2,32 +2,25 @@ #include "StdAfx.h" -#include "Common/IntToString.h" +#include "../../../Common/IntToString.h" -#include "Windows/ResourceString.h" +#include "../../../Windows/ResourceString.h" #include "MessagesDialog.h" -#ifdef LANG #include "LangUtils.h" -#endif -using namespace NWindows; +#include "ProgressDialog2Res.h" -#ifdef LANG -static CIDLangPair kIDLangPairs[] = -{ - { IDOK, 0x02000713 } -}; -#endif +using namespace NWindows; void CMessagesDialog::AddMessageDirect(LPCWSTR message) { - int itemIndex = _messageList.GetItemCount(); - wchar_t sz[32]; - ConvertInt64ToString(itemIndex, sz); - _messageList.InsertItem(itemIndex, sz); - _messageList.SetSubItem(itemIndex, 1, message); + int i = _messageList.GetItemCount(); + wchar_t sz[16]; + ConvertUInt32ToString((UInt32)i, sz); + _messageList.InsertItem(i, sz); + _messageList.SetSubItem(i, 1, message); } void CMessagesDialog::AddMessage(LPCWSTR message) @@ -39,7 +32,7 @@ void CMessagesDialog::AddMessage(LPCWSTR message) if (pos < 0) break; AddMessageDirect(s.Left(pos)); - s.Delete(0, pos + 1); + s.DeleteFrontal(pos + 1); } AddMessageDirect(s); } @@ -47,24 +40,17 @@ void CMessagesDialog::AddMessage(LPCWSTR message) bool CMessagesDialog::OnInit() { #ifdef LANG - LangSetWindowText(HWND(*this), 0x02000A00); - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetWindowText(*this, IDD_MESSAGES); + LangSetDlgItems(*this, NULL, 0); + SetItemText(IDOK, LangString(IDS_CLOSE)); #endif - _messageList.Attach(GetItem(IDC_MESSAGE_LIST)); + _messageList.Attach(GetItem(IDL_MESSAGE)); _messageList.SetUnicodeFormat(); _messageList.InsertColumn(0, L"", 30); + _messageList.InsertColumn(1, LangString(IDS_MESSAGE), 600); - const UString s = - #ifdef LANG - LangString(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80); - #else - MyLoadStringW(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN); - #endif - - _messageList.InsertColumn(1, s, 600); - - for (int i = 0; i < Messages->Size(); i++) + FOR_VECTOR (i, *Messages) AddMessage((*Messages)[i]); _messageList.SetColumnWidthAuto(0); diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.h b/CPP/7zip/UI/FileManager/MessagesDialog.h old mode 100755 new mode 100644 index 1304d516..5c017eb4 --- a/CPP/7zip/UI/FileManager/MessagesDialog.h +++ b/CPP/7zip/UI/FileManager/MessagesDialog.h @@ -3,21 +3,23 @@ #ifndef __MESSAGES_DIALOG_H #define __MESSAGES_DIALOG_H -#include "Windows/Control/Dialog.h" -#include "Windows/Control/ListView.h" +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/ListView.h" #include "MessagesDialogRes.h" class CMessagesDialog: public NWindows::NControl::CModalDialog { NWindows::NControl::CListView _messageList; + void AddMessageDirect(LPCWSTR message); void AddMessage(LPCWSTR message); virtual bool OnInit(); virtual bool OnSize(WPARAM wParam, int xSize, int ySize); public: const UStringVector *Messages; - INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_DIALOG_MESSAGES, parent); } + + INT_PTR Create(HWND parent = 0) { return CModalDialog::Create(IDD_MESSAGES, parent); } }; #endif diff --git a/CPP/7zip/UI/FileManager/MessagesDialog.rc b/CPP/7zip/UI/FileManager/MessagesDialog.rc old mode 100755 new mode 100644 index fb2f0f7d..49b73e84 --- a/CPP/7zip/UI/FileManager/MessagesDialog.rc +++ b/CPP/7zip/UI/FileManager/MessagesDialog.rc @@ -4,11 +4,11 @@ #define xc 440 #define yc 160 -IDD_DIALOG_MESSAGES MY_RESIZE_DIALOG +IDD_MESSAGES DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT CAPTION "7-Zip: Diagnostic messages" { DEFPUSHBUTTON "&Close", IDOK, bx, by, bxs, bys - CONTROL "List1", IDC_MESSAGE_LIST, "SysListView32", + CONTROL "List1", IDL_MESSAGE, "SysListView32", LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, m, m, xc, yc - bys - m } diff --git a/CPP/7zip/UI/FileManager/MessagesDialogRes.h b/CPP/7zip/UI/FileManager/MessagesDialogRes.h old mode 100755 new mode 100644 index 39d49f57..c8fffff6 --- a/CPP/7zip/UI/FileManager/MessagesDialogRes.h +++ b/CPP/7zip/UI/FileManager/MessagesDialogRes.h @@ -1,3 +1,3 @@ -#define IDS_MESSAGES_DIALOG_MESSAGE_COLUMN 503 -#define IDD_DIALOG_MESSAGES 503 -#define IDC_MESSAGE_LIST 1000 +#define IDD_MESSAGES 6602 +#define IDS_MESSAGE 6603 +#define IDL_MESSAGE 100 diff --git a/CPP/7zip/UI/FileManager/Move.bmp b/CPP/7zip/UI/FileManager/Move.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/Move2.bmp b/CPP/7zip/UI/FileManager/Move2.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/MyCom2.h b/CPP/7zip/UI/FileManager/MyCom2.h old mode 100755 new mode 100644 index 98b1d708..224a838d --- a/CPP/7zip/UI/FileManager/MyCom2.h +++ b/CPP/7zip/UI/FileManager/MyCom2.h @@ -3,7 +3,7 @@ #ifndef __MYCOM2_H #define __MYCOM2_H -#include "Common/MyCom.h" +#include "../../../Common/MyCom.h" #define MY_ADDREF_RELEASE_MT \ STDMETHOD_(ULONG, AddRef)() { InterlockedIncrement((LONG *)&__m_RefCount); return __m_RefCount; } \ diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp old mode 100755 new mode 100644 index b16e8948..401e48ef --- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp @@ -2,8 +2,8 @@ #include "StdAfx.h" -#include "Windows/Menu.h" -#include "Windows/Control/Dialog.h" +#include "../../../Windows/Menu.h" +#include "../../../Windows/Control/Dialog.h" #include "../../PropID.h" @@ -19,8 +19,8 @@ using namespace NWindows; -static const UINT kOpenBookmarkMenuID = 730; -static const UINT kSetBookmarkMenuID = 740; +static const UINT kOpenBookmarkMenuID = 830; +static const UINT kSetBookmarkMenuID = 810; extern HINSTANCE g_hInstance; @@ -36,102 +36,36 @@ enum kMenuIndex_Bookmarks }; -static const UInt32 kTopMenuLangIDs[] = -{ - 0x03000102, - 0x03000103, - 0x03000104, - 0x03000107, - 0x03000105, - 0x03000106 -}; +static const UInt32 kTopMenuLangIDs[] = { 500, 501, 502, 503, 504, 505 }; -static const UInt32 kAddToFavoritesLangID = 0x03000710; -static const UInt32 kToolbarsLangID = 0x03000451; +static const UInt32 kAddToFavoritesLangID = 800; +static const UInt32 kToolbarsLangID = 733; static const CIDLangPair kIDLangPairs[] = { - // File - { IDM_FILE_OPEN, 0x03000210 }, - { IDM_FILE_OPEN_INSIDE, 0x03000211 }, - { IDM_FILE_OPEN_OUTSIDE, 0x03000212 }, - { IDM_FILE_VIEW, 0x03000220 }, - { IDM_FILE_EDIT, 0x03000221 }, - { IDM_RENAME, 0x03000230 }, - { IDM_COPY_TO, 0x03000231 }, - { IDM_MOVE_TO, 0x03000232 }, - { IDM_DELETE, 0x03000233 }, - { IDM_FILE_PROPERTIES, 0x03000240 }, - { IDM_FILE_COMMENT, 0x03000241 }, - { IDM_FILE_CRC, 0x03000242 }, - { IDM_FILE_DIFF, 0x03000243 }, - { IDM_FILE_SPLIT, 0x03000270 }, - { IDM_FILE_COMBINE, 0x03000271 }, - { IDM_CREATE_FOLDER, 0x03000250 }, - { IDM_CREATE_FILE, 0x03000251 }, - { IDCLOSE, 0x03000260 }, - - // Edit - { IDM_EDIT_CUT, 0x03000320 }, - { IDM_EDIT_COPY, 0x03000321 }, - { IDM_EDIT_PASTE, 0x03000322 }, - - { IDM_SELECT_ALL, 0x03000330 }, - { IDM_DESELECT_ALL, 0x03000331 }, - { IDM_INVERT_SELECTION, 0x03000332 }, - { IDM_SELECT, 0x03000333 }, - { IDM_DESELECT, 0x03000334 }, - { IDM_SELECT_BY_TYPE, 0x03000335 }, - { IDM_DESELECT_BY_TYPE, 0x03000336 }, - - { IDM_VIEW_LARGE_ICONS, 0x03000410 }, - { IDM_VIEW_SMALL_ICONS, 0x03000411 }, - { IDM_VIEW_LIST, 0x03000412 }, - { IDM_VIEW_DETAILS, 0x03000413 }, - - { IDM_VIEW_ARANGE_BY_NAME, 0x02000204 }, - { IDM_VIEW_ARANGE_BY_TYPE, 0x02000214 }, - { IDM_VIEW_ARANGE_BY_DATE, 0x0200020C }, - { IDM_VIEW_ARANGE_BY_SIZE, 0x02000207 }, - { IDM_VIEW_ARANGE_NO_SORT, 0x03000420 }, - - { IDM_OPEN_ROOT_FOLDER, 0x03000430 }, - { IDM_OPEN_PARENT_FOLDER, 0x03000431 }, - { IDM_FOLDERS_HISTORY, 0x03000432 }, - - { IDM_VIEW_REFRESH, 0x03000440 }, - - { IDM_VIEW_FLAT_VIEW, 0x03000449 }, - { IDM_VIEW_TWO_PANELS, 0x03000450 }, - { IDM_VIEW_ARCHIVE_TOOLBAR, 0x03000460 }, - { IDM_VIEW_STANDARD_TOOLBAR, 0x03000461 }, - { IDM_VIEW_TOOLBARS_LARGE_BUTTONS, 0x03000462 }, - { IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, 0x03000463 }, - - { IDM_OPTIONS, 0x03000510 }, - { IDM_BENCHMARK, 0x03000511 }, - - { IDM_HELP_CONTENTS, 0x03000610 }, - { IDM_ABOUT, 0x03000620 } + { IDCLOSE, 557 }, + { IDM_VIEW_ARANGE_BY_NAME, 1004 }, + { IDM_VIEW_ARANGE_BY_TYPE, 1020 }, + { IDM_VIEW_ARANGE_BY_DATE, 1012 }, + { IDM_VIEW_ARANGE_BY_SIZE, 1007 } }; - -static int FindLangItem(int ControlID) +static int FindLangItem(unsigned controlID) { - for (int i = 0; i < sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]); i++) - if (kIDLangPairs[i].ControlID == ControlID) + for (unsigned i = 0; i < ARRAY_SIZE(kIDLangPairs); i++) + if (kIDLangPairs[i].ControlID == controlID) return i; return -1; } static int GetSortControlID(PROPID propID) { - switch(propID) + switch (propID) { - case kpidName: return IDM_VIEW_ARANGE_BY_NAME; - case kpidExtension: return IDM_VIEW_ARANGE_BY_TYPE; - case kpidMTime: return IDM_VIEW_ARANGE_BY_DATE; - case kpidSize: return IDM_VIEW_ARANGE_BY_SIZE; + case kpidName: return IDM_VIEW_ARANGE_BY_NAME; + case kpidExtension: return IDM_VIEW_ARANGE_BY_TYPE; + case kpidMTime: return IDM_VIEW_ARANGE_BY_DATE; + case kpidSize: return IDM_VIEW_ARANGE_BY_SIZE; case kpidNoProperty: return IDM_VIEW_ARANGE_NO_SORT; } return -1; @@ -203,27 +137,30 @@ static void MyChangeMenu(HMENU menuLoc, int level, int menuIndex) MyChangeMenu(item.hSubMenu, level + 1, i); if (level == 1 && menuIndex == kMenuIndex_View) langID = kToolbarsLangID; - else if (level == 0 && i < sizeof(kTopMenuLangIDs) / sizeof(kTopMenuLangIDs[0])) + else if (level == 0 && i < ARRAY_SIZE(kTopMenuLangIDs)) langID = kTopMenuLangIDs[i]; else continue; } - newString = LangString(langID); + LangString_OnlyFromLangFile(langID, newString); if (newString.IsEmpty()) continue; } else { - int langPos = FindLangItem(item.wID); - if (langPos < 0) + if (item.IsSeparator()) continue; - newString = LangString(kIDLangPairs[langPos].LangID); + int langPos = FindLangItem(item.wID); + + // we don't need lang change for CRC items!!! + LangString_OnlyFromLangFile(langPos >= 0 ? kIDLangPairs[langPos].LangID : item.wID, newString); if (newString.IsEmpty()) continue; + UString shorcutString = item.StringValue; int tabPos = shorcutString.ReverseFind(wchar_t('\t')); if (tabPos >= 0) - newString += shorcutString.Mid(tabPos); + newString += shorcutString.Ptr(tabPos); } { item.StringValue = newString; @@ -243,6 +180,19 @@ struct CFileMenuDestroyer } g_FileMenuDestroyer; +static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec); + +static void CopyPopMenu_IfRequired(CMenuItem &item) +{ + if (item.hSubMenu) + { + CMenu popup; + popup.CreatePopup(); + CopyMenu(item.hSubMenu, popup); + item.hSubMenu = popup; + } +} + static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec) { CMenu srcMenu; @@ -253,15 +203,15 @@ static void CopyMenu(HMENU srcMenuSpec, HMENU destMenuSpec) for (int i = 0;; i++) { CMenuItem item; - item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); + item.fMask = MIIM_SUBMENU | MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); item.fType = MFT_STRING; - if (srcMenu.GetItem(i, true, item)) - { - if (destMenu.InsertItem(startPos, true, item)) - startPos++; - } - else + + if (!srcMenu.GetItem(i, true, item)) break; + + CopyPopMenu_IfRequired(item); + if (destMenu.InsertItem(startPos, true, item)) + startPos++; } } @@ -274,7 +224,7 @@ void MyLoadMenu() HMENU oldMenu = g_App._commandBar.GetMenu(0); if (oldMenu) ::DestroyMenu(oldMenu); - BOOL b = g_App._commandBar.InsertMenubar(g_hInstance, IDM_MENU, 0); + /* BOOL b = */ g_App._commandBar.InsertMenubar(g_hInstance, IDM_MENU, 0); baseMenu = g_App._commandBar.GetMenu(0); if (!g_LangID.IsEmpty()) MyChangeMenu(baseMenu, 0, 0); @@ -344,6 +294,9 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) menu.CheckItemByID(IDM_VIEW_STANDARD_TOOLBAR, g_App.ShowStandardToolbar); menu.CheckItemByID(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, g_App.LargeButtons); menu.CheckItemByID(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, g_App.ShowButtonsLables); + menu.CheckItemByID(IDM_VIEW_AUTO_REFRESH, g_App.Get_AutoRefresh_Mode()); + // menu.CheckItemByID(IDM_VIEW_SHOW_STREAMS, g_App.Get_ShowNtfsStrems_Mode()); + // menu.CheckItemByID(IDM_VIEW_SHOW_DELETED, g_App.ShowDeletedFiles); } else if (position == kMenuIndex_Bookmarks) { @@ -356,8 +309,8 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) int i; for (i = 0; i < 10; i++) { - UString s = LangString(IDS_BOOKMARK, 0x03000720); - s += L" "; + UString s = LangString(IDS_BOOKMARK); + s += L' '; wchar_t c = (wchar_t)(L'0' + i); s += c; s += L"\tAlt+Shift+"; @@ -369,17 +322,16 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position) for (i = 0; i < 10; i++) { - UString path = g_App.AppState.FastFolders.GetString(i); + UString s = g_App.AppState.FastFolders.GetString(i); const int kMaxSize = 100; const int kFirstPartSize = kMaxSize / 2; - if (path.Length() > kMaxSize) + if (s.Len() > kMaxSize) { - path = path.Left(kFirstPartSize) + UString(L" ... ") + - path.Right(kMaxSize - kFirstPartSize); + s.Delete(kFirstPartSize, s.Len() - kMaxSize); + s.Insert(kFirstPartSize, L" ... "); } - UString s = path; if (s.IsEmpty()) - s = L"-"; + s = L'-'; s += L"\tAlt+"; s += (wchar_t)(L'0' + i); menu.AppendItem(MF_STRING, kOpenBookmarkMenuID + i, s); @@ -410,7 +362,7 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, { CMenuItem item; - item.fMask = MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); + item.fMask = MIIM_SUBMENU | MIIM_STATE | MIIM_ID | Get_fMaskForFTypeAndString(); item.fType = MFT_STRING; if (!g_FileMenu.GetItem(i, true, item)) break; @@ -418,20 +370,24 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, if (!programMenu && item.wID == IDCLOSE) continue; - if (item.wID == IDM_FILE_DIFF && diffPath.IsEmpty()) + if (item.wID == IDM_DIFF && diffPath.IsEmpty()) continue; bool isOneFsFile = (isFsFolder && numItems == 1 && allAreFiles); - bool disable = ((item.wID == IDM_FILE_SPLIT || item.wID == IDM_FILE_COMBINE) && !isOneFsFile); + bool disable = (!isOneFsFile && (item.wID == IDM_SPLIT || item.wID == IDM_COMBINE)); bool isBigScreen = NControl::IsDialogSizeOK(40, 200); if (!isBigScreen && (disable || item.IsSeparator())) continue; + + CopyPopMenu_IfRequired(item); if (destMenu.InsertItem(startPos, true, item)) + { + if (disable) + destMenu.EnableItem(startPos, MF_BYPOSITION | MF_GRAYED); startPos++; - if (disable) - destMenu.EnableItem(startPos - 1, MF_BYPOSITION | MF_GRAYED); + } if (!item.IsSeparator()) numRealItems = startPos; @@ -442,7 +398,7 @@ void LoadFileMenu(HMENU hMenu, int startPos, bool programMenu, bool ExecuteFileCommand(int id) { - if (id >= kPluginMenuStartID) + if (id >= kMenuCmdID_Plugin_Start) { g_App.GetFocusedPanel().InvokePluginCommand(id); g_App.GetFocusedPanel()._sevenZipContextMenu.Release(); @@ -453,62 +409,33 @@ bool ExecuteFileCommand(int id) switch (id) { // File - case IDM_FILE_OPEN: - g_App.OpenItem(); - break; - case IDM_FILE_OPEN_INSIDE: - g_App.OpenItemInside(); - break; - case IDM_FILE_OPEN_OUTSIDE: - g_App.OpenItemOutside(); - break; - case IDM_FILE_VIEW: - break; - case IDM_FILE_EDIT: - g_App.EditItem(); - break; - case IDM_RENAME: - g_App.Rename(); - break; - case IDM_COPY_TO: - g_App.CopyTo(); - break; - case IDM_MOVE_TO: - g_App.MoveTo(); - break; - case IDM_DELETE: - { - bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; - g_App.Delete(!shift); - break; - } - case IDM_FILE_CRC: - g_App.CalculateCrc(); - break; - case IDM_FILE_DIFF: - g_App.DiffFiles(); - break; - case IDM_FILE_SPLIT: - g_App.Split(); - break; - case IDM_FILE_COMBINE: - g_App.Combine(); - break; - case IDM_FILE_PROPERTIES: - g_App.Properties(); - break; - case IDM_FILE_COMMENT: - g_App.Comment(); - break; - - case IDM_CREATE_FOLDER: - g_App.CreateFolder(); - break; - case IDM_CREATE_FILE: - g_App.CreateFile(); - break; - default: - return false; + case IDM_OPEN: g_App.OpenItem(); break; + case IDM_OPEN_INSIDE: g_App.OpenItemInside(); break; + case IDM_OPEN_OUTSIDE: g_App.OpenItemOutside(); break; + case IDM_FILE_VIEW: g_App.EditItem(false); break; + case IDM_FILE_EDIT: g_App.EditItem(true); break; + case IDM_RENAME: g_App.Rename(); break; + case IDM_COPY_TO: g_App.CopyTo(); break; + case IDM_MOVE_TO: g_App.MoveTo(); break; + case IDM_DELETE: g_App.Delete(!IsKeyDown(VK_SHIFT)); break; + + case IDM_HASH_ALL: g_App.CalculateCrc(L"*"); break; + case IDM_CRC32: g_App.CalculateCrc(L"CRC32"); break; + case IDM_CRC64: g_App.CalculateCrc(L"CRC64"); break; + case IDM_SHA1: g_App.CalculateCrc(L"SHA1"); break; + case IDM_SHA256: g_App.CalculateCrc(L"SHA256"); break; + + case IDM_DIFF: g_App.DiffFiles(); break; + case IDM_SPLIT: g_App.Split(); break; + case IDM_COMBINE: g_App.Combine(); break; + case IDM_PROPERTIES: g_App.Properties(); break; + case IDM_COMMENT: g_App.Comment(); break; + case IDM_CREATE_FOLDER: g_App.CreateFolder(); break; + case IDM_CREATE_FILE: g_App.CreateFile(); break; + #ifndef UNDER_CE + case IDM_LINK: g_App.Link(); break; + #endif + default: return false; } return true; } @@ -534,6 +461,7 @@ bool OnMenuCommand(HWND hWnd, int id) break; // Edit + /* case IDM_EDIT_CUT: g_App.EditCut(); break; @@ -543,6 +471,7 @@ bool OnMenuCommand(HWND hWnd, int id) case IDM_EDIT_PASTE: g_App.EditPaste(); break; + */ case IDM_SELECT_ALL: g_App.SelectAll(true); g_App.Refresh_StatusBar(); @@ -591,67 +520,38 @@ bool OnMenuCommand(HWND hWnd, int id) } break; } - case IDM_VIEW_ARANGE_BY_NAME: - { - g_App.SortItemsWithPropID(kpidName); - break; - } - case IDM_VIEW_ARANGE_BY_TYPE: - { - g_App.SortItemsWithPropID(kpidExtension); - break; - } - case IDM_VIEW_ARANGE_BY_DATE: - { - g_App.SortItemsWithPropID(kpidMTime); - break; - } - case IDM_VIEW_ARANGE_BY_SIZE: - { - g_App.SortItemsWithPropID(kpidSize); - break; - } - case IDM_VIEW_ARANGE_NO_SORT: + case IDM_VIEW_ARANGE_BY_NAME: g_App.SortItemsWithPropID(kpidName); break; + case IDM_VIEW_ARANGE_BY_TYPE: g_App.SortItemsWithPropID(kpidExtension); break; + case IDM_VIEW_ARANGE_BY_DATE: g_App.SortItemsWithPropID(kpidMTime); break; + case IDM_VIEW_ARANGE_BY_SIZE: g_App.SortItemsWithPropID(kpidSize); break; + case IDM_VIEW_ARANGE_NO_SORT: g_App.SortItemsWithPropID(kpidNoProperty); break; + + case IDM_OPEN_ROOT_FOLDER: g_App.OpenRootFolder(); break; + case IDM_OPEN_PARENT_FOLDER: g_App.OpenParentFolder(); break; + case IDM_FOLDERS_HISTORY: g_App.FoldersHistory(); break; + case IDM_VIEW_FLAT_VIEW: g_App.ChangeFlatMode(); break; + case IDM_VIEW_REFRESH: g_App.RefreshView(); break; + case IDM_VIEW_AUTO_REFRESH: g_App.Change_AutoRefresh_Mode(); break; + + // case IDM_VIEW_SHOW_STREAMS: g_App.Change_ShowNtfsStrems_Mode(); break; + /* + case IDM_VIEW_SHOW_DELETED: { - g_App.SortItemsWithPropID(kpidNoProperty); - break; + g_App.Change_ShowDeleted(); + bool isChecked = g_App.ShowDeletedFiles; + Save_ShowDeleted(isChecked); } + */ + + case IDM_VIEW_TWO_PANELS: g_App.SwitchOnOffOnePanel(); break; + case IDM_VIEW_STANDARD_TOOLBAR: g_App.SwitchStandardToolbar(); break; + case IDM_VIEW_ARCHIVE_TOOLBAR: g_App.SwitchArchiveToolbar(); break; - case IDM_OPEN_ROOT_FOLDER: - g_App.OpenRootFolder(); - break; - case IDM_OPEN_PARENT_FOLDER: - g_App.OpenParentFolder(); - break; - case IDM_FOLDERS_HISTORY: - g_App.FoldersHistory(); - break; - case IDM_VIEW_REFRESH: - g_App.RefreshView(); - break; - case IDM_VIEW_FLAT_VIEW: - g_App.ChangeFlatMode(); - break; - case IDM_VIEW_TWO_PANELS: - g_App.SwitchOnOffOnePanel(); - break; - case IDM_VIEW_STANDARD_TOOLBAR: - g_App.SwitchStandardToolbar(); - break; - case IDM_VIEW_ARCHIVE_TOOLBAR: - g_App.SwitchArchiveToolbar(); - break; - case IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT: - g_App.SwitchButtonsLables(); - break; - case IDM_VIEW_TOOLBARS_LARGE_BUTTONS: - g_App.SwitchLargeButtons(); - break; + case IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT: g_App.SwitchButtonsLables(); break; + case IDM_VIEW_TOOLBARS_LARGE_BUTTONS: g_App.SwitchLargeButtons(); break; // Tools - case IDM_OPTIONS: - OptionsDialog(hWnd, g_hInstance); - break; + case IDM_OPTIONS: OptionsDialog(hWnd, g_hInstance); break; case IDM_BENCHMARK: MyBenchmark(false); break; case IDM_BENCHMARK2: MyBenchmark(true); break; diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.h b/CPP/7zip/UI/FileManager/MyLoadMenu.h old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/MyWindowsNew.h b/CPP/7zip/UI/FileManager/MyWindowsNew.h old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/NetFolder.cpp b/CPP/7zip/UI/FileManager/NetFolder.cpp old mode 100755 new mode 100644 index 07387328..f3d531ab --- a/CPP/7zip/UI/FileManager/NetFolder.cpp +++ b/CPP/7zip/UI/FileManager/NetFolder.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#include "Windows/PropVariant.h" +#include "../../../Windows/PropVariant.h" #include "../../PropID.h" @@ -13,23 +13,23 @@ using namespace NWindows; using namespace NNet; -static const STATPROPSTG kProps[] = +static const PROPID kProps[] = { - { NULL, kpidName, VT_BSTR}, - { NULL, kpidLocalName, VT_BSTR}, - { NULL, kpidComment, VT_BSTR}, - { NULL, kpidProvider, VT_BSTR} + kpidName, + kpidLocalName, + kpidComment, + kpidProvider }; void CNetFolder::Init(const UString &path) { /* - if (path.Length() > 2) + if (path.Len() > 2) { if (path[0] == L'\\' && path[1] == L'\\') { CResource netResource; - netResource.RemoteName = GetSystemString(path.Left(path.Length() - 1)); + netResource.RemoteName = GetSystemString(path.Left(path.Len() - 1)); netResource.Scope = RESOURCE_GLOBALNET; netResource.Type = RESOURCETYPE_DISK; netResource.DisplayType = RESOURCEDISPLAYTYPE_SERVER; @@ -42,7 +42,8 @@ void CNetFolder::Init(const UString &path) */ CResourceW resource; resource.RemoteNameIsDefined = true; - resource.RemoteName = path.Left(path.Length() - 1); + if (!path.IsEmpty()) + resource.RemoteName.SetFrom(path, path.Len() - 1); resource.ProviderIsDefined = false; resource.LocalNameIsDefined = false; resource.CommentIsDefined = false; @@ -114,7 +115,7 @@ STDMETHODIMP CNetFolder::LoadItems() if (pos >= 0) { // _path = resource.Name.Left(pos + 1); - resource.Name = resource.Name.Mid(pos + 1); + resource.Name.DeleteFrontal(pos + 1); } _items.Add(resource); } diff --git a/CPP/7zip/UI/FileManager/NetFolder.h b/CPP/7zip/UI/FileManager/NetFolder.h old mode 100755 new mode 100644 index 9962845c..151dd096 --- a/CPP/7zip/UI/FileManager/NetFolder.h +++ b/CPP/7zip/UI/FileManager/NetFolder.h @@ -3,9 +3,9 @@ #ifndef __NET_FOLDER_H #define __NET_FOLDER_H -#include "Common/MyCom.h" +#include "../../../Common/MyCom.h" -#include "Windows/Net.h" +#include "../../../Windows/Net.h" #include "IFolder.h" diff --git a/CPP/7zip/UI/FileManager/OpenCallback.cpp b/CPP/7zip/UI/FileManager/OpenCallback.cpp old mode 100755 new mode 100644 index 95daf37a..d5afb2da --- a/CPP/7zip/UI/FileManager/OpenCallback.cpp +++ b/CPP/7zip/UI/FileManager/OpenCallback.cpp @@ -2,9 +2,11 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" +#include "../../../Common/ComTry.h" +#include "../../../Common/StringConvert.h" -#include "Windows/PropVariant.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/PropVariant.h" #include "../../Common/FileStreams.h" @@ -17,44 +19,40 @@ using namespace NWindows; STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 *numFiles, const UInt64 *numBytes) { - RINOK(ProgressDialog.Sync.ProcessStopAndPause()); + RINOK(ProgressDialog.Sync.CheckStop()); { - NSynchronization::CCriticalSectionLock lock(_criticalSection); - if (numFiles != NULL) + // NSynchronization::CCriticalSectionLock lock(_criticalSection); + if (numFiles) { - ProgressDialog.Sync.SetNumFilesTotal(*numFiles); - ProgressDialog.Sync.SetBytesProgressMode(false); + ProgressDialog.Sync.Set_NumFilesTotal(*numFiles); + ProgressDialog.Sync.Set_BytesProgressMode(false); } - if (numBytes != NULL) - ProgressDialog.Sync.SetNumBytesTotal(*numBytes); + if (numBytes) + ProgressDialog.Sync.Set_NumBytesTotal(*numBytes); } return S_OK; } STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *numFiles, const UInt64 *numBytes) { - RINOK(ProgressDialog.Sync.ProcessStopAndPause()); - NSynchronization::CCriticalSectionLock lock(_criticalSection); - if (numFiles != NULL) - ProgressDialog.Sync.SetNumFilesCur(*numFiles); - if (numBytes != NULL) - ProgressDialog.Sync.SetPos(*numBytes); - return S_OK; + // NSynchronization::CCriticalSectionLock lock(_criticalSection); + if (numFiles) + ProgressDialog.Sync.Set_NumFilesCur(*numFiles); + if (numBytes) + ProgressDialog.Sync.Set_NumBytesCur(*numBytes); + return ProgressDialog.Sync.CheckStop(); } STDMETHODIMP COpenArchiveCallback::SetTotal(const UInt64 total) { - RINOK(ProgressDialog.Sync.ProcessStopAndPause()); - ProgressDialog.Sync.SetNumBytesTotal(total); + RINOK(ProgressDialog.Sync.CheckStop()); + ProgressDialog.Sync.Set_NumBytesTotal(total); return S_OK; } STDMETHODIMP COpenArchiveCallback::SetCompleted(const UInt64 *completed) { - RINOK(ProgressDialog.Sync.ProcessStopAndPause()); - if (completed != NULL) - ProgressDialog.Sync.SetPos(*completed); - return S_OK; + return ProgressDialog.Sync.Set_NumBytesCur(completed); } STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value) @@ -86,16 +84,16 @@ STDMETHODIMP COpenArchiveCallback::GetProperty(PROPID propID, PROPVARIANT *value STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **inStream) { + COM_TRY_BEGIN *inStream = NULL; if (_subArchiveMode) return S_FALSE; - NFile::NFind::CFileInfo fileInfo; - - FString fullPath = _folderPrefix + us2fs(name); - if (!fileInfo.Find(fullPath)) + FString fullPath; + if (!NFile::NName::GetFullPath(_folderPrefix, us2fs(name), fullPath)) + return S_FALSE; + if (!_fileInfo.Find(fullPath)) return S_FALSE; - _fileInfo = fileInfo; if (_fileInfo.IsDir()) return S_FALSE; CInFileStream *inFile = new CInFileStream; @@ -104,10 +102,12 @@ STDMETHODIMP COpenArchiveCallback::GetStream(const wchar_t *name, IInStream **in return ::GetLastError(); *inStream = inStreamTemp.Detach(); return S_OK; + COM_TRY_END } STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) { + COM_TRY_BEGIN PasswordWasAsked = true; if (!PasswordIsDefined) { @@ -116,7 +116,7 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) dialog.ShowPassword = showPassword; ProgressDialog.WaitCreating(); - if (dialog.Create(ProgressDialog) == IDCANCEL) + if (dialog.Create(ProgressDialog) != IDOK) return E_ABORT; Password = dialog.Password; @@ -125,4 +125,5 @@ STDMETHODIMP COpenArchiveCallback::CryptoGetTextPassword(BSTR *password) NExtract::Save_ShowPassword(dialog.ShowPassword); } return StringToBstr(Password, password); + COM_TRY_END } diff --git a/CPP/7zip/UI/FileManager/OpenCallback.h b/CPP/7zip/UI/FileManager/OpenCallback.h old mode 100755 new mode 100644 index a0c0167e..c952d7b0 --- a/CPP/7zip/UI/FileManager/OpenCallback.h +++ b/CPP/7zip/UI/FileManager/OpenCallback.h @@ -1,12 +1,11 @@ // OpenCallback.h -#ifndef __OPENCALLBACK_H -#define __OPENCALLBACK_H +#ifndef __OPEN_CALLBACK_H +#define __OPEN_CALLBACK_H -#include "Common/MyCom.h" -#include "Common/MyString.h" +#include "../../../Common/MyCom.h" -#include "Windows/FileFind.h" +#include "../../../Windows/FileFind.h" #include "../../IPassword.h" @@ -29,7 +28,7 @@ class COpenArchiveCallback: { FString _folderPrefix; NWindows::NFile::NFind::CFileInfo _fileInfo; - NWindows::NSynchronization::CCriticalSection _criticalSection; + // NWindows::NSynchronization::CCriticalSection _criticalSection; bool _subArchiveMode; UString _subArchiveName; @@ -58,7 +57,7 @@ public: { _subArchiveMode = true; _subArchiveName = name; - return S_OK; + return S_OK; } COpenArchiveCallback(): diff --git a/CPP/7zip/UI/FileManager/OptionsDialog.cpp b/CPP/7zip/UI/FileManager/OptionsDialog.cpp old mode 100755 new mode 100644 index a1ef1b1d..fa2ab922 --- a/CPP/7zip/UI/FileManager/OptionsDialog.cpp +++ b/CPP/7zip/UI/FileManager/OptionsDialog.cpp @@ -2,8 +2,8 @@ #include "StdAfx.h" -#include "Windows/Control/Dialog.h" -#include "Windows/Control/PropertyPage.h" +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/PropertyPage.h" #include "DialogSize.h" #include "EditPage.h" @@ -92,41 +92,36 @@ void OptionsDialog(HWND hwndOwner, HINSTANCE /* hInstance */) CFoldersPage foldersPage; CObjectVector pages; - const UInt32 langIDs[] = { 0x03010300, - // 0x03010100, - 0xFFFFFFFF, - 0x01000200, 0x03010200, 0x03010400, 0x01000400}; - BIG_DIALOG_SIZE(200, 200); UINT pageIDs[] = { SIZED_DIALOG(IDD_SYSTEM), - // IDD_PLUGINS, SIZED_DIALOG(IDD_MENU), SIZED_DIALOG(IDD_FOLDERS), SIZED_DIALOG(IDD_EDIT), SIZED_DIALOG(IDD_SETTINGS), SIZED_DIALOG(IDD_LANG) }; NControl::CPropertyPage *pagePinters[] = { &systemPage, &menuPage, &foldersPage, &editPage, &settingsPage, &langPage }; - const int kNumPages = sizeof(langIDs) / sizeof(langIDs[0]); + const int kNumPages = ARRAY_SIZE(pageIDs); for (int i = 0; i < kNumPages; i++) { NControl::CPageInfo page; - page.Title = LangString(langIDs[i]); page.ID = pageIDs[i]; + LangString_OnlyFromLangFile(page.ID, page.Title); page.Page = pagePinters[i]; pages.Add(page); } - INT_PTR res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS, 0x03010000)); + INT_PTR res = NControl::MyPropertySheet(pages, hwndOwner, LangString(IDS_OPTIONS)); if (res != -1 && res != 0) { if (langPage.LangWasChanged) { - g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000)); + // g_App._window.SetText(LangString(IDS_APP_TITLE, 0x03000000)); MyLoadMenu(); g_App.ReloadToolbars(); g_App.MoveSubWindows(); + g_App.ReloadLang(); } /* if (systemPage.WasChanged) diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp old mode 100755 new mode 100644 index 5f072daf..a657bc90 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp @@ -2,48 +2,44 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" +#include "../../../Common/StringConvert.h" -#include "Windows/FileName.h" -#include "Windows/Defs.h" -#include "Windows/ResourceString.h" -#include "Windows/Control/Static.h" -#include "Windows/PropVariantConversions.h" +#include "../../../Windows/PropVariantConv.h" +#include "../../../Windows/ResourceString.h" + +#include "../../../Windows/Control/Static.h" #include "FormatUtils.h" +#include "LangUtils.h" #include "OverwriteDialog.h" -// #include "../resource.h" - -#ifdef LANG -#include "LangUtils.h" -#endif +#include "PropertyNameRes.h" using namespace NWindows; #ifdef LANG -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_STATIC_OVERWRITE_HEADER, 0x02000901}, - { IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 }, - { IDC_STATIC_OVERWRITE_QUESTION_END, 0x02000903 }, - { IDYES, 0x02000705 }, - { IDC_BUTTON_OVERWRITE_YES_TO_ALL, 0x02000707 }, - { IDNO, 0x02000709 }, - { IDC_BUTTON_OVERWRITE_NO_TO_ALL,0x0200070B }, - { IDC_BUTTON_OVERWRITE_AUTO_RENAME, 0x02000911 }, - { IDCANCEL, 0x02000711 } + IDT_OVERWRITE_HEADER, + IDT_OVERWRITE_QUESTION_BEGIN, + IDT_OVERWRITE_QUESTION_END, + IDB_YES_TO_ALL, + IDB_NO_TO_ALL, + IDB_AUTO_RENAME }; #endif -static const int kCurrentFileNameSizeLimit = 82; -static const int kCurrentFileNameSizeLimit2 = 30; +static const unsigned kCurrentFileNameSizeLimit = 82; +static const unsigned kCurrentFileNameSizeLimit2 = 30; void COverwriteDialog::ReduceString(UString &s) { - int size = _isBig ? kCurrentFileNameSizeLimit : kCurrentFileNameSizeLimit2; - if (s.Length() > size) - s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2); + unsigned size = _isBig ? kCurrentFileNameSizeLimit : kCurrentFileNameSizeLimit2; + if (s.Len() > size) + { + s.Delete(size / 2, s.Len() - size); + s.Insert(size / 2, L" ... "); + } } void COverwriteDialog::SetFileInfoControl(int textID, int iconID, @@ -51,52 +47,38 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID, { UString sizeString; if (fileInfo.SizeIsDefined) - sizeString = MyFormatNew(IDS_FILE_SIZE, - #ifdef LANG - 0x02000982, - #endif - NumberToString(fileInfo.Size)); + sizeString = MyFormatNew(IDS_FILE_SIZE, NumberToString(fileInfo.Size)); const UString &fileName = fileInfo.Name; int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); - UString s1, s2; - if (slashPos >= 0) - { - s1 = fileName.Left(slashPos + 1); - s2 = fileName.Mid(slashPos + 1); - } - else - s2 = fileName; + UString s1 = fileName.Left(slashPos + 1); + UString s2 = fileName.Ptr(slashPos + 1); + ReduceString(s1); ReduceString(s2); - UString fullString = s1 + L'\n' + s2; - fullString += L'\n'; - fullString += sizeString; - fullString += L'\n'; + UString s = s1; + s += L'\n'; + s += s2; + s += L'\n'; + s += sizeString; + s += L'\n'; if (fileInfo.TimeIsDefined) { - UString timeString; FILETIME localFileTime; if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime)) throw 4190402; - timeString = ConvertFileTimeToString(localFileTime); - - fullString += - #ifdef LANG - LangString(IDS_FILE_MODIFIED, 0x02000983); - #else - MyLoadStringW(IDS_FILE_MODIFIED); - #endif - - fullString += L" "; - fullString += timeString; + s += LangString(IDS_PROP_MTIME); + s += L": "; + wchar_t t[32]; + ConvertFileTimeToString(localFileTime, t); + s += t; } - NWindows::NControl::CDialogChildControl control; + NControl::CDialogChildControl control; control.Init(*this, textID); - control.SetText(fullString); + control.SetText(s); SHFILEINFO shellFileInfo; if (::SHGetFileInfo( @@ -112,24 +94,24 @@ void COverwriteDialog::SetFileInfoControl(int textID, int iconID, bool COverwriteDialog::OnInit() { #ifdef LANG - LangSetWindowText(HWND(*this), 0x02000900); - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetWindowText(*this, IDD_OVERWRITE); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); #endif - SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); - SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); + SetFileInfoControl(IDT_OVERWRITE_OLD_FILE_SIZE_TIME, IDI_OVERWRITE_OLD_FILE, OldFileInfo); + SetFileInfoControl(IDT_OVERWRITE_NEW_FILE_SIZE_TIME, IDI_OVERWRITE_NEW_FILE, NewFileInfo); NormalizePosition(); return CModalDialog::OnInit(); } bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { - switch(buttonID) + switch (buttonID) { case IDYES: - case IDC_BUTTON_OVERWRITE_YES_TO_ALL: case IDNO: - case IDC_BUTTON_OVERWRITE_NO_TO_ALL: - case IDC_BUTTON_OVERWRITE_AUTO_RENAME: + case IDB_YES_TO_ALL: + case IDB_NO_TO_ALL: + case IDB_AUTO_RENAME: End(buttonID); return true; } diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.h b/CPP/7zip/UI/FileManager/OverwriteDialog.h old mode 100755 new mode 100644 index f760611e..da7fa55f --- a/CPP/7zip/UI/FileManager/OverwriteDialog.h +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.h @@ -3,9 +3,7 @@ #ifndef __OVERWRITE_DIALOG_H #define __OVERWRITE_DIALOG_H -#include "Common/Types.h" - -#include "Windows/Control/Dialog.h" +#include "../../../Windows/Control/Dialog.h" #include "DialogSize.h" #include "OverwriteDialogRes.h" @@ -61,7 +59,7 @@ public: #else _isBig = true; #endif - return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_OVERWRITE), parent); + return CModalDialog::Create(SIZED_DIALOG(IDD_OVERWRITE), parent); } NOverwriteDialog::CFileInfo OldFileInfo; diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.rc b/CPP/7zip/UI/FileManager/OverwriteDialog.rc old mode 100755 new mode 100644 index 8961d28b..29f99122 --- a/CPP/7zip/UI/FileManager/OverwriteDialog.rc +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.rc @@ -18,26 +18,26 @@ #undef bx1 #define bx1 (xs - m - bSizeBig) -IDD_DIALOG_OVERWRITE MY_DIALOG +IDD_OVERWRITE DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT CAPTION "Confirm File Replace" BEGIN - LTEXT "Destination folder already contains processed file.", IDC_STATIC_OVERWRITE_HEADER, m, 7, xc, 8 - LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, m, 28, xc, 8 + LTEXT "Destination folder already contains processed file.", IDT_OVERWRITE_HEADER, m, 7, xc, 8 + LTEXT "Would you like to replace the existing file", IDT_OVERWRITE_QUESTION_BEGIN, m, 28, xc, 8 - ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, m, 44, iconSize, iconSize - LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, x, 44, fx, fy, SS_NOPREFIX + ICON "", IDI_OVERWRITE_OLD_FILE, m, 44, iconSize, iconSize + LTEXT "", IDT_OVERWRITE_OLD_FILE_SIZE_TIME, x, 44, fx, fy, SS_NOPREFIX - LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, m, 98, xc, 8 + LTEXT "with this one?", IDT_OVERWRITE_QUESTION_END, m, 98, xc, 8 - ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, m, 114, iconSize, iconSize - LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, x, 114, fx, fy, SS_NOPREFIX + ICON "", IDI_OVERWRITE_NEW_FILE, m, 114, iconSize, iconSize + LTEXT "", IDT_OVERWRITE_NEW_FILE_SIZE_TIME, x, 114, fx, fy, SS_NOPREFIX - PUSHBUTTON "&Yes", IDYES, bx3, by2, bxs, bys - PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, bx2, by2, bxs, bys - PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, bx1, by2, bSizeBig, bys - PUSHBUTTON "&No", IDNO, bx3, by1, bxs, bys - PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, bx2, by1, bxs, bys - PUSHBUTTON "&Cancel", IDCANCEL, xs - m - bxs, by1, bxs, bys + PUSHBUTTON "&Yes", IDYES, bx3, by2, bxs, bys + PUSHBUTTON "Yes to &All", IDB_YES_TO_ALL, bx2, by2, bxs, bys + PUSHBUTTON "A&uto Rename", IDB_AUTO_RENAME, bx1, by2, bSizeBig, bys + PUSHBUTTON "&No", IDNO, bx3, by1, bxs, bys + PUSHBUTTON "No to A&ll", IDB_NO_TO_ALL, bx2, by1, bxs, bys + PUSHBUTTON "&Cancel", IDCANCEL, xs - m - bxs, by1, bxs, bys END @@ -61,25 +61,25 @@ END #define bx1 (xs - m - bxs) -IDD_DIALOG_OVERWRITE_2 MY_DIALOG +IDD_OVERWRITE_2 DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT CAPTION "Confirm File Replace" BEGIN - LTEXT "Would you like to replace the existing file", IDC_STATIC_OVERWRITE_QUESTION_BEGIN, m, m, xc, 8 + LTEXT "Would you like to replace the existing file", IDT_OVERWRITE_QUESTION_BEGIN, m, m, xc, 8 - ICON "", IDC_STATIC_OVERWRITE_OLD_FILE_ICON, m, 20, iconSize, iconSize - LTEXT "", IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, x, 20, fx, fy, SS_NOPREFIX + ICON "", IDI_OVERWRITE_OLD_FILE, m, 20, iconSize, iconSize + LTEXT "", IDT_OVERWRITE_OLD_FILE_SIZE_TIME, x, 20, fx, fy, SS_NOPREFIX - LTEXT "with this one?",IDC_STATIC_OVERWRITE_QUESTION_END, m, 60, xc, 8 + LTEXT "with this one?", IDT_OVERWRITE_QUESTION_END, m, 60, xc, 8 - ICON "",IDC_STATIC_OVERWRITE_NEW_FILE_ICON, m, 72, iconSize, iconSize - LTEXT "",IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, x, 72, fx, fy, SS_NOPREFIX + ICON "", IDI_OVERWRITE_NEW_FILE, m, 72, iconSize, iconSize + LTEXT "", IDT_OVERWRITE_NEW_FILE_SIZE_TIME, x, 72, fx, fy, SS_NOPREFIX - PUSHBUTTON "&Yes", IDYES, bx3, by2, bxs, bys - PUSHBUTTON "Yes to &All", IDC_BUTTON_OVERWRITE_YES_TO_ALL, bx2, by2, bxs, bys - PUSHBUTTON "A&uto Rename", IDC_BUTTON_OVERWRITE_AUTO_RENAME, bx1, by2, bxs, bys - PUSHBUTTON "&No", IDNO, bx3, by1, bxs, bys - PUSHBUTTON "No to A&ll", IDC_BUTTON_OVERWRITE_NO_TO_ALL, bx2, by1, bxs, bys - PUSHBUTTON "&Cancel", IDCANCEL, bx1, by1, bxs, bys + PUSHBUTTON "&Yes", IDYES, bx3, by2, bxs, bys + PUSHBUTTON "Yes to &All", IDB_YES_TO_ALL, bx2, by2, bxs, bys + PUSHBUTTON "A&uto Rename", IDB_AUTO_RENAME, bx1, by2, bxs, bys + PUSHBUTTON "&No", IDNO, bx3, by1, bxs, bys + PUSHBUTTON "No to A&ll", IDB_NO_TO_ALL, bx2, by1, bxs, bys + PUSHBUTTON "&Cancel", IDCANCEL, bx1, by1, bxs, bys END #endif @@ -87,6 +87,5 @@ END STRINGTABLE BEGIN - IDS_FILE_MODIFIED "modified on" - IDS_FILE_SIZE "{0} bytes" + IDS_FILE_SIZE "{0} bytes" END diff --git a/CPP/7zip/UI/FileManager/OverwriteDialogRes.h b/CPP/7zip/UI/FileManager/OverwriteDialogRes.h old mode 100755 new mode 100644 index 3bc6900d..b480ba16 --- a/CPP/7zip/UI/FileManager/OverwriteDialogRes.h +++ b/CPP/7zip/UI/FileManager/OverwriteDialogRes.h @@ -1,20 +1,17 @@ -#define IDD_DIALOG_OVERWRITE 502 -#define IDD_DIALOG_OVERWRITE_2 602 +#define IDD_OVERWRITE 3500 +#define IDD_OVERWRITE_2 13500 -#define IDS_FILE_MODIFIED 600 -#define IDS_FILE_SIZE 601 +#define IDT_OVERWRITE_HEADER 3501 +#define IDT_OVERWRITE_QUESTION_BEGIN 3502 +#define IDT_OVERWRITE_QUESTION_END 3503 +#define IDS_FILE_SIZE 3504 -#define IDC_STATIC_OVERWRITE_HEADER 1000 +#define IDB_AUTO_RENAME 3505 +#define IDB_YES_TO_ALL 440 +#define IDB_NO_TO_ALL 441 -#define IDC_STATIC_OVERWRITE_QUESTION_BEGIN 1001 -#define IDC_STATIC_OVERWRITE_QUESTION_END 1002 +#define IDI_OVERWRITE_OLD_FILE 100 +#define IDI_OVERWRITE_NEW_FILE 101 -#define IDC_STATIC_OVERWRITE_OLD_FILE_ICON 1003 -#define IDC_STATIC_OVERWRITE_NEW_FILE_ICON 1004 - -#define IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME 1005 -#define IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME 1006 - -#define IDC_BUTTON_OVERWRITE_YES_TO_ALL 1010 -#define IDC_BUTTON_OVERWRITE_NO_TO_ALL 1011 -#define IDC_BUTTON_OVERWRITE_AUTO_RENAME 1012 +#define IDT_OVERWRITE_OLD_FILE_SIZE_TIME 102 +#define IDT_OVERWRITE_NEW_FILE_SIZE_TIME 103 diff --git a/CPP/7zip/UI/FileManager/Panel.cpp b/CPP/7zip/UI/FileManager/Panel.cpp old mode 100755 new mode 100644 index ebbe12b9..d63bdc17 --- a/CPP/7zip/UI/FileManager/Panel.cpp +++ b/CPP/7zip/UI/FileManager/Panel.cpp @@ -4,13 +4,13 @@ #include -#include "Common/Defs.h" -#include "Common/IntToString.h" -#include "Common/StringConvert.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/StringConvert.h" -#include "Windows/Error.h" -#include "Windows/PropVariant.h" -#include "Windows/Thread.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/ErrorMsg.h" +#include "../../../Windows/PropVariant.h" +#include "../../../Windows/Thread.h" #include "../../PropID.h" @@ -29,6 +29,7 @@ #include "Panel.h" #include "RootFolder.h" +#include "PropertyNameRes.h" using namespace NWindows; using namespace NControl; @@ -43,7 +44,6 @@ static const UINT kTimerElapse = 1000; static DWORD kStyles[4] = { LVS_ICON, LVS_SMALLICON, LVS_LIST, LVS_REPORT }; // static const int kCreateFolderID = 101; -// static const UINT kFileChangeNotifyMessage = WM_APP; extern HINSTANCE g_hInstance; extern DWORD g_ComCtl32Version; @@ -94,9 +94,10 @@ HRESULT CPanel::Create(HWND mainWindow, HWND parentWindow, UINT id, if (currentFolderPrefix[0] == L'.') { FString cfpF; - if (NFile::NDirectory::MyGetFullPathName(us2fs(currentFolderPrefix), cfpF)) + if (NFile::NDir::MyGetFullPathName(us2fs(currentFolderPrefix), cfpF)) cfp = fs2us(cfpF); } + RINOK(BindToPath(cfp, arcFormat, archiveIsOpened, encrypted)); if (!CreateEx(0, kClassName, 0, WS_CHILD | WS_VISIBLE, @@ -180,11 +181,9 @@ LRESULT CMyListView::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) */ else if (message == WM_KEYDOWN) { - bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0; - // bool RightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0; - bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; + bool alt = IsKeyDown(VK_MENU); + bool ctrl = IsKeyDown(VK_CONTROL); + bool shift = IsKeyDown(VK_SHIFT); switch (wParam) { /* @@ -249,6 +248,9 @@ LRESULT CMyComboBox::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) return CallWindowProc(_origWindowProc, *this, message, wParam, lParam); } */ + +#ifndef UNDER_CE + static LRESULT APIENTRY ComboBoxEditSubclassProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { CWindow tempDialog(hwnd); @@ -258,6 +260,8 @@ static LRESULT APIENTRY ComboBoxEditSubclassProc(HWND hwnd, UINT message, WPARAM return w->OnMessage(message, wParam, lParam); } +#endif + LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { // See MSDN / Subclassing a Combo Box / Creating a Combo-box Toolbar @@ -272,9 +276,9 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) // check ALT if ((lParam & (1<<29)) == 0) break; - bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; + bool alt = IsKeyDown(VK_MENU); + bool ctrl = IsKeyDown(VK_CONTROL); + bool shift = IsKeyDown(VK_SHIFT); if (alt && !ctrl && !shift) { _panel->_panelCallback->SetFocusToPath(wParam == VK_F1 ? 0 : 1); @@ -293,9 +297,9 @@ LRESULT CMyComboBoxEdit::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) return 0; case VK_F9: { - bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; + bool alt = IsKeyDown(VK_MENU); + bool ctrl = IsKeyDown(VK_CONTROL); + bool shift = IsKeyDown(VK_SHIFT); if (!alt && !ctrl && !shift) { g_App.SwitchOnOffOnePanel();; @@ -336,7 +340,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) style |= WS_CLIPCHILDREN; style |= WS_CLIPSIBLINGS; - const UInt32 kNumListModes = sizeof(kStyles) / sizeof(kStyles[0]); + const UInt32 kNumListModes = ARRAY_SIZE(kStyles); if (_ListViewMode >= kNumListModes) _ListViewMode = kNumListModes - 1; @@ -355,7 +359,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) exStyle = WS_EX_CLIENTEDGE; if (!_listView.CreateEx(exStyle, style, 0, 0, 116, 260, - HWND(*this), (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL)) + *this, (HMENU)(UINT_PTR)(_baseID + 1), g_hInstance, NULL)) return false; _listView.SetUnicodeFormat(); @@ -398,16 +402,18 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) icex.dwICC = ICC_COOL_CLASSES | ICC_BAR_CLASSES; InitCommonControlsEx(&icex); + // if there is no CCS_NOPARENTALIGN, there is space of some pixels after rebar (Incorrect GetWindowRect ?) + _headerReBar.Attach(::CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | CCS_NODIVIDER - // | CCS_NOPARENTALIGN + | CCS_NOPARENTALIGN | CCS_TOP | RBS_VARHEIGHT | RBS_BANDBORDERS - ,0,0,0,0, HWND(*this), NULL, g_hInstance, NULL)); + ,0,0,0,0, *this, NULL, g_hInstance, NULL)); } DWORD toolbarStyle = WS_CHILD | WS_VISIBLE ; @@ -428,7 +434,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _baseID + 2, 11, (HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR, - (LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]), + (LPCTBBUTTON)&tbb, ARRAY_SIZE(tbb), 0, 0, 0, 0, sizeof (TBBUTTON))); #ifndef UNDER_CE @@ -447,7 +453,7 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) , NULL, WS_BORDER | WS_VISIBLE |WS_CHILD | CBS_DROPDOWN | CBS_AUTOHSCROLL, 0, 0, 100, 520, - ((_headerReBar == 0) ? HWND(*this) : _headerToolBar), + ((_headerReBar == 0) ? (HWND)*this : _headerToolBar), (HMENU)(UINT_PTR)(_comboBoxID), g_hInstance, NULL); #ifndef UNDER_CE @@ -519,14 +525,14 @@ bool CPanel::OnCreate(CREATESTRUCT * /* createStruct */) _statusBar.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID); // _statusBar2.Create(WS_CHILD | WS_VISIBLE, L"Status", (*this), _statusBarID + 1); - int sizes[] = {150, 250, 350, -1}; + int sizes[] = {160, 250, 350, -1}; _statusBar.SetParts(4, sizes); // _statusBar2.SetParts(5, sizes); /* RECT rect; GetClientRect(&rect); - OnSize(0, rect.right - rect.left, rect.top - rect.bottom); + OnSize(0, RECT_SIZE_X(rect), RECT_SIZE_Y(rect)); */ SetTimer(kTimerID, kTimerElapse); @@ -556,13 +562,13 @@ void CPanel::ChangeWindowSize(int xSize, int ySize) else _headerToolBar.GetWindowRect(&rect); - kHeaderSize = rect.bottom - rect.top; + kHeaderSize = RECT_SIZE_Y(rect); _statusBar.GetWindowRect(&rect); - kStatusBarSize = rect.bottom - rect.top; + kStatusBarSize = RECT_SIZE_Y(rect); // _statusBar2.GetWindowRect(&rect); - // kStatusBar2Size = rect.bottom - rect.top; + // kStatusBar2Size = RECT_SIZE_Y(rect); int yListViewSize = MyMax(ySize - kHeaderSize - kStatusBarSize, 0); const int kStartXPos = 32; @@ -600,7 +606,7 @@ bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */) { RECT rect; GetWindowRect(&rect); - ChangeWindowSize(rect.right - rect.left, rect.bottom - rect.top); + ChangeWindowSize(RECT_SIZE_X(rect), RECT_SIZE_Y(rect)); return false; } } @@ -615,7 +621,6 @@ bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result) return OnNotifyComboBox(header, result); else if (header->hwndFrom == _headerReBar) return OnNotifyReBar(header, result); - // if (header->hwndFrom == _listView) else if (header->hwndFrom == _listView) return OnNotifyList(header, result); else if (::GetParent(header->hwndFrom) == _listView && @@ -649,13 +654,15 @@ bool CPanel::OnCommand(int code, int itemID, LPARAM lParam, LRESULT &result) } void CPanel::MessageBoxInfo(LPCWSTR message, LPCWSTR caption) - { ::MessageBoxW(HWND(*this), message, caption, MB_OK); } + { ::MessageBoxW((HWND)*this, message, caption, MB_OK); } void CPanel::MessageBox(LPCWSTR message, LPCWSTR caption) - { ::MessageBoxW(HWND(*this), message, caption, MB_OK | MB_ICONSTOP); } + { ::MessageBoxW((HWND)*this, message, caption, MB_OK | MB_ICONSTOP); } void CPanel::MessageBox(LPCWSTR message) { MessageBox(message, L"7-Zip"); } +void CPanel::MessageBoxWarning(LPCWSTR message) + { ::MessageBoxW(NULL, message, L"7-Zip", MB_OK | MB_ICONWARNING); } void CPanel::MessageBoxMyError(LPCWSTR message) - { MessageBox(message, L"Error"); } + { MessageBox(message, L"7-Zip"); } void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption) @@ -663,15 +670,26 @@ void CPanel::MessageBoxError(HRESULT errorCode, LPCWSTR caption) MessageBox(HResultToMessage(errorCode), caption); } +void CPanel::MessageBoxError2Lines(LPCWSTR message, HRESULT errorCode) +{ + UString m = message; + if (errorCode != 0) + { + m += L'\n'; + m += HResultToMessage(errorCode); + } + MessageBoxMyError(m); +} + void CPanel::MessageBoxError(HRESULT errorCode) { MessageBoxError(errorCode, L"7-Zip"); } void CPanel::MessageBoxLastError(LPCWSTR caption) { MessageBoxError(::GetLastError(), caption); } void CPanel::MessageBoxLastError() - { MessageBoxLastError(L"Error"); } + { MessageBoxLastError(L"7-Zip"); } -void CPanel::MessageBoxErrorLang(UINT resourceID, UInt32 langID) - { MessageBox(LangString(resourceID, langID)); } +void CPanel::MessageBoxErrorLang(UINT resourceID) + { MessageBox(LangString(resourceID)); } void CPanel::SetFocusToList() @@ -707,8 +725,7 @@ bool CPanel::IsFSFolder() const { return IsFolderTypeEqTo(L"FSFolder"); } bool CPanel::IsFSDrivesFolder() const { return IsFolderTypeEqTo(L"FSDrives"); } bool CPanel::IsArcFolder() const { - UString s = GetFolderTypeID(); - return s.Left(5) == L"7-Zip"; + return GetFolderTypeID().IsPrefixedBy(L"7-Zip"); } UString CPanel::GetFsPath() const @@ -723,22 +740,8 @@ UString CPanel::GetDriveOrNetworkPrefix() const if (!IsFSFolder()) return UString(); UString drive = GetFsPath(); - if (drive.Length() < 3) - return UString(); - if (drive[0] == L'\\' && drive[1] == L'\\') - { - // if network - int pos = drive.Find(L'\\', 2); - if (pos < 0) - return UString(); - pos = drive.Find(L'\\', pos + 1); - if (pos < 0) - return UString(); - return drive.Left(pos + 1); - } - if (drive[1] != L':' || drive[2] != L'\\') - return UString(); - return drive.Left(3); + drive.DeleteFrom(NFile::NName::GetRootPrefixSize(drive)); + return drive; } bool CPanel::DoesItSupportOperations() const @@ -754,9 +757,20 @@ void CPanel::SetListViewMode(UInt32 index) _ListViewMode = index; DWORD oldStyle = (DWORD)_listView.GetStyle(); DWORD newStyle = kStyles[index]; + + // DWORD tickCount1 = GetTickCount(); if ((oldStyle & LVS_TYPEMASK) != newStyle) _listView.SetStyle((oldStyle & ~LVS_TYPEMASK) | newStyle); // RefreshListCtrlSaveFocused(); + /* + DWORD tickCount2 = GetTickCount(); + char s[256]; + sprintf(s, "SetStyle = %5d", + tickCount2 - tickCount1 + ); + OutputDebugStringA(s); + */ + } void CPanel::ChangeFlatMode() @@ -769,6 +783,17 @@ void CPanel::ChangeFlatMode() RefreshListCtrlSaveFocused(); } +/* +void CPanel::Change_ShowNtfsStrems_Mode() +{ + _showNtfsStrems_Mode = !_showNtfsStrems_Mode; + if (_parentFolders.Size() > 0) + _showNtfsStrems_ModeForArc = _showNtfsStrems_Mode; + else + _showNtfsStrems_ModeForDisk = _showNtfsStrems_Mode; + RefreshListCtrlSaveFocused(); +} +*/ void CPanel::Post_Refresh_StatusBar() { @@ -782,12 +807,12 @@ void CPanel::AddToArchive() GetOperatedItemIndices(indices); if (!IsFsOrDrivesFolder()) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } if (indices.Size() == 0) { - MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03); + MessageBoxErrorLang(IDS_SELECT_FILES); return; } UStringVector names; @@ -801,35 +826,42 @@ void CPanel::AddToArchive() curPrefix.Empty(); } - for (int i = 0; i < indices.Size(); i++) + FOR_VECTOR (i, indices) names.Add(curPrefix + GetItemRelPath(indices[i])); - const UString archiveName = CreateArchiveName(names.Front(), (names.Size() > 1), false); - HRESULT res = CompressFiles(destCurDirPrefix, archiveName, L"", names, false, true, false); + bool fromPrev = (names.Size() > 1); + const UString archiveName = CreateArchiveName(names.Front(), fromPrev, false); + HRESULT res = CompressFiles(destCurDirPrefix, archiveName, L"", + true, // addExtension + names, false, true, false); if (res != S_OK) { - if (destCurDirPrefix.Length() >= MAX_PATH) - MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER, 0x03020A01); + if (destCurDirPrefix.Len() >= MAX_PATH) + MessageBoxErrorLang(IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER); } // KillSelection(); } static UString GetSubFolderNameForExtract(const UString &archiveName) { - int slashPos = archiveName.ReverseFind(WCHAR_PATH_SEPARATOR); - int dotPos = archiveName.ReverseFind(L'.'); + UString res = archiveName; + int slashPos = res.ReverseFind(WCHAR_PATH_SEPARATOR); + int dotPos = res.ReverseFind(L'.'); if (dotPos < 0 || slashPos > dotPos) - return archiveName + UString(L"~"); - UString res = archiveName.Left(dotPos); - res.TrimRight(); + res += L'~'; + else + { + res.DeleteFrom(dotPos); + res.TrimRight(); + } return res; } -void CPanel::GetFilePaths(const CRecordVector &indices, UStringVector &paths) +void CPanel::GetFilePaths(const CRecordVector &indices, UStringVector &paths, bool allowFolders) { - for (int i = 0; i < indices.Size(); i++) + FOR_VECTOR (i, indices) { int index = indices[i]; - if (IsItemFolder(index)) + if (!allowFolders && IsItem_Folder(index)) { paths.Clear(); break; @@ -838,7 +870,7 @@ void CPanel::GetFilePaths(const CRecordVector &indices, UStringVector &p } if (paths.Size() == 0) { - MessageBoxErrorLang(IDS_SELECT_FILES, 0x03020A03); + MessageBoxErrorLang(IDS_SELECT_FILES); return; } } @@ -861,14 +893,17 @@ void CPanel::ExtractArchives() folderName = GetSubFolderNameForExtract(GetItemRelPath(indices[0])); else folderName = L"*"; - ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(WCHAR_PATH_SEPARATOR), true); + ::ExtractArchives(paths, _currentFolderPrefix + folderName + UString(WCHAR_PATH_SEPARATOR) + , true // showDialog + , false // elimDup + ); } -static void AddValuePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) +void AddValuePair(UINT resourceID, UInt64 value, UString &s) { wchar_t sz[32]; - s += LangString(resourceID, langID); - s += L' '; + s += LangString(resourceID); + s += L": "; ConvertUInt64ToString(value, sz); s += sz; s += L'\n'; @@ -884,31 +919,40 @@ public: CMyComPtr ArchiveFolder; }; +// actually now we don't need CThreadTest, since now we call CopyTo for "test command + +/* HRESULT CThreadTest::ProcessVirt() { RINOK(ArchiveFolder->Extract(&Indices[0], Indices.Size(), - NExtract::NPathMode::kFullPathnames, NExtract::NOverwriteMode::kAskBefore, - NULL, BoolToInt(true), ExtractCallback)); + true, // includeAltStreams + false, // replaceAltStreamColon + NExtract::NPathMode::kFullPathnames, + NExtract::NOverwriteMode::kAskBefore, + NULL, // path + BoolToInt(true), // testMode + ExtractCallback)); if (ExtractCallbackSpec->IsOK()) { UString s; - AddValuePair(IDS_FOLDERS_COLON, 0x02000321, ExtractCallbackSpec->NumFolders, s); - AddValuePair(IDS_FILES_COLON, 0x02000320, ExtractCallbackSpec->NumFiles, s); - // AddSizePair(IDS_SIZE_COLON, 0x02000322, Stat.UnpackSize, s); - // AddSizePair(IDS_COMPRESSED_COLON, 0x02000323, Stat.PackSize, s); + AddValuePair(IDS_PROP_FOLDERS, ExtractCallbackSpec->NumFolders, s); + AddValuePair(IDS_PROP_FILES, ExtractCallbackSpec->NumFiles, s); + // AddValuePair(IDS_PROP_SIZE, ExtractCallbackSpec->UnpackSize, s); + // AddSizePair(IDS_COMPRESSED_COLON, Stat.PackSize, s); s += L'\n'; - s += LangString(IDS_MESSAGE_NO_ERRORS, 0x02000608); - OkMessage = s; + s += LangString(IDS_MESSAGE_NO_ERRORS); + FinalMessage.OkMessage.Message = s; } return S_OK; } +*/ /* static void AddSizePair(UINT resourceID, UInt32 langID, UInt64 value, UString &s) { wchar_t sz[32]; s += LangString(resourceID, langID); - s += L" "; + s += L' '; ConvertUInt64ToString(value, sz); s += sz; ConvertUInt64ToString(value >> 20, sz); @@ -927,6 +971,21 @@ void CPanel::TestArchives() _folder.QueryInterface(IID_IArchiveFolder, &archiveFolder); if (archiveFolder) { + CCopyToOptions options; + options.streamMode = true; + options.showErrorMessages = true; + options.testMode = true; + + UStringVector messages; + HRESULT res = CopyTo(options, indices, &messages); + if (res != S_OK) + { + if (res != E_ABORT) + MessageBoxError(res); + } + return; + + /* { CThreadTest extracter; @@ -946,13 +1005,13 @@ void CPanel::TestArchives() extracter.Indices = indices; - UString title = LangString(IDS_PROGRESS_TESTING, 0x02000F90); - UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); + UString title = LangString(IDS_PROGRESS_TESTING); + UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE); extracter.ProgressDialog.CompressingMode = false; extracter.ProgressDialog.MainWindow = GetParent(); extracter.ProgressDialog.MainTitle = progressWindowTitle; - extracter.ProgressDialog.MainAddTitle = title + L" "; + extracter.ProgressDialog.MainAddTitle = title + L' '; extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore; extracter.ExtractCallbackSpec->Init(); @@ -963,15 +1022,16 @@ void CPanel::TestArchives() } RefreshTitleAlways(); return; + */ } if (!IsFSFolder()) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } UStringVector paths; - GetFilePaths(indices, paths); + GetFilePaths(indices, paths, true); if (paths.IsEmpty()) return; ::TestArchives(paths); diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h old mode 100755 new mode 100644 index e33a37a2..a9cf6023 --- a/CPP/7zip/UI/FileManager/Panel.h +++ b/CPP/7zip/UI/FileManager/Panel.h @@ -5,22 +5,27 @@ #include "../../../../C/Alloc.h" -#include "Common/MyCom.h" - -#include "Windows/DLL.h" -#include "Windows/FileDir.h" -#include "Windows/FileFind.h" -#include "Windows/Handle.h" -#include "Windows/Synchronization.h" - -#include "Windows/Control/ComboBox.h" -#include "Windows/Control/Edit.h" -#include "Windows/Control/ListView.h" -#include "Windows/Control/ReBar.h" -#include "Windows/Control/Static.h" -#include "Windows/Control/StatusBar.h" -#include "Windows/Control/ToolBar.h" -#include "Windows/Control/Window2.h" +#include "../../../Common/Defs.h" +#include "../../../Common/MyCom.h" + +#include "../../../Windows/DLL.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/FileFind.h" +#include "../../../Windows/Handle.h" +#include "../../../Windows/Synchronization.h" + +#include "../../../Windows/Control/ComboBox.h" +#include "../../../Windows/Control/Edit.h" +#include "../../../Windows/Control/ListView.h" +#include "../../../Windows/Control/ReBar.h" +#include "../../../Windows/Control/Static.h" +#include "../../../Windows/Control/StatusBar.h" +#include "../../../Windows/Control/ToolBar.h" +#include "../../../Windows/Control/Window2.h" + +#include "../../Archive/IArchive.h" + +#include "ExtractCallback.h" #include "AppState.h" #include "IFolder.h" @@ -28,9 +33,13 @@ #include "ProgressDialog2.h" #include "SysIconUtils.h" +#ifdef UNDER_CE +#define NON_CE_VAR(_v_) +#else +#define NON_CE_VAR(_v_) _v_ +#endif + const int kParentFolderID = 100; -const int kPluginMenuStartID = 1000; -const int kToolbarStartID = 2000; const int kParentIndex = -1; @@ -62,21 +71,18 @@ struct CItemProperty VARTYPE Type; int Order; bool IsVisible; + bool IsRawProp; UInt32 Width; -}; - -inline bool operator<(const CItemProperty &a1, const CItemProperty &a2) - { return (a1.Order < a2.Order); } -inline bool operator==(const CItemProperty &a1, const CItemProperty &a2) - { return (a1.Order == a2.Order); } + int Compare(const CItemProperty &a) const { return MyCompare(Order, a.Order); } +}; class CItemProperties: public CObjectVector { public: int FindItemWithID(PROPID id) { - for (int i = 0; i < Size(); i++) + FOR_VECTOR (i, (*this)) if ((*this)[i].ID == id) return i; return -1; @@ -97,8 +103,8 @@ struct CTempFileInfo { if (NeedDelete) { - NWindows::NFile::NDirectory::DeleteFileAlways(FilePath); - NWindows::NFile::NDirectory::MyRemoveDirectory(FolderPath); + NWindows::NFile::NDir::DeleteFileAlways(FilePath); + NWindows::NFile::NDir::RemoveDir(FolderPath); } } bool WasChanged(const NWindows::NFile::NFind::CFileInfo &newFileInfo) const @@ -128,6 +134,8 @@ struct CFolderLink: public CTempFileInfo enum MyMessages { + // we can use WM_USER, since we have defined new window class. + // so we don't need WM_APP. kShiftSelectMessage = WM_USER + 1, kReLoadMessage, kSetFocusToListView, @@ -181,6 +189,35 @@ struct CSelectedState #define MY_NMLISTVIEW_NMITEMACTIVATE NMITEMACTIVATE #endif +struct CCopyToOptions +{ + bool streamMode; + bool moveMode; + bool testMode; + bool includeAltStreams; + bool replaceAltStreamChars; + bool showErrorMessages; + + UString folder; + + UStringVector hashMethods; + + CVirtFileSystem *VirtFileSystemSpec; + ISequentialOutStream *VirtFileSystem; + + CCopyToOptions(): + streamMode(false), + moveMode(false), + testMode(false), + includeAltStreams(true), + replaceAltStreamChars(false), + showErrorMessages(false), + VirtFileSystemSpec(NULL), + VirtFileSystem(NULL) + {} +}; + + class CPanel: public NWindows::NControl::CWindow2 { CExtToIconMap _extToIconMap; @@ -223,6 +260,7 @@ class CPanel: public NWindows::NControl::CWindow2 void OnColumnClick(LPNMLISTVIEW info); bool OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result); + public: HWND _mainWindow; CPanelCallback *_panelCallback; @@ -230,9 +268,10 @@ public: void SysIconsWereChanged() { _extToIconMap.Clear(); } void DeleteItems(bool toRecycleBin); - void DeleteItemsInternal(CRecordVector &indices); void CreateFolder(); void CreateFile(); + bool CorrectFsPath(const UString &path, UString &result); + // bool IsPathForPlugin(const UString &path); private: @@ -293,6 +332,8 @@ public: CBoolVector _selectedStatusVector; CSelectedState _selectedState; + bool _thereAreDeletedItems; + bool _markDeletedItems; HWND GetParent(); @@ -323,6 +364,10 @@ public: bool _flatModeForDisk; bool _flatModeForArc; + // bool _showNtfsStrems_Mode; + // bool _showNtfsStrems_ModeForDisk; + // bool _showNtfsStrems_ModeForArc; + bool _dontShowMode; @@ -330,7 +375,33 @@ public: CObjectVector _parentFolders; NWindows::NDLL::CLibrary _library; + CMyComPtr _folder; + CMyComPtr _folderCompare; + CMyComPtr _folderGetItemName; + CMyComPtr _folderRawProps; + + void ReleaseFolder() + { + _folderCompare.Release(); + _folderGetItemName.Release(); + _folderRawProps.Release(); + _folder.Release(); + _thereAreDeletedItems = false; + } + + void SetNewFolder(IFolderFolder *newFolder) + { + ReleaseFolder(); + _folder = newFolder; + if (_folder) + { + _folder.QueryInterface(IID_IFolderCompare, &_folderCompare); + _folder.QueryInterface(IID_IFolderGetItemName, &_folderGetItemName); + _folder.QueryInterface(IID_IArchiveGetRawProps, &_folderRawProps); + } + } + // CMyComPtr _folderGetSystemIconIndex; UStringVector _fastFolders; @@ -340,11 +411,16 @@ public: HRESULT RefreshListCtrl(const CSelectedState &s); HRESULT RefreshListCtrlSaveFocused(); + bool GetItem_BoolProp(UInt32 itemIndex, PROPID propID) const; + bool IsItem_Deleted(int itemIndex) const; + bool IsItem_Folder(int itemIndex) const; + bool IsItem_AltStream(int itemIndex) const; + UString GetItemName(int itemIndex) const; + void GetItemNameFast(int itemIndex, UString &s) const; UString GetItemPrefix(int itemIndex) const; UString GetItemRelPath(int itemIndex) const; UString GetItemFullPath(int itemIndex) const; - bool IsItemFolder(int itemIndex) const; UInt64 GetItemSize(int itemIndex) const; //////////////////////// @@ -391,8 +467,15 @@ public: _flatMode(false), _flatModeForDisk(false), _flatModeForArc(false), + + // _showNtfsStrems_Mode(false), + // _showNtfsStrems_ModeForDisk(false), + // _showNtfsStrems_ModeForArc(false), + _xSize(300), _mySelectMode(false), + _thereAreDeletedItems(false), + _markDeletedItems(true), _enableItemChangeNotify(true), _dontShowMode(false) {} @@ -413,6 +496,9 @@ public: PROPID _sortID; // int _sortIndex; bool _ascending; + Int32 _isRawSortProp; + + void SetSortRawStatus(); void Release(); ~CPanel(); @@ -489,8 +575,6 @@ public: class CDisableTimerProcessing { bool _processTimerMem; - bool _processNotifyMem; - bool _processStatusBarMem; CPanel &_panel; public: @@ -500,38 +584,66 @@ public: void Disable() { _processTimerMem = _panel._processTimer; + _panel._processTimer = false; + } + void Restore() + { + _panel._processTimer = _processTimerMem; + } + CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; } + }; + + class CDisableNotify + { + bool _processNotifyMem; + bool _processStatusBarMem; + + CPanel &_panel; + public: + + CDisableNotify(CPanel &panel): _panel(panel) { Disable(); } + ~CDisableNotify() { Restore(); } + void Disable() + { _processNotifyMem = _panel._processNotify; _processStatusBarMem = _panel._processStatusBar; - _panel._processTimer = false; _panel._processNotify = false; _panel._processStatusBar = false; } + void SetMemMode_Enable() + { + _processNotifyMem = true; + _processStatusBarMem = true; + } void Restore() { - _panel._processTimer = _processTimerMem; _panel._processNotify = _processNotifyMem; _panel._processStatusBar = _processStatusBarMem; } - CDisableTimerProcessing& operator=(const CDisableTimerProcessing &) {; } + CDisableNotify& operator=(const CDisableNotify &) {; } }; // bool _passwordIsDefined; // UString _password; + void InvalidateList() { _listView.InvalidateRect(NULL, true); } + HRESULT RefreshListCtrl(); void MessageBoxInfo(LPCWSTR message, LPCWSTR caption); void MessageBox(LPCWSTR message); + void MessageBoxWarning(LPCWSTR message); void MessageBox(LPCWSTR message, LPCWSTR caption); void MessageBoxMyError(LPCWSTR message); void MessageBoxError(HRESULT errorCode, LPCWSTR caption); void MessageBoxError(HRESULT errorCode); + void MessageBoxError2Lines(LPCWSTR message, HRESULT errorCode); void MessageBoxLastError(LPCWSTR caption); void MessageBoxLastError(); - void MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID); + void MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID); - void MessageBoxErrorLang(UINT resourceID, UInt32 langID); + void MessageBoxErrorLang(UINT resourceID); void OpenFocusedItemAsInternal(); void OpenSelectedItems(bool internal); @@ -548,13 +660,13 @@ public: HRESULT OpenItemAsArchive(const UString &relPath, const UString &arcFormat, bool &encrypted); HRESULT OpenItemAsArchive(int index); void OpenItemInArchive(int index, bool tryInternal, bool tryExternal, - bool editMode); + bool editMode, bool useEditor); HRESULT OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, bool usePassword, const UString &password); LRESULT OnOpenItemChanged(LPARAM lParam); void OpenItem(int index, bool tryInternal, bool tryExternal); - void EditItem(); - void EditItem(int index); + void EditItem(bool useEditor); + void EditItem(int index, bool useEditor); void RenameFile(); void ChangeComment(); @@ -564,23 +676,31 @@ public: PROPID GetSortID() const { return _sortID; } void ChangeFlatMode(); + void Change_ShowNtfsStrems_Mode(); bool GetFlatMode() const { return _flatMode; } + // bool Get_ShowNtfsStrems_Mode() const { return _showNtfsStrems_Mode; } + bool AutoRefresh_Mode; + void Set_AutoRefresh_Mode(bool mode) + { + AutoRefresh_Mode = mode; + } + void Post_Refresh_StatusBar(); void Refresh_StatusBar(); void AddToArchive(); - void GetFilePaths(const CRecordVector &indices, UStringVector &paths); + void GetFilePaths(const CRecordVector &indices, UStringVector &paths, bool allowFolders = false); void ExtractArchives(); void TestArchives(); - HRESULT CopyTo(const CRecordVector &indices, const UString &folder, - bool moveMode, bool showErrorMessages, UStringVector *messages, + HRESULT CopyTo(CCopyToOptions &options, + const CRecordVector &indices, + UStringVector *messages, bool &usePassword, UString &password); - HRESULT CopyTo(const CRecordVector &indices, const UString &folder, - bool moveMode, bool showErrorMessages, UStringVector *messages) + HRESULT CopyTo(CCopyToOptions &options, const CRecordVector &indices, UStringVector *messages) { bool usePassword = false; UString password; @@ -590,10 +710,10 @@ public: usePassword = fl.UsePassword; password = fl.Password; } - return CopyTo(indices, folder, moveMode, showErrorMessages, messages, usePassword, password); + return CopyTo(options, indices, messages, usePassword, password); } - HRESULT CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, + HRESULT CopyFrom(bool moveMode, const UString &folderPrefix, const UStringVector &filePaths, bool showErrorMessages, UStringVector *messages); void CopyFromNoAsk(const UStringVector &filePaths); diff --git a/CPP/7zip/UI/FileManager/PanelCopy.cpp b/CPP/7zip/UI/FileManager/PanelCopy.cpp old mode 100755 new mode 100644 index 8c27ef2f..d11368cf --- a/CPP/7zip/UI/FileManager/PanelCopy.cpp +++ b/CPP/7zip/UI/FileManager/PanelCopy.cpp @@ -1,14 +1,15 @@ -// PanelExtract.cpp +/// PanelExtract.cpp #include "StdAfx.h" +#include "../../../Common/MyException.h" + +#include "../GUI/HashGUI.h" + +#include "ExtractCallback.h" +#include "LangUtils.h" #include "Panel.h" #include "resource.h" -#include "LangUtils.h" -#include "ExtractCallback.h" -#include "Windows/Thread.h" -//////////////////////////////////////////////////////////////// - #include "UpdateCallback100.h" using namespace NWindows; @@ -17,35 +18,82 @@ class CPanelCopyThread: public CProgressThreadVirt { HRESULT ProcessVirt(); public: + const CCopyToOptions *options; CMyComPtr FolderOperations; CRecordVector Indices; - UString DestPath; CExtractCallbackImp *ExtractCallbackSpec; CMyComPtr ExtractCallback; + + CHashBundle Hash; + UString FirstFilePath; + HRESULT Result; - bool MoveMode; + - CPanelCopyThread(): MoveMode(false), Result(E_FAIL) {} + CPanelCopyThread(): Result(E_FAIL) {} }; HRESULT CPanelCopyThread::ProcessVirt() { - if (MoveMode) - Result = FolderOperations->MoveTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback); + /* + CMyComPtr iReplace; + FolderOperations.QueryInterface(IID_IFolderSetReplaceAltStreamCharsMode, &iReplace); + if (iReplace) + { + RINOK(iReplace->SetReplaceAltStreamCharsMode(ReplaceAltStreamChars ? 1 : 0)); + } + */ + + if (options->testMode) + { + CMyComPtr archiveFolder; + FolderOperations.QueryInterface(IID_IArchiveFolder, &archiveFolder); + if (!archiveFolder) + return E_NOTIMPL; + CMyComPtr extractCallback2; + RINOK(ExtractCallback.QueryInterface(IID_IFolderArchiveExtractCallback, &extractCallback2)); + NExtract::NPathMode::EEnum pathMode = + NExtract::NPathMode::kCurPaths; + // NExtract::NPathMode::kFullPathnames; + Result = archiveFolder->Extract(&Indices.Front(), Indices.Size(), + BoolToInt(options->includeAltStreams), + BoolToInt(options->replaceAltStreamChars), + pathMode, NExtract::NOverwriteMode::kAsk, + options->folder, BoolToInt(true), extractCallback2); + } else - Result = FolderOperations->CopyTo(&Indices.Front(), Indices.Size(), DestPath, ExtractCallback); + Result = FolderOperations->CopyTo( + BoolToInt(options->moveMode), + &Indices.Front(), Indices.Size(), + BoolToInt(options->includeAltStreams), + BoolToInt(options->replaceAltStreamChars), + options->folder, ExtractCallback); + + if (Result == S_OK && !ExtractCallbackSpec->ThereAreMessageErrors && + (!options->hashMethods.IsEmpty() || options->testMode)) + { + CProgressMessageBoxPair &pair = GetMessagePair(false); // GetMessagePair(ExtractCallbackSpec->Hash.NumErrors != 0); + AddHashBundleRes(pair.Message, Hash, FirstFilePath); + } + return Result; } -HRESULT CPanel::CopyTo(const CRecordVector &indices, const UString &folder, - bool moveMode, bool showErrorMessages, UStringVector *messages, +static void ThrowException_if_Error(HRESULT res) +{ + if (res != S_OK) + throw CSystemException(res); +} + +HRESULT CPanel::CopyTo(CCopyToOptions &options, const CRecordVector &indices, + UStringVector *messages, bool &usePassword, UString &password) { CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); - if (showErrorMessages) + UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED); + if (options.showErrorMessages) MessageBox(errorMessage); else if (messages != 0) messages->Add(errorMessage); @@ -56,27 +104,88 @@ HRESULT CPanel::CopyTo(const CRecordVector &indices, const UString &fold { CPanelCopyThread extracter; - extracter.ExtractCallbackSpec = new CExtractCallbackImp; extracter.ExtractCallback = extracter.ExtractCallbackSpec; + + extracter.options = &options; extracter.ExtractCallbackSpec->ProgressDialog = &extracter.ProgressDialog; extracter.ProgressDialog.CompressingMode = false; + + extracter.ExtractCallbackSpec->StreamMode = options.streamMode; + + #ifdef EXTERNAL_CODECS + CExternalCodecs __externalCodecs; + #else + CMyComPtr compressCodecsInfo; + #endif + + if (indices.Size() == 1) + extracter.FirstFilePath = GetItemRelPath(indices[0]); + + if (options.VirtFileSystem) + { + extracter.ExtractCallbackSpec->VirtFileSystem = options.VirtFileSystem; + extracter.ExtractCallbackSpec->VirtFileSystemSpec = options.VirtFileSystemSpec; + } + extracter.ExtractCallbackSpec->ProcessAltStreams = options.includeAltStreams; + + if (!options.hashMethods.IsEmpty()) + { + { + CCodecs *codecs = new CCodecs; + ThrowException_if_Error(codecs->Load()); + #ifdef EXTERNAL_CODECS + __externalCodecs.GetCodecs = codecs; + __externalCodecs.GetHashers = codecs; + ThrowException_if_Error(__externalCodecs.LoadCodecs()); + #else + compressCodecsInfo = codecs; + #endif + } + + extracter.Hash.SetMethods(EXTERNAL_CODECS_VARS options.hashMethods); + extracter.ExtractCallbackSpec->SetHashMethods(&extracter.Hash); + } + else if (options.testMode) + { + extracter.ExtractCallbackSpec->SetHashCalc(&extracter.Hash); + } + + extracter.Hash.Init(); + - UString title = moveMode ? - LangString(IDS_MOVING, 0x03020206): - LangString(IDS_COPYING, 0x03020205); - UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); + UString title; + { + UInt32 titleID = IDS_COPYING; + if (options.moveMode) + titleID = IDS_MOVING; + else if (!options.hashMethods.IsEmpty() && options.streamMode) + { + titleID = IDS_CHECKSUM_CALCULATING; + if (options.hashMethods.Size() == 1) + { + const UString &s = options.hashMethods[0]; + if (s != L"*") + title = s; + } + } + else if (options.testMode) + titleID = IDS_PROGRESS_TESTING; + + if (title.IsEmpty()) + title = LangString(titleID); + } + + UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE); extracter.ProgressDialog.MainWindow = GetParent(); extracter.ProgressDialog.MainTitle = progressWindowTitle; - extracter.ProgressDialog.MainAddTitle = title + L" "; + extracter.ProgressDialog.MainAddTitle = title + L' '; - extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAskBefore; + extracter.ExtractCallbackSpec->OverwriteMode = NExtract::NOverwriteMode::kAsk; extracter.ExtractCallbackSpec->Init(); extracter.Indices = indices; - extracter.DestPath = folder; extracter.FolderOperations = folderOperations; - extracter.MoveMode = moveMode; extracter.ExtractCallbackSpec->PasswordIsDefined = usePassword; extracter.ExtractCallbackSpec->Password = password; @@ -93,6 +202,7 @@ HRESULT CPanel::CopyTo(const CRecordVector &indices, const UString &fold password = extracter.ExtractCallbackSpec->Password; } } + RefreshTitleAlways(); return res; } @@ -108,6 +218,7 @@ struct CThreadUpdate CMyComPtr UpdateCallback; CUpdateCallback100Imp *UpdateCallbackSpec; HRESULT Result; + bool MoveMode; void Process() { @@ -115,6 +226,7 @@ struct CThreadUpdate { CProgressCloser closer(ProgressDialog); Result = FolderOperations->CopyFrom( + MoveMode, FolderPrefix, &FileNamePointers.Front(), FileNamePointers.Size(), @@ -129,7 +241,7 @@ struct CThreadUpdate } }; -HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &filePaths, +HRESULT CPanel::CopyFrom(bool moveMode, const UString &folderPrefix, const UStringVector &filePaths, bool showErrorMessages, UStringVector *messages) { CMyComPtr folderOperations; @@ -140,28 +252,29 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP else { CThreadUpdate updater; + updater.MoveMode = moveMode; updater.UpdateCallbackSpec = new CUpdateCallback100Imp; updater.UpdateCallback = updater.UpdateCallbackSpec; updater.UpdateCallbackSpec->ProgressDialog = &updater.ProgressDialog; - UString title = LangString(IDS_COPYING, 0x03020205); - UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); + UString title = LangString(IDS_COPYING); + UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE); updater.ProgressDialog.MainWindow = GetParent(); updater.ProgressDialog.MainTitle = progressWindowTitle; - updater.ProgressDialog.MainAddTitle = title + UString(L" "); + updater.ProgressDialog.MainAddTitle = title + UString(L' '); updater.UpdateCallbackSpec->Init(false, L""); updater.FolderOperations = folderOperations; updater.FolderPrefix = folderPrefix; - updater.FileNames.Reserve(filePaths.Size()); - int i; - for(i = 0; i < filePaths.Size(); i++) - updater.FileNames.Add(filePaths[i]); - updater.FileNamePointers.Reserve(updater.FileNames.Size()); - for(i = 0; i < updater.FileNames.Size(); i++) - updater.FileNamePointers.Add(updater.FileNames[i]); + updater.FileNames.ClearAndReserve(filePaths.Size()); + unsigned i; + for (i = 0; i < filePaths.Size(); i++) + updater.FileNames.AddInReserved(filePaths[i]); + updater.FileNamePointers.ClearAndReserve(updater.FileNames.Size()); + for (i = 0; i < updater.FileNames.Size(); i++) + updater.FileNamePointers.AddInReserved(updater.FileNames[i]); NWindows::CThread thread; RINOK(thread.Create(CThreadUpdate::MyThreadFunction, &updater)); @@ -175,7 +288,7 @@ HRESULT CPanel::CopyFrom(const UString &folderPrefix, const UStringVector &fileP if (res == E_NOINTERFACE) { - UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + UString errorMessage = LangString(IDS_OPERATION_IS_NOT_SUPPORTED); if (showErrorMessages) MessageBox(errorMessage); else if (messages != 0) @@ -194,11 +307,13 @@ void CPanel::CopyFromNoAsk(const UStringVector &filePaths) CSelectedState srcSelState; SaveSelectedState(srcSelState); - HRESULT result = CopyFrom(L"", filePaths, true, 0); + HRESULT result = CopyFrom(false, L"", filePaths, true, 0); + + CDisableNotify disableNotify(*this); if (result != S_OK) { - disableTimerProcessing.Restore(); + disableNotify.Restore(); // For Password: SetFocusToList(); if (result != E_ABORT) @@ -208,14 +323,14 @@ void CPanel::CopyFromNoAsk(const UStringVector &filePaths) RefreshListCtrl(srcSelState); - disableTimerProcessing.Restore(); + disableNotify.Restore(); SetFocusToList(); } void CPanel::CopyFromAsk(const UStringVector &filePaths) { - UString title = LangString(IDS_CONFIRM_FILE_COPY, 0x03020222); - UString message = LangString(IDS_WANT_TO_COPY_FILES, 0x03020223); + UString title = LangString(IDS_CONFIRM_FILE_COPY); + UString message = LangString(IDS_WANT_TO_COPY_FILES); message += L"\n\'"; message += _currentFolderPrefix; message += L"\' ?"; diff --git a/CPP/7zip/UI/FileManager/PanelCrc.cpp b/CPP/7zip/UI/FileManager/PanelCrc.cpp old mode 100755 new mode 100644 index 2dd5e7ce..ab93ecba --- a/CPP/7zip/UI/FileManager/PanelCrc.cpp +++ b/CPP/7zip/UI/FileManager/PanelCrc.cpp @@ -1,24 +1,19 @@ -// PanelSplitFile.cpp +// PanelCrc.cpp #include "StdAfx.h" -#include "../../../../C/7zCrc.h" -#include "../../../../C/Sha256.h" +#include "../../../Common/MyException.h" -#include "Common/IntToString.h" +#include "../../../Windows/FileFind.h" +#include "../../../Windows/FileIO.h" -#include "Windows/FileFind.h" -#include "Windows/FileIO.h" -#include "Windows/FileName.h" +#include "../Common/LoadCodecs.h" -#include "OverwriteDialogRes.h" +#include "../GUI/HashGUI.h" #include "App.h" -#include "FormatUtils.h" #include "LangUtils.h" -#include "../Common/PropIDUtils.h" - #include "resource.h" using namespace NWindows; @@ -28,17 +23,18 @@ static const UInt32 kBufSize = (1 << 15); struct CDirEnumerator { - bool FlatMode; + bool EnterToDirs; FString BasePrefix; - FStringVector FileNames; + FStringVector FilePaths; CObjectVector Enumerators; FStringVector Prefixes; - int Index; - HRESULT GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &fullPath); + unsigned Index; + + CDirEnumerator(): EnterToDirs(false), Index(0) {}; + void Init(); - - CDirEnumerator(): FlatMode(false) {}; + DWORD GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &resPath); }; void CDirEnumerator::Init() @@ -48,295 +44,320 @@ void CDirEnumerator::Init() Index = 0; } -static HRESULT GetNormalizedError() +static DWORD GetNormalizedError() { - HRESULT errorCode = GetLastError(); - return (errorCode == 0) ? E_FAIL : errorCode; + DWORD error = GetLastError(); + return (error == 0) ? E_FAIL : error; } -HRESULT CDirEnumerator::GetNextFile(NFind::CFileInfo &fileInfo, bool &filled, FString &resPath) +DWORD CDirEnumerator::GetNextFile(NFind::CFileInfo &fi, bool &filled, FString &resPath) { filled = false; + resPath.Empty(); for (;;) { if (Enumerators.IsEmpty()) { - if (Index >= FileNames.Size()) + if (Index >= FilePaths.Size()) return S_OK; - const FString &path = FileNames[Index]; + const FString &path = FilePaths[Index++]; int pos = path.ReverseFind(FCHAR_PATH_SEPARATOR); - resPath.Empty(); if (pos >= 0) - resPath = path.Left(pos + 1); + resPath.SetFrom(path, pos + 1); #ifdef _WIN32 - // it's for "c:" paths/ - if (BasePrefix.IsEmpty() && path.Length() == 2 && path[1] == ':') + if (BasePrefix.IsEmpty() && path.Len() == 2 && path[1] == ':') { - fileInfo.Name = path; - fileInfo.Attrib = FILE_ATTRIBUTE_DIRECTORY; - fileInfo.Size = 0; + // we use "c:" item as directory item + fi.Clear(); + fi.Name = path; + fi.SetAsDir(); + fi.Size = 0; } else #endif - if (!fileInfo.Find(BasePrefix + path)) + if (!fi.Find(BasePrefix + path)) { - WRes errorCode = GetNormalizedError(); + DWORD error = GetNormalizedError(); resPath = path; - return errorCode; + return error; } - Index++; break; } bool found; - if (!Enumerators.Back().Next(fileInfo, found)) + if (Enumerators.Back().Next(fi, found)) { - HRESULT errorCode = GetNormalizedError(); - resPath = Prefixes.Back(); - return errorCode; + if (found) + { + resPath = Prefixes.Back(); + break; + } } - if (found) + else { + DWORD error = GetNormalizedError(); resPath = Prefixes.Back(); - break; + Enumerators.DeleteBack(); + Prefixes.DeleteBack(); + return error; } Enumerators.DeleteBack(); Prefixes.DeleteBack(); } - resPath += fileInfo.Name; - if (!FlatMode && fileInfo.IsDir()) + resPath += fi.Name; + if (EnterToDirs && fi.IsDir()) { - FString prefix = resPath + FCHAR_PATH_SEPARATOR; - Enumerators.Add(NFind::CEnumerator(BasePrefix + prefix + FCHAR_ANY_MASK)); - Prefixes.Add(prefix); + FString s = resPath; + s += FCHAR_PATH_SEPARATOR; + Prefixes.Add(s); + s += FCHAR_ANY_MASK; + Enumerators.Add(NFind::CEnumerator(BasePrefix + s)); } filled = true; return S_OK; } -static void ConvertByteToHex(unsigned value, wchar_t *s) -{ - for (int i = 0; i < 2; i++) - { - unsigned t = value & 0xF; - value >>= 4; - s[1 - i] = (wchar_t)((t < 10) ? (L'0' + t) : (L'A' + (t - 10))); - } -} - class CThreadCrc: public CProgressThreadVirt { - UInt64 NumFilesScan; - UInt64 NumFiles; - UInt64 NumFolders; - UInt64 DataSize; - UInt32 DataCrcSum; - Byte Sha256Sum[SHA256_DIGEST_SIZE]; - UInt32 DataNameCrcSum; - - UString GetResultMessage() const; HRESULT ProcessVirt(); public: CDirEnumerator Enumerator; - + CHashBundle Hash; + + void SetStatus(const UString &s); + void AddErrorMessage(DWORD systemError, const FChar *name); }; -UString CThreadCrc::GetResultMessage() const +void CThreadCrc::AddErrorMessage(DWORD systemError, const FChar *name) { - UString s; - wchar_t sz[32]; - - s += LangString(IDS_FILES_COLON, 0x02000320); - s += L' '; - ConvertUInt64ToString(NumFiles, sz); - s += sz; - s += L'\n'; - - s += LangString(IDS_FOLDERS_COLON, 0x02000321); - s += L' '; - ConvertUInt64ToString(NumFolders, sz); - s += sz; - s += L'\n'; - - s += LangString(IDS_SIZE_COLON, 0x02000322); - s += L' '; - ConvertUInt64ToString(DataSize, sz); - s += MyFormatNew(IDS_FILE_SIZE, 0x02000982, sz); - s += L'\n'; - - s += LangString(IDS_CHECKSUM_CRC_DATA, 0x03020721); - s += L' '; - ConvertUInt32ToHex(DataCrcSum, sz); - s += sz; - s += L'\n'; - - s += LangString(IDS_CHECKSUM_CRC_DATA_NAMES, 0x03020722); - s += L' '; - ConvertUInt32ToHex(DataNameCrcSum, sz); - s += sz; - s += L'\n'; - - if (NumFiles == 1 && NumFilesScan == 1) + ProgressDialog.Sync.AddError_Code_Name(systemError, fs2us(Enumerator.BasePrefix + name)); + Hash.NumErrors++; +} + +void CThreadCrc::SetStatus(const UString &s2) +{ + UString s = s2; + if (Enumerator.BasePrefix) { - s += L"SHA-256: "; - for (int i = 0; i < SHA256_DIGEST_SIZE; i++) - { - wchar_t s2[4]; - ConvertByteToHex(Sha256Sum[i], s2); - s2[2] = 0; - s += s2; - } + if (!s.IsEmpty()) + s += L' '; + s += fs2us(Enumerator.BasePrefix); } - return s; + ProgressDialog.Sync.Set_Status(s); } HRESULT CThreadCrc::ProcessVirt() { - DataSize = NumFolders = NumFiles = NumFilesScan = DataCrcSum = DataNameCrcSum = 0; - memset(Sha256Sum, 0, SHA256_DIGEST_SIZE); - // ProgressDialog.WaitCreating(); + Hash.Init(); - CMyBuffer bufferObject; - if (!bufferObject.Allocate(kBufSize)) + CMyBuffer buf; + if (!buf.Allocate(kBufSize)) return E_OUTOFMEMORY; - Byte *buffer = (Byte *)(void *)bufferObject; - - UInt64 totalSize = 0; + + CProgressSync &sync = ProgressDialog.Sync; + SetStatus(LangString(IDS_SCANNING)); + Enumerator.Init(); - - UString scanningStr = LangString(IDS_SCANNING, 0x03020800); - scanningStr += L' '; - - CProgressSync &sync = ProgressDialog.Sync; + + FString path; + NFind::CFileInfo fi; + UInt64 numFiles = 0; + UInt64 numItems = 0, numItems_Prev = 0; + UInt64 totalSize = 0; for (;;) { - NFind::CFileInfo fileInfo; bool filled; - FString resPath; - HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath); - if (errorCode != 0) + DWORD error = Enumerator.GetNextFile(fi, filled, path); + if (error != 0) { - SetErrorPath1(resPath); - return errorCode; + AddErrorMessage(error, path); + continue; } if (!filled) break; - if (!fileInfo.IsDir()) + if (!fi.IsDir()) + { + totalSize += fi.Size; + numFiles++; + } + numItems++; + bool needPrint = false; + // if (fi.IsDir()) { - totalSize += fileInfo.Size; - NumFilesScan++; + if (numItems - numItems_Prev >= 100) + { + needPrint = true; + numItems_Prev = numItems; + } + } + /* + else if (numFiles - numFiles_Prev >= 200) + { + needPrint = true; + numFiles_Prev = numFiles; + } + */ + if (needPrint) + { + RINOK(sync.ScanProgress(numFiles, totalSize, fs2us(path), fi.IsDir())); } - sync.SetCurrentFileName(scanningStr + fs2us(resPath)); - sync.SetProgress(totalSize, 0); - RINOK(sync.SetPosAndCheckPaused(0)); } - sync.SetNumFilesTotal(NumFilesScan); - sync.SetProgress(totalSize, 0); - + RINOK(sync.ScanProgress(numFiles, totalSize, L"", false)); + // sync.SetNumFilesTotal(numFiles); + // sync.SetProgress(totalSize, 0); + // SetStatus(LangString(IDS_CHECKSUM_CALCULATING)); + // sync.SetCurFilePath(L""); + SetStatus(L""); + Enumerator.Init(); - + + FString tempPath; + FString firstFilePath; + bool isFirstFile = true; + UInt64 errorsFilesSize = 0; + for (;;) { - NFind::CFileInfo fileInfo; bool filled; - FString resPath; - HRESULT errorCode = Enumerator.GetNextFile(fileInfo, filled, resPath); - if (errorCode != 0) + DWORD error = Enumerator.GetNextFile(fi, filled, path); + if (error != 0) { - SetErrorPath1(resPath); - return errorCode; + AddErrorMessage(error, path); + continue; } if (!filled) break; - UInt32 crc = CRC_INIT_VAL; - CSha256 sha256; - Sha256_Init(&sha256); - - if (fileInfo.IsDir()) - NumFolders++; - else + error = 0; + Hash.InitForNewFile(); + if (!fi.IsDir()) { NIO::CInFile inFile; - if (!inFile.Open(Enumerator.BasePrefix + resPath)) + tempPath = Enumerator.BasePrefix; + tempPath += path; + if (!inFile.Open(tempPath)) + { + error = GetNormalizedError(); + AddErrorMessage(error, path); + continue; + } + if (isFirstFile) { - errorCode = GetNormalizedError(); - SetErrorPath1(resPath); - return errorCode; + firstFilePath = path; + isFirstFile = false; } - sync.SetCurrentFileName(fs2us(resPath)); - sync.SetNumFilesCur(NumFiles); - NumFiles++; + sync.Set_FilePath(fs2us(path)); + sync.Set_NumFilesCur(Hash.NumFiles); + UInt64 progress_Prev = 0; for (;;) { - UInt32 processedSize; - if (!inFile.Read(buffer, kBufSize, processedSize)) + UInt32 size; + if (!inFile.Read(buf, kBufSize, size)) { - errorCode = GetNormalizedError(); - SetErrorPath1(resPath); - return errorCode; + error = GetNormalizedError(); + AddErrorMessage(error, path); + UInt64 errorSize = 0; + if (inFile.GetLength(errorSize)) + errorsFilesSize += errorSize; + break; } - if (processedSize == 0) + if (size == 0) break; - crc = CrcUpdate(crc, buffer, processedSize); - if (NumFilesScan == 1) - Sha256_Update(&sha256, buffer, processedSize); - - DataSize += processedSize; - RINOK(sync.SetPosAndCheckPaused(DataSize)); + Hash.Update(buf, size); + if (Hash.CurSize - progress_Prev >= ((UInt32)1 << 21)) + { + RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize + Hash.CurSize)); + progress_Prev = Hash.CurSize; + } } - DataCrcSum += CRC_GET_DIGEST(crc); - if (NumFilesScan == 1) - Sha256_Final(&sha256, Sha256Sum); - } - for (int i = 0; i < resPath.Length(); i++) - { - wchar_t c = resPath[i]; - crc = CRC_UPDATE_BYTE(crc, ((Byte)(c & 0xFF))); - crc = CRC_UPDATE_BYTE(crc, ((Byte)((c >> 8) & 0xFF))); } - DataNameCrcSum += CRC_GET_DIGEST(crc); - RINOK(sync.SetPosAndCheckPaused(DataSize)); + if (error == 0) + Hash.Final(fi.IsDir(), false, fs2us(path)); + RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize)); } - sync.SetNumFilesCur(NumFiles); - OkMessage = GetResultMessage(); - OkMessageTitle = LangString(IDS_CHECKSUM_INFORMATION, 0x03020720); + RINOK(sync.Set_NumBytesCur(errorsFilesSize + Hash.FilesSize)); + sync.Set_NumFilesCur(Hash.NumFiles); + if (Hash.NumFiles != 1) + sync.Set_FilePath(L""); + SetStatus(L""); + + CProgressMessageBoxPair &pair = GetMessagePair(Hash.NumErrors != 0); + AddHashBundleRes(pair.Message, Hash, fs2us(firstFilePath)); + LangString(IDS_CHECKSUM_INFORMATION, pair.Title); return S_OK; } -void CApp::CalculateCrc() +static void ThrowException_if_Error(HRESULT res) +{ + if (res != S_OK) + throw CSystemException(res); +} + +void CApp::CalculateCrc(const UString &methodName) { int srcPanelIndex = GetFocusedPanelIndex(); CPanel &srcPanel = Panels[srcPanelIndex]; - if (!srcPanel.IsFsOrDrivesFolder()) - { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); - return; - } + CRecordVector indices; - srcPanel.GetOperatedItemIndices(indices); + srcPanel.GetOperatedIndicesSmart(indices); if (indices.IsEmpty()) return; + if (!srcPanel.IsFsOrDrivesFolder()) { - CThreadCrc t; - for (int i = 0; i < indices.Size(); i++) - t.Enumerator.FileNames.Add(us2fs(srcPanel.GetItemRelPath(indices[i]))); - t.Enumerator.BasePrefix = us2fs(srcPanel.GetFsPath()); - t.Enumerator.FlatMode = GetFlatMode(); + CCopyToOptions options; + options.streamMode = true; + options.showErrorMessages = true; + options.hashMethods.Add(methodName); - t.ProgressDialog.ShowCompressionInfo = false; + UStringVector messages; + HRESULT res = srcPanel.CopyTo(options, indices, &messages); + if (res != S_OK) + { + if (res != E_ABORT) + srcPanel.MessageBoxError(res); + } + return; + } - UString title = LangString(IDS_CHECKSUM_CALCULATING, 0x03020710); + CCodecs *codecs = new CCodecs; + #ifdef EXTERNAL_CODECS + CExternalCodecs __externalCodecs; + __externalCodecs.GetCodecs = codecs; + __externalCodecs.GetHashers = codecs; + #else + CMyComPtr compressCodecsInfo = codecs; + #endif + ThrowException_if_Error(codecs->Load()); - t.ProgressDialog.MainWindow = _window; - t.ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); - t.ProgressDialog.MainAddTitle = title + UString(L' '); + #ifdef EXTERNAL_CODECS + ThrowException_if_Error(__externalCodecs.LoadCodecs()); + #endif - if (t.Create(title, _window) != S_OK) - return; + { + CThreadCrc t; + { + UStringVector methods; + methods.Add(methodName); + t.Hash.SetMethods(EXTERNAL_CODECS_VARS methods); + } + FOR_VECTOR (i, indices) + t.Enumerator.FilePaths.Add(us2fs(srcPanel.GetItemRelPath(indices[i]))); + t.Enumerator.BasePrefix = us2fs(srcPanel.GetFsPath()); + t.Enumerator.EnterToDirs = !GetFlatMode(); + + t.ProgressDialog.ShowCompressionInfo = false; + + UString title = LangString(IDS_CHECKSUM_CALCULATING); + + t.ProgressDialog.MainWindow = _window; + t.ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE); + t.ProgressDialog.MainAddTitle = title + UString(L' '); + + if (t.Create(title, _window) != S_OK) + return; } RefreshTitleAlways(); } diff --git a/CPP/7zip/UI/FileManager/PanelDrag.cpp b/CPP/7zip/UI/FileManager/PanelDrag.cpp old mode 100755 new mode 100644 index 02bccc03..9434d156 --- a/CPP/7zip/UI/FileManager/PanelDrag.cpp +++ b/CPP/7zip/UI/FileManager/PanelDrag.cpp @@ -6,12 +6,13 @@ #include #endif -#include "Common/StringConvert.h" +#include "../../../Common/StringConvert.h" +#include "../../../Common/Wildcard.h" -#include "Windows/Memory.h" -#include "Windows/FileDir.h" -#include "Windows/FileName.h" -#include "Windows/Shell.h" +#include "../../../Windows/MemoryGlobal.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/Shell.h" #include "../Common/ArchiveName.h" #include "../Common/CompressCall.h" @@ -22,6 +23,8 @@ #include "EnumFormatEtc.h" using namespace NWindows; +using namespace NFile; +using namespace NDir; #ifndef _UNICODE extern bool g_IsNT; @@ -204,10 +207,9 @@ STDMETHODIMP CDropSource::QueryContinueDrag(BOOL escapePressed, DWORD keyState) } if (needExtract) { - Result = Panel->CopyTo(Indices, Folder, - false, // moveMode, - false, // showMessages - &Messages); + CCopyToOptions options; + options.folder = Folder; + Result = Panel->CopyTo(options, Indices, &Messages); if (Result != S_OK || !Messages.IsEmpty()) return DRAGDROP_S_CANCEL; } @@ -224,19 +226,19 @@ STDMETHODIMP CDropSource::GiveFeedback(DWORD effect) static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &names) { - size_t totalLength = 1; + size_t totalLen = 1; #ifndef _UNICODE if (!g_IsNT) { AStringVector namesA; - int i; + unsigned i; for (i = 0; i < names.Size(); i++) namesA.Add(GetSystemString(names[i])); for (i = 0; i < names.Size(); i++) - totalLength += namesA[i].Length() + 1; + totalLen += namesA[i].Len() + 1; - if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(CHAR) + sizeof(DROPFILES))) + if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLen * sizeof(CHAR) + sizeof(DROPFILES))) return false; NMemory::CGlobalLock dropLock(hgDrop); @@ -252,21 +254,21 @@ static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &na for (i = 0; i < names.Size(); i++) { const AString &s = namesA[i]; - int fullLength = s.Length() + 1; + unsigned fullLen = s.Len() + 1; MyStringCopy(p, (const char *)s); - p += fullLength; - totalLength -= fullLength; + p += fullLen; + totalLen -= fullLen; } *p = 0; } else #endif { - int i; + unsigned i; for (i = 0; i < names.Size(); i++) - totalLength += names[i].Length() + 1; + totalLen += names[i].Len() + 1; - if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLength * sizeof(WCHAR) + sizeof(DROPFILES))) + if (!hgDrop.Alloc(GHND | GMEM_SHARE, totalLen * sizeof(WCHAR) + sizeof(DROPFILES))) return false; NMemory::CGlobalLock dropLock(hgDrop); @@ -282,10 +284,10 @@ static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &na for (i = 0; i < names.Size(); i++) { const UString &s = names[i]; - int fullLength = s.Length() + 1; + unsigned fullLen = s.Len() + 1; MyStringCopy(p, (const WCHAR *)s); - p += fullLength; - totalLength -= fullLength; + p += fullLen; + totalLen -= fullLen; } *p = 0; } @@ -294,7 +296,7 @@ static bool CopyNamesToHGlobal(NMemory::CGlobal &hgDrop, const UStringVector &na void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) { - CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); + CDisableTimerProcessing disableTimerProcessing2(*this); if (!DoesItSupportOperations()) return; CRecordVector indices; @@ -306,7 +308,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) // SaveSelectedState(selState); FString dirPrefix; - NFile::NDirectory::CTempDir tempDirectory; + CTempDir tempDirectory; bool isFSFolder = IsFSFolder(); if (isFSFolder) @@ -323,7 +325,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) { UStringVector names; - for (int i = 0; i < indices.Size(); i++) + FOR_VECTOR (i, indices) { UInt32 index = indices[i]; UString s; @@ -356,6 +358,7 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) HRESULT res = DoDragDrop(dataObject, dropSource, effectsOK, &effect); _panelCallback->DragEnd(); bool canceled = (res == DRAGDROP_S_CANCEL); + CDisableNotify disableNotify(*this); if (res == DRAGDROP_S_DROP) { res = dropSourceSpec->Result; @@ -363,10 +366,10 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) if (!dataObjectSpec->Path.IsEmpty()) { NFile::NName::NormalizeDirPathPrefix(dataObjectSpec->Path); - res = CopyTo(indices, dataObjectSpec->Path, - (effect == DROPEFFECT_MOVE),// dropSourceSpec->MoveMode, - false, // showErrorMessages - &dropSourceSpec->Messages); + CCopyToOptions options; + options.folder = dataObjectSpec->Path; + options.moveMode = (effect == DROPEFFECT_MOVE); + res = CopyTo(options, indices, &dropSourceSpec->Messages); } /* if (effect == DROPEFFECT_MOVE) @@ -386,8 +389,14 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */) messagesDialog.Messages = &dropSourceSpec->Messages; messagesDialog.Create((*this)); } + if (res != S_OK && res != E_ABORT) + { + // we restore Notify before MessageBoxError. So we will se files selection + disableNotify.Restore(); + // SetFocusToList(); MessageBoxError(res); + } if (res == S_OK && dropSourceSpec->Messages.IsEmpty() && !canceled) KillSelection(); } @@ -483,7 +492,7 @@ void CDropTarget::PositionCursor(POINTL ptl) int realIndex = m_Panel->GetRealItemIndex(index); if (realIndex == kParentIndex) return; - if (!m_Panel->IsItemFolder(realIndex)) + if (!m_Panel->IsItem_Folder(realIndex)) return; m_SubFolderIndex = realIndex; m_SubFolderName = m_Panel->GetItemName(m_SubFolderIndex); @@ -585,10 +594,9 @@ bool CDropTarget::IsItSameDrive() const if (m_SourcePaths.Size() == 0) return false; - for (int i = 0; i < m_SourcePaths.Size(); i++) + FOR_VECTOR (i, m_SourcePaths) { - const UString &path = m_SourcePaths[i]; - if (drive.CompareNoCase(path.Left(drive.Length())) != 0) + if (MyStringCompareNoCase_N(m_SourcePaths[i], drive, drive.Len()) != 0) return false; } return true; @@ -649,7 +657,7 @@ bool CDropTarget::SetPath(bool enablePath) const UString path; if (enablePath) path = GetTargetPath(); - size_t size = path.Length() + 1; + size_t size = path.Len() + 1; medium.hGlobal = GlobalAlloc(GHND | GMEM_SHARE, size * sizeof(wchar_t)); if (medium.hGlobal == 0) return false; @@ -752,23 +760,26 @@ void CPanel::CompressDropFiles(HDROP dr) static bool IsFolderInTemp(const FString &path) { FString tempPath; - if (!NFile::NDirectory::MyGetTempPath(tempPath)) + if (!MyGetTempPath(tempPath)) return false; if (tempPath.IsEmpty()) return false; - return (tempPath.CompareNoCase(path.Left(tempPath.Length())) == 0); + unsigned len = tempPath.Len(); + if (path.Len() < len) + return false; + return CompareFileNames(path.Left(len), tempPath) == 0; } static bool AreThereNamesFromTemp(const UStringVector &fileNames) { FString tempPathF; - if (!NFile::NDirectory::MyGetTempPath(tempPathF)) + if (!MyGetTempPath(tempPathF)) return false; UString tempPath = fs2us(tempPathF); if (tempPath.IsEmpty()) return false; - for (int i = 0; i < fileNames.Size(); i++) - if (tempPath.CompareNoCase(fileNames[i].Left(tempPath.Length())) == 0) + FOR_VECTOR (i, fileNames) + if (MyStringCompareNoCase_N(fileNames[i], tempPath, tempPath.Len()) == 0) return true; return false; } @@ -787,13 +798,15 @@ void CPanel::CompressDropFiles(const UStringVector &fileNames, const UString &fo if (folderPath2.IsEmpty()) { FString folderPath2F; - NFile::NDirectory::GetOnlyDirPrefix(us2fs(fileNames.Front()), folderPath2F); + GetOnlyDirPrefix(us2fs(fileNames.Front()), folderPath2F); folderPath2 = fs2us(folderPath2F); if (IsFolderInTemp(folderPath2F)) folderPath2 = ROOT_FS_FOLDER; } const UString archiveName = CreateArchiveName(fileNames.Front(), (fileNames.Size() > 1), false); - CompressFiles(folderPath2, archiveName, L"", fileNames, + CompressFiles(folderPath2, archiveName, L"", + true, // addExtension + fileNames, false, // email true, // showDialog AreThereNamesFromTemp(fileNames) // waitFinish diff --git a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp old mode 100755 new mode 100644 index 995124be..83993bb1 --- a/CPP/7zip/UI/FileManager/PanelFolderChange.cpp +++ b/CPP/7zip/UI/FileManager/PanelFolderChange.cpp @@ -2,11 +2,12 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" -#include "Common/Wildcard.h" +#include "../../../Common/StringConvert.h" +#include "../../../Common/Wildcard.h" -#include "Windows/FileName.h" -#include "Windows/PropVariant.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/FileDir.h" +#include "../../../Windows/PropVariant.h" #include "../../PropID.h" @@ -29,10 +30,10 @@ using namespace NFind; void CPanel::SetToRootFolder() { - _folder.Release(); + ReleaseFolder(); _library.Free(); CRootFolder *rootFolderSpec = new CRootFolder; - _folder = rootFolderSpec; + SetNewFolder(rootFolderSpec); rootFolderSpec->Init(); } @@ -40,12 +41,13 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo { archiveIsOpened = false; encrypted = false; - CDisableTimerProcessing disableTimerProcessing1(*this); + CDisableTimerProcessing disableTimerProcessing(*this); + CDisableNotify disableNotify(*this); if (_parentFolders.Size() > 0) { const UString &virtPath = _parentFolders.Back().VirtualPath; - if (fullPath.Left(virtPath.Length()) == virtPath) + if (fullPath.IsPrefixedBy(virtPath)) { for (;;) { @@ -53,11 +55,11 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo HRESULT res = _folder->BindToParentFolder(&newFolder); if (!newFolder || res != S_OK) break; - _folder = newFolder; + SetNewFolder(newFolder); } UStringVector parts; - SplitPathToParts(fullPath.Mid(virtPath.Length()), parts); - for (int i = 0; i < parts.Size(); i++) + SplitPathToParts(fullPath.Ptr(virtPath.Len()), parts); + FOR_VECTOR (i, parts) { const UString &s = parts[i]; if ((i == 0 || i == parts.Size() - 1) && s.IsEmpty()) @@ -66,7 +68,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo HRESULT res = _folder->BindToFolder(s, &newFolder); if (!newFolder || res != S_OK) break; - _folder = newFolder; + SetNewFolder(newFolder); } return S_OK; } @@ -85,9 +87,9 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo sysPath.Empty(); else { - if (reducedParts.Size() > 0 || pos < sysPath.Length() - 1) - reducedParts.Add(sysPath.Mid(pos + 1)); - sysPath = sysPath.Left(pos); + if (reducedParts.Size() > 0 || pos < (int)sysPath.Len() - 1) + reducedParts.Add(sysPath.Ptr(pos + 1)); + sysPath.DeleteFrom(pos); } } SetToRootFolder(); @@ -95,21 +97,21 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo if (sysPath.IsEmpty()) { if (_folder->BindToFolder(fullPath, &newFolder) == S_OK) - _folder = newFolder; + SetNewFolder(newFolder); } else if (fileInfo.IsDir()) { NName::NormalizeDirPathPrefix(sysPath); if (_folder->BindToFolder(sysPath, &newFolder) == S_OK) - _folder = newFolder; + SetNewFolder(newFolder); } else { FString dirPrefix, fileName; - NDirectory::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName); + NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName); if (_folder->BindToFolder(fs2us(dirPrefix), &newFolder) == S_OK) { - _folder = newFolder; + SetNewFolder(newFolder); LoadFullPath(); { HRESULT res = OpenItemAsArchive(fs2us(fileName), arcFormat, encrypted); @@ -130,7 +132,7 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo _folder->BindToFolder(reducedParts[i], &newFolder); if (!newFolder) break; - _folder = newFolder; + SetNewFolder(newFolder); } } } @@ -141,7 +143,8 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo HRESULT CPanel::BindToPathAndRefresh(const UString &path) { - CDisableTimerProcessing disableTimerProcessing1(*this); + CDisableTimerProcessing disableTimerProcessing(*this); + CDisableNotify disableNotify(*this); bool archiveIsOpened, encrypted; RINOK(BindToPath(path, UString(), archiveIsOpened, encrypted)); RefreshListCtrl(UString(), -1, true, UStringVector()); @@ -170,7 +173,7 @@ UString GetFolderPath(IFolderFolder *folder) void CPanel::LoadFullPath() { _currentFolderPrefix.Empty(); - for (int i = 0; i < _parentFolders.Size(); i++) + FOR_VECTOR (i, _parentFolders) { const CFolderLink &folderLink = _parentFolders[i]; _currentFolderPrefix += GetFolderPath(folderLink.ParentFolder); @@ -197,11 +200,12 @@ void CPanel::LoadFullPathAndShow() _headerComboBox.SetText(_currentFolderPrefix); #ifndef UNDER_CE + COMBOBOXEXITEM item; item.mask = 0; UString path = _currentFolderPrefix; - if (path.Length() > + if (path.Len() > #ifdef _WIN32 3 #else @@ -213,16 +217,15 @@ void CPanel::LoadFullPathAndShow() DWORD attrib = FILE_ATTRIBUTE_DIRECTORY; // GetRealIconIndex is slow for direct DVD/UDF path. So we use dummy path - UString excludePrefix = L"\\\\.\\"; - UString path2 = L"_TestFolder_"; - if (excludePrefix != path.Left(excludePrefix.Length())) + if (path.IsPrefixedBy(L"\\\\.\\")) + path = L"_TestFolder_"; + else { - path2 = path; - CFileInfo info; - if (info.Find(us2fs(path))) - attrib = info.Attrib; + CFileInfo fi; + if (fi.Find(us2fs(path))) + attrib = fi.Attrib; } - item.iImage = GetRealIconIndex(us2fs(path2), attrib); + item.iImage = GetRealIconIndex(us2fs(path), attrib); if (item.iImage >= 0) { @@ -231,6 +234,7 @@ void CPanel::LoadFullPathAndShow() } item.iItem = -1; _headerComboBox.SetItem(&item); + #endif RefreshTitle(); @@ -349,7 +353,7 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) ComboBoxPaths.Clear(); _headerComboBox.ResetContent(); - int i; + unsigned i; UStringVector pathParts; SplitPathToParts(_currentFolderPrefix, pathParts); @@ -386,7 +390,7 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) FString s = driveStrings[i]; ComboBoxPaths.Add(fs2us(s)); int iconIndex = GetRealIconIndex(s, 0); - if (s.Length() > 0 && s.Back() == FCHAR_PATH_SEPARATOR) + if (s.Len() > 0 && s.Back() == FCHAR_PATH_SEPARATOR) s.DeleteBack(); AddComboBoxItem(fs2us(s), iconIndex, 1, false); } @@ -436,10 +440,10 @@ bool CPanel::OnComboBoxCommand(UINT code, LPARAM /* param */, LRESULT &result) return false; } -bool CPanel::OnNotifyComboBox(LPNMHDR header, LRESULT &result) +bool CPanel::OnNotifyComboBox(LPNMHDR NON_CE_VAR(header), LRESULT & NON_CE_VAR(result)) { #ifndef UNDER_CE - switch(header->code) + switch (header->code) { case CBEN_BEGINEDIT: { @@ -467,9 +471,9 @@ void CPanel::FoldersHistory() { CListViewDialog listViewDialog; listViewDialog.DeleteIsAllowed = true; - listViewDialog.Title = LangString(IDS_FOLDERS_HISTORY, 0x03020260); + LangString(IDS_FOLDERS_HISTORY, listViewDialog.Title); _appState->FolderHistory.GetList(listViewDialog.Strings); - if (listViewDialog.Create(GetParent()) == IDCANCEL) + if (listViewDialog.Create(GetParent()) != IDOK) return; UString selectString; if (listViewDialog.StringsWereChanged) @@ -502,15 +506,16 @@ void CPanel::OpenParentFolder() { int pos = focucedName.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos >= 0) - focucedName = focucedName.Mid(pos + 1); + focucedName.DeleteFrontal(pos + 1); } } - CDisableTimerProcessing disableTimerProcessing1(*this); + CDisableTimerProcessing disableTimerProcessing(*this); + CDisableNotify disableNotify(*this); CMyComPtr newFolder; _folder->BindToParentFolder(&newFolder); if (newFolder) - _folder = newFolder; + SetNewFolder(newFolder); else { if (_parentFolders.IsEmpty()) @@ -521,10 +526,10 @@ void CPanel::OpenParentFolder() } else { - _folder.Release(); + ReleaseFolder(); _library.Free(); CFolderLink &link = _parentFolders.Back(); - _folder = link.ParentFolder; + SetNewFolder(link.ParentFolder); _library.Attach(link.Library.Detach()); focucedName = link.RelPath; if (_parentFolders.Size() > 1) @@ -543,29 +548,30 @@ void CPanel::OpenParentFolder() LoadFullPath(); // ::SetCurrentDirectory(::_currentFolderPrefix); RefreshListCtrl(focucedName, -1, true, selectedItems); - _listView.EnsureVisible(_listView.GetFocusedItem(), false); + // _listView.EnsureVisible(_listView.GetFocusedItem(), false); } void CPanel::CloseOpenFolders() { while (_parentFolders.Size() > 0) { - _folder.Release(); + ReleaseFolder(); _library.Free(); - _folder = _parentFolders.Back().ParentFolder; + SetNewFolder(_parentFolders.Back().ParentFolder); _library.Attach(_parentFolders.Back().Library.Detach()); if (_parentFolders.Size() > 1) OpenParentArchiveFolder(); _parentFolders.DeleteBack(); } _flatMode = _flatModeForDisk; - _folder.Release(); + ReleaseFolder(); _library.Free(); } void CPanel::OpenRootFolder() { - CDisableTimerProcessing disableTimerProcessing1(*this); + CDisableTimerProcessing disableTimerProcessing(*this); + CDisableNotify disableNotify(*this); _parentFolders.Clear(); SetToRootFolder(); RefreshListCtrl(UString(), -1, true, UStringVector()); @@ -585,11 +591,11 @@ void CPanel::OpenDrivesFolder() CloseOpenFolders(); #ifdef UNDER_CE NFsFolder::CFSFolder *folderSpec = new NFsFolder::CFSFolder; - _folder = folderSpec; + SetNewFolder(folderSpec); folderSpec->InitToRoot(); #else CFSDrives *folderSpec = new CFSDrives; - _folder = folderSpec; + SetNewFolder(folderSpec); folderSpec->Init(); #endif RefreshListCtrl(); @@ -606,9 +612,8 @@ void CPanel::OpenFolder(int index) _folder->BindToFolder(index, &newFolder); if (!newFolder) return; - _folder = newFolder; + SetNewFolder(newFolder); LoadFullPath(); - // ::SetCurrentDirectory(::_currentFolderPrefix); RefreshListCtrl(); _listView.SetItemState_Selected(_listView.GetFocusedItem()); _listView.EnsureVisible(_listView.GetFocusedItem(), false); diff --git a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp old mode 100755 new mode 100644 index 6c4309c6..39585cb2 --- a/CPP/7zip/UI/FileManager/PanelItemOpen.cpp +++ b/CPP/7zip/UI/FileManager/PanelItemOpen.cpp @@ -4,16 +4,16 @@ #include -#include "Common/AutoPtr.h" -#include "Common/StringConvert.h" +#include "../../../Common/AutoPtr.h" +#include "../../../Common/StringConvert.h" -#include "Windows/Error.h" -#include "Windows/FileDir.h" -#include "Windows/FileFind.h" -#include "Windows/FileName.h" -#include "Windows/Process.h" -#include "Windows/PropVariant.h" -#include "Windows/Thread.h" +#include "../../../Windows/ProcessUtils.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/PropVariant.h" +#include "../../../Windows/PropVariantConv.h" + +#include "../../Common/FileStreams.h" +#include "../../Common/StreamObjects.h" #include "../Common/ExtractingFilePath.h" @@ -30,7 +30,9 @@ using namespace NWindows; using namespace NSynchronization; using namespace NFile; -using namespace NDirectory; +using namespace NDir; + +extern UInt64 g_RAM_Size; #ifndef _UNICODE extern bool g_IsNT; @@ -85,7 +87,7 @@ public: void CloseAll() { - for (int i = 0; i < Handles.Size(); i++) + FOR_VECTOR (i, Handles) { HANDLE h = Handles[i]; if (h != NULL) @@ -129,7 +131,7 @@ public: for (;;) { - int i; + unsigned i; for (i = 0; i < ids.Size(); i++) { DWORD id = ids[i]; @@ -225,31 +227,33 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, _parentFolders.Add(folderLink); _parentFolders.Back().Library.Attach(_library.Detach()); - _folder.Release(); + ReleaseFolder(); _library.Free(); - _folder = newFolder; + SetNewFolder(newFolder); _library.Attach(library.Detach()); _flatMode = _flatModeForArc; CMyComPtr getFolderArcProps; _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps); + _thereAreDeletedItems = false; if (getFolderArcProps) { CMyComPtr arcProps; getFolderArcProps->GetFolderArcProps(&arcProps); if (arcProps) { + /* UString s; UInt32 numLevels; if (arcProps->GetArcNumLevels(&numLevels) != S_OK) numLevels = 0; - for (UInt32 level2 = 0; level2 < numLevels; level2++) + for (UInt32 level2 = 0; level2 <= numLevels; level2++) { - UInt32 level = numLevels - 1 - level2; - PROPID propIDs[] = { kpidError, kpidPath, kpidType } ; - UString values[3]; - for (Int32 i = 0; i < 3; i++) + UInt32 level = numLevels - level2; + PROPID propIDs[] = { kpidError, kpidPath, kpidType, kpidErrorType } ; + UString values[4]; + for (Int32 i = 0; i < 4; i++) { CMyComBSTR name; NCOM::CPropVariant prop; @@ -258,17 +262,39 @@ HRESULT CPanel::OpenItemAsArchive(IInStream *inStream, if (prop.vt != VT_EMPTY) values[i] = (prop.vt == VT_BSTR) ? prop.bstrVal : L"?"; } + UString s2; + if (!values[3].IsEmpty()) + { + s2 = L"Can not open the file as [" + values[3] + L"] archive"; + if (level2 != 0) + s2 += L"\nThe file is open as [" + values[2] + L"] archive"; + } if (!values[0].IsEmpty()) + { + if (!s2.IsEmpty()) + s2 += L"\n"; + s2 += L"["; + s2 += values[2]; + s2 += L"] Error: "; + s2 += values[0]; + } + if (!s2.IsEmpty()) { if (!s.IsEmpty()) s += L"--------------------\n"; - s += values[0]; s += L"\n\n["; - s += values[2]; s += L"] "; - s += values[1]; s += L"\n"; + s += values[1]; + s += L"\n"; + s += s2; } } + */ + /* if (!s.IsEmpty()) - MessageBox(s); + MessageBoxWarning(s); + else + */ + // after MessageBoxWarning it throws exception in nested archives in Debug Mode. why ?. + // MessageBoxWarning(L"test error"); } } @@ -288,15 +314,22 @@ HRESULT CPanel::OpenItemAsArchive(const UString &relPath, const UString &arcForm HRESULT CPanel::OpenItemAsArchive(int index) { CDisableTimerProcessing disableTimerProcessing1(*this); + CDisableNotify disableNotify(*this); bool encrypted; - RINOK(OpenItemAsArchive(GetItemRelPath(index), UString(), encrypted)); + HRESULT res = OpenItemAsArchive(GetItemRelPath(index), UString(), encrypted); + if (res != S_OK) + { + RefreshTitle(true); // in case of error we must refresh changed title of 7zFM + return res; + } RefreshListCtrl(); return S_OK; } HRESULT CPanel::OpenParentArchiveFolder() { - CDisableTimerProcessing disableTimerProcessing1(*this); + CDisableTimerProcessing disableTimerProcessing(*this); + CDisableNotify disableNotify(*this); if (_parentFolders.Size() < 2) return S_OK; const CFolderLink &folderLinkPrev = _parentFolders[_parentFolders.Size() - 2]; @@ -306,14 +339,14 @@ HRESULT CPanel::OpenParentArchiveFolder() { if (folderLink.WasChanged(newFileInfo)) { - UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, 0x03020280, folderLink.RelPath); - if (::MessageBoxW(HWND(*this), message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK) + UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, folderLink.RelPath); + if (::MessageBoxW((HWND)*this, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK) { - if (OnOpenItemChanged(folderLink.FileIndex, folderLink.FilePath, + if (OnOpenItemChanged(folderLink.FileIndex, fs2us(folderLink.FilePath), folderLinkPrev.UsePassword, folderLinkPrev.Password) != S_OK) { - ::MessageBoxW(HWND(*this), MyFormatNew(IDS_CANNOT_UPDATE_FILE, - 0x03020281, fs2us(folderLink.FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP); + ::MessageBoxW((HWND)*this, MyFormatNew(IDS_CANNOT_UPDATE_FILE, + fs2us(folderLink.FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP); return S_OK; } } @@ -346,17 +379,25 @@ static const char *kStartExtensions = static bool FindExt(const char *p, const UString &name) { - int extPos = name.ReverseFind('.'); - if (extPos < 0) + int dotPos = name.ReverseFind('.'); + if (dotPos < 0 || dotPos == (int)name.Len() - 1) return false; - UString ext = name.Mid(extPos + 1); - ext.MakeLower(); - AString ext2 = UnicodeStringToMultiByte(ext); - for (int i = 0; p[i] != 0;) + + AString s; + for (unsigned pos = dotPos + 1;; pos++) + { + wchar_t c = name[pos]; + if (c == 0) + break; + if (c >= 0x80) + return false; + s += (char)MyCharLower_Ascii((char)c); + } + for (unsigned i = 0; p[i] != 0;) { - int j; + unsigned j; for (j = i; p[j] != ' '; j++); - if (ext2.Length() == j - i && memcmp(p + i, (const char *)ext2, ext2.Length()) == 0) + if (s.Len() == j - i && memcmp(p + i, (const char *)s, s.Len()) == 0) return true; i = j + 1; } @@ -373,19 +414,19 @@ static UString GetQuotedString(const UString &s) return UString(L'\"') + s + UString(L'\"'); } -static HRESULT StartEditApplication(const UString &path, HWND window, CProcess &process) +static HRESULT StartEditApplication(const UString &path, bool useEditor, HWND window, CProcess &process) { UString command; - ReadRegEditor(command); + ReadRegEditor(useEditor, command); if (command.IsEmpty()) { #ifdef UNDER_CE command = L"\\Windows\\"; #else FString winDir; - if (!MyGetWindowsDirectory(winDir)) + if (!GetWindowsDir(winDir)) return 0; - NFile::NName::NormalizeDirPathPrefix(winDir); + NName::NormalizeDirPathPrefix(winDir); command = fs2us(winDir); #endif command += L"notepad.exe"; @@ -393,7 +434,7 @@ static HRESULT StartEditApplication(const UString &path, HWND window, CProcess & HRESULT res = process.Create(command, GetQuotedString(path), NULL); if (res != SZ_OK) - ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), L"7-Zip", MB_OK | MB_ICONSTOP); + ::MessageBoxW(window, LangString(IDS_CANNOT_START_EDITOR), L"7-Zip", MB_OK | MB_ICONSTOP); return res; } @@ -435,7 +476,7 @@ void CApp::DiffFiles() HRESULT res = MyCreateProcess(command, param); if (res == SZ_OK) return; - ::MessageBoxW(_window, LangString(IDS_CANNOT_START_EDITOR, 0x03020282), L"7-Zip", MB_OK | MB_ICONSTOP); + ::MessageBoxW(_window, LangString(IDS_CANNOT_START_EDITOR), L"7-Zip", MB_OK | MB_ICONSTOP); } #ifndef _UNICODE @@ -501,7 +542,7 @@ static HRESULT StartApplication(const UString &dir, const UString &path, HWND wi { case SE_ERR_NOASSOC: ::MessageBoxW(window, - NError::MyFormatMessageW(::GetLastError()), + NError::MyFormatMessage(::GetLastError()), // L"There is no application associated with the given file name extension", L"7-Zip", MB_OK | MB_ICONSTOP); } @@ -515,15 +556,15 @@ static void StartApplicationDontWait(const UString &dir, const UString &path, HW StartApplication(dir, path, window, process); } -void CPanel::EditItem(int index) +void CPanel::EditItem(int index, bool useEditor) { if (!_parentFolders.IsEmpty()) { - OpenItemInArchive(index, false, true, true); + OpenItemInArchive(index, false, true, true, useEditor); return; } CProcess process; - StartEditApplication(GetItemFullPath(index), (HWND)*this, process); + StartEditApplication(GetItemFullPath(index), useEditor, (HWND)*this, process); } void CPanel::OpenFolderExternal(int index) @@ -533,12 +574,12 @@ void CPanel::OpenFolderExternal(int index) if (index == kParentIndex) { int pos = fsPrefix.ReverseFind(WCHAR_PATH_SEPARATOR); - if (pos >= 0 && pos == fsPrefix.Length() - 1) + if (pos >= 0 && pos == (int)fsPrefix.Len() - 1) { UString s = fsPrefix.Left(pos); pos = s.ReverseFind(WCHAR_PATH_SEPARATOR); if (pos >= 0) - fsPrefix = s.Left(pos + 1); + fsPrefix.SetFrom(s, pos + 1); } name = fsPrefix; } @@ -549,24 +590,30 @@ void CPanel::OpenFolderExternal(int index) void CPanel::OpenItem(int index, bool tryInternal, bool tryExternal) { - CDisableTimerProcessing disableTimerProcessing1(*this); - if (!_parentFolders.IsEmpty()) + CDisableTimerProcessing disableTimerProcessing(*this); + UString name = GetItemRelPath(index); + if (IsNameVirus(name)) { - OpenItemInArchive(index, tryInternal, tryExternal, false); + MessageBoxErrorLang(IDS_VIRUS); return; } - UString name = GetItemRelPath(index); - if (IsNameVirus(name)) + + if (!_parentFolders.IsEmpty()) { - MessageBoxErrorLang(IDS_VIRUS, 0x03020284); + OpenItemInArchive(index, tryInternal, tryExternal, false, false); return; } + + CDisableNotify disableNotify(*this); UString prefix = GetFsPath(); UString fullPath = prefix + name; + if (tryInternal) if (!tryExternal || !DoItemAlwaysStart(name)) { HRESULT res = OpenItemAsArchive(index); + disableNotify.Restore(); // we must restore to allow text notification update + InvalidateList(); if (res == S_OK || res == E_ABORT) return; if (res != S_FALSE) @@ -606,7 +653,7 @@ HRESULT CPanel::OnOpenItemChanged(UInt32 index, const wchar_t *fullFilePath, CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return E_FAIL; } @@ -649,10 +696,12 @@ LRESULT CPanel::OnOpenItemChanged(LPARAM lParam) CSelectedState state; SaveSelectedState(state); - HRESULT result = OnOpenItemChanged(fileIndex, tpi.FilePath, tpi.UsePassword, tpi.Password); + CDisableNotify disableNotify(*this); // do we need it?? + + HRESULT result = OnOpenItemChanged(fileIndex, fs2us(tpi.FilePath), tpi.UsePassword, tpi.Password); + RefreshListCtrl(state); if (result != S_OK) return 0; - RefreshListCtrl(state); return 1; } @@ -678,7 +727,8 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param) { CRecordVector handles; CRecordVector indices; - for (int i = 0; i < processes.Handles.Size(); i++) + + FOR_VECTOR (i, processes.Handles) { if (processes.NeedWait[i]) { @@ -686,6 +736,7 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param) indices.Add(i); } } + if (handles.IsEmpty()) break; @@ -707,14 +758,13 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param) { if (tpi->WasChanged(newFileInfo)) { - UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, - 0x03020280, tpi->RelPath); + UString message = MyFormatNew(IDS_WANT_UPDATE_MODIFIED_FILE, tpi->RelPath); if (::MessageBoxW(g_HWND, message, L"7-Zip", MB_OKCANCEL | MB_ICONQUESTION) == IDOK) { if (SendMessage(tpi->Window, kOpenItemChanged, 0, (LONG_PTR)tpi) != 1) { ::MessageBoxW(g_HWND, MyFormatNew(IDS_CANNOT_UPDATE_FILE, - 0x03020281, fs2us(tpi->FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP); + fs2us(tpi->FilePath)), L"7-Zip", MB_OK | MB_ICONSTOP); return 0; } } @@ -724,21 +774,167 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param) return 0; } -void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode) +#if defined(_WIN32) && !defined(UNDER_CE) +static const FChar *k_ZoneId_StreamName = FTEXT(":Zone.Identifier"); +#endif + + +#ifndef UNDER_CE + +static void ReadZoneFile(CFSTR fileName, CByteBuffer &buf) +{ + buf.Free(); + NIO::CInFile file; + if (!file.Open(fileName)) + return; + UInt64 fileSize; + if (!file.GetLength(fileSize)) + return; + if (fileSize == 0 || fileSize >= ((UInt32)1 << 20)) + return; + buf.Alloc((size_t)fileSize); + UInt32 processed; + if (file.Read(buf, (UInt32)fileSize, processed) && processed == fileSize) + return; + buf.Free(); +} + +static bool WriteZoneFile(CFSTR fileName, const CByteBuffer &buf) +{ + NIO::COutFile file; + if (!file.Create(fileName, true)) + return false; + UInt32 processed; + if (!file.Write(buf, (UInt32)buf.Size(), processed)) + return false; + return processed == buf.Size(); +} + +#endif + +/* +class CBufSeqOutStream_WithFile: + public ISequentialOutStream, + public CMyUnknownImp +{ + Byte *_buffer; + size_t _size; + size_t _pos; + + + size_t _fileWritePos; + bool fileMode; +public: + + bool IsStreamInMem() const { return !fileMode; } + size_t GetMemStreamWrittenSize() const { return _pos; } + + // ISequentialOutStream *FileStream; + FString FilePath; + COutFileStream *outFileStreamSpec; + CMyComPtr outFileStream; + + CBufSeqOutStream_WithFile(): outFileStreamSpec(NULL) {} + + void Init(Byte *buffer, size_t size) + { + fileMode = false; + _buffer = buffer; + _pos = 0; + _size = size; + _fileWritePos = 0; + } + + HRESULT FlushToFile(); + size_t GetPos() const { return _pos; } + + MY_UNKNOWN_IMP + STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); +}; + +static const UInt32 kBlockSize = ((UInt32)1 << 31); + +STDMETHODIMP CBufSeqOutStream_WithFile::Write(const void *data, UInt32 size, UInt32 *processedSize) +{ + if (processedSize) + *processedSize = 0; + if (!fileMode) + { + if (_size - _pos >= size) + { + memcpy(_buffer + _pos, data, size); + _pos += size; + if (processedSize) + *processedSize = (UInt32)size; + return S_OK; + } + + fileMode = true; + } + RINOK(FlushToFile()); + return outFileStream->Write(data, size, processedSize); +} + +HRESULT CBufSeqOutStream_WithFile::FlushToFile() +{ + if (!outFileStream) + { + outFileStreamSpec = new COutFileStream; + outFileStream = outFileStreamSpec; + if (!outFileStreamSpec->Create(FilePath, false)) + { + outFileStream.Release(); + return E_FAIL; + // MessageBoxMyError(UString(L"Can't create file ") + fs2us(tempFilePath)); + } + } + while (_fileWritePos != _pos) + { + size_t cur = _pos - _fileWritePos; + UInt32 curSize = (cur < kBlockSize) ? (UInt32)cur : kBlockSize; + UInt32 processedSizeLoc = 0; + HRESULT res = outFileStream->Write(_buffer + _fileWritePos, curSize, &processedSizeLoc); + _fileWritePos += processedSizeLoc; + RINOK(res); + if (processedSizeLoc == 0) + return E_FAIL; + } + return S_OK; +} +*/ + +/* +static HRESULT GetTime(IFolderFolder *folder, UInt32 index, PROPID propID, FILETIME &filetime, bool &filetimeIsDefined) +{ + filetimeIsDefined = false; + NCOM::CPropVariant prop; + RINOK(folder->GetProperty(index, propID, &prop)); + if (prop.vt == VT_FILETIME) + { + filetime = prop.filetime; + filetimeIsDefined = (filetime.dwHighDateTime != 0 || filetime.dwLowDateTime != 0); + } + else if (prop.vt != VT_EMPTY) + return E_FAIL; + return S_OK; +} +*/ + +void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bool editMode, bool useEditor) { const UString name = GetItemName(index); const UString relPath = GetItemRelPath(index); if (IsNameVirus(name)) { - MessageBoxErrorLang(IDS_VIRUS, 0x03020284); + MessageBoxErrorLang(IDS_VIRUS); return; } CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } @@ -746,7 +942,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo UString fullVirtPath = _currentFolderPrefix + relPath; - NFile::NDirectory::CTempDir tempDirectory; + CTempDir tempDirectory; if (!tempDirectory.Create(kTempDirPrefix)) { MessageBoxLastError(); @@ -754,8 +950,8 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo } FString tempDir = tempDirectory.GetPath(); FString tempDirNorm = tempDir; - NFile::NName::NormalizeDirPathPrefix(tempDirNorm); - FString tempFilePath = tempDirNorm + us2fs(GetCorrectFsPath(name)); + NName::NormalizeDirPathPrefix(tempDirNorm); + const FString tempFilePath = tempDirNorm + us2fs(GetCorrectFsPath(name)); CTempFileInfo tempFileInfo; tempFileInfo.FileIndex = index; @@ -779,12 +975,20 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo if (subStream) { bool encrypted; - if (OpenItemAsArchive(subStream, tempFileInfo, fullVirtPath, UString(), encrypted) == S_OK) + HRESULT res = OpenItemAsArchive(subStream, tempFileInfo, fullVirtPath, UString(), encrypted); + if (res == S_OK) { tempDirectory.DisableDeleting(); RefreshListCtrl(); return; } + if (res == E_ABORT) + return; + if (res != S_FALSE) + { + // probably we must show some message here + // return; + } } } } @@ -805,7 +1009,55 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo password = fl.Password; } - HRESULT result = CopyTo(indices, fs2us(tempDirNorm), false, true, &messages, usePassword, password); + #if defined(_WIN32) && !defined(UNDER_CE) + CByteBuffer zoneBuf; + #ifndef _UNICODE + if (g_IsNT) + #endif + if (_parentFolders.Size() > 0) + { + const CFolderLink &fl = _parentFolders.Front(); + if (!fl.IsVirtual && !fl.FilePath.IsEmpty()) + ReadZoneFile(fl.FilePath + k_ZoneId_StreamName, zoneBuf); + } + #endif + + + CVirtFileSystem *virtFileSystemSpec = NULL; + CMyComPtr virtFileSystem; + + bool isAltStream = IsItem_AltStream(index); + + CCopyToOptions options; + options.includeAltStreams = false; + options.replaceAltStreamChars = isAltStream; + + if (tryAsArchive) + { + NCOM::CPropVariant prop; + _folder->GetProperty(index, kpidSize, &prop); + UInt64 fileLimit = g_RAM_Size / 4; + UInt64 fileSize = 0; + if (!ConvertPropVariantToUInt64(prop, fileSize)) + fileSize = fileLimit; + if (fileSize <= fileLimit && fileSize > 0) + { + options.streamMode = true; + virtFileSystemSpec = new CVirtFileSystem; + virtFileSystem = virtFileSystemSpec; + // we allow additional total size for small alt streams; + virtFileSystemSpec->MaxTotalAllocSize = fileSize + (1 << 10); + + virtFileSystemSpec->DirPrefix = tempDirNorm; + virtFileSystemSpec->Init(); + options.VirtFileSystem = virtFileSystem; + options.VirtFileSystemSpec = virtFileSystemSpec; + } + } + + options.folder = fs2us(tempDirNorm); + options.showErrorMessages = true; + HRESULT result = CopyTo(options, indices, &messages, usePassword, password); if (_parentFolders.Size() > 0) { @@ -823,6 +1075,39 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo return; } + if (options.VirtFileSystem) + { + if (virtFileSystemSpec->IsStreamInMem()) + { + const CVirtFile &file = virtFileSystemSpec->Files[0]; + + size_t streamSize = (size_t)file.Size; + CBufInStream *bufInStreamSpec = new CBufInStream; + CMyComPtr bufInStream = bufInStreamSpec; + bufInStreamSpec->Init(file.Data, streamSize, virtFileSystem); + bool encrypted; + if (OpenItemAsArchive(bufInStream, tempFileInfo, fullVirtPath, UString(), encrypted) == S_OK) + { + tempDirectory.DisableDeleting(); + RefreshListCtrl(); + return; + } + if (virtFileSystemSpec->FlushToDisk(true) != S_OK) + return; + } + } + + + #if defined(_WIN32) && !defined(UNDER_CE) + if (zoneBuf.Size() != 0) + { + if (NFind::DoesFileExist(tempFilePath)) + { + WriteZoneFile(tempFilePath + k_ZoneId_StreamName, zoneBuf); + } + } + #endif + if (tryAsArchive) { @@ -854,7 +1139,7 @@ void CPanel::OpenItemInArchive(int index, bool tryInternal, bool tryExternal, bo CProcess process; HRESULT res; if (editMode) - res = StartEditApplication(fs2us(tempFilePath), (HWND)*this, process); + res = StartEditApplication(fs2us(tempFilePath), useEditor, (HWND)*this, process); else res = StartApplication(fs2us(tempDirNorm), fs2us(tempFilePath), (HWND)*this, process); @@ -887,7 +1172,7 @@ static bool CheckDeleteItem(UINT64 currentFileTime, UINT64 folderFileTime) void DeleteOldTempFiles() { UString tempPath; - if(!NFile::NDirectory::MyGetTempPath(tempPath)) + if(!MyGetTempPath(tempPath)) throw 1; UINT64 currentFileTime; diff --git a/CPP/7zip/UI/FileManager/PanelItems.cpp b/CPP/7zip/UI/FileManager/PanelItems.cpp old mode 100755 new mode 100644 index daa150c6..b8cc6269 --- a/CPP/7zip/UI/FileManager/PanelItems.cpp +++ b/CPP/7zip/UI/FileManager/PanelItems.cpp @@ -4,11 +4,9 @@ #include "../../../../C/Sort.h" -#include "Common/StringConvert.h" - -#include "Windows/Menu.h" -#include "Windows/PropVariant.h" -#include "Windows/PropVariantConversions.h" +#include "../../../Windows/Menu.h" +#include "../../../Windows/PropVariant.h" +#include "../../../Windows/PropVariantConv.h" #include "../../PropID.h" @@ -21,16 +19,44 @@ using namespace NWindows; +static bool GetColumnVisible(PROPID propID, bool isFsFolder) +{ + if (isFsFolder) + { + switch (propID) + { + case kpidATime: + case kpidAttrib: + case kpidPackSize: + case kpidINode: + case kpidLinks: + case kpidNtReparse: + return false; + } + } + return true; +} + +static int GetColumnWidth(PROPID propID, VARTYPE /* varType */) +{ + switch (propID) + { + case kpidName: return 160; + } + return 100; +} + static int GetColumnAlign(PROPID propID, VARTYPE varType) { - switch(propID) + switch (propID) { case kpidCTime: case kpidATime: case kpidMTime: return LVCFMT_LEFT; } - switch(varType) + + switch (varType) { case VT_UI1: case VT_I2: @@ -65,50 +91,82 @@ HRESULT CPanel::InitColumns() ReadListViewInfo(); - PROPID sortID; /* if (_listViewInfo.SortIndex >= 0) sortID = _listViewInfo.Columns[_listViewInfo.SortIndex].PropID; */ - sortID = _listViewInfo.SortID; + sortID = _listViewInfo.SortID; _ascending = _listViewInfo.Ascending; _properties.Clear(); _needSaveInfo = true; + bool isFsFolder = IsFSFolder(); - UInt32 numProperties; - _folder->GetNumberOfProperties(&numProperties); - int i; - for (i = 0; i < (int)numProperties; i++) { - CMyComBSTR name; - PROPID propID; - VARTYPE varType; - - RINOK(_folder->GetPropertyInfo(i, &name, &propID, &varType)); - - if (propID == kpidIsDir) - continue; + UInt32 numProps; + _folder->GetNumberOfProperties(&numProps); + + for (UInt32 i = 0; i < numProps; i++) + { + CMyComBSTR name; + PROPID propID; + VARTYPE varType; + HRESULT res = _folder->GetPropertyInfo(i, &name, &propID, &varType); + + if (res != S_OK) + { + /* We can return ERROR, but in that case, other code will not be called, + and user can see empty window without error message. So we just ignore that field */ + continue; + } + if (propID == kpidIsDir) + continue; + CItemProperty prop; + prop.Type = varType; + prop.ID = propID; + prop.Name = GetNameOfProperty(propID, name); + prop.Order = -1; + prop.IsVisible = GetColumnVisible(propID, isFsFolder); + prop.Width = GetColumnWidth(propID, varType); + prop.IsRawProp = false; + _properties.Add(prop); + } + } - CItemProperty prop; - prop.Type = varType; - prop.ID = propID; - prop.Name = GetNameOfProperty(propID, name); - prop.Order = -1; - prop.IsVisible = true; - prop.Width = 100; - _properties.Add(prop); + if (_folderRawProps) + { + UInt32 numProps; + _folderRawProps->GetNumRawProps(&numProps); + for (UInt32 i = 0; i < numProps; i++) + { + CMyComBSTR name; + PROPID propID; + RINOK(_folderRawProps->GetRawPropInfo(i, &name, &propID)); + + CItemProperty prop; + prop.Type = VT_EMPTY; + prop.ID = propID; + prop.Name = GetNameOfProperty(propID, name); + prop.Order = -1; + prop.IsVisible = GetColumnVisible(propID, isFsFolder); + prop.Width = GetColumnWidth(propID, VT_BSTR);; + prop.IsRawProp = true; + _properties.Add(prop); + } } + // InitColumns2(sortID); for (;;) if (!_listView.DeleteColumn(0)) break; - int order = 0; + unsigned order = 0; + unsigned i; + for (i = 0; i < _listViewInfo.Columns.Size(); i++) { const CColumnInfo &columnInfo = _listViewInfo.Columns[i]; @@ -123,6 +181,7 @@ HRESULT CPanel::InitColumns() continue; } } + for (i = 0; i < _properties.Size(); i++) { CItemProperty &item = _properties[i]; @@ -180,13 +239,11 @@ int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData); void CPanel::GetSelectedNames(UStringVector &selectedNames) { - selectedNames.Clear(); - CRecordVector indices; GetSelectedItemsIndices(indices); - selectedNames.Reserve(indices.Size()); - for (int i = 0; i < indices.Size(); i++) - selectedNames.Add(GetItemRelPath(indices[i])); + selectedNames.ClearAndReserve(indices.Size()); + FOR_VECTOR (i, indices) + selectedNames.AddInReserved(GetItemRelPath(indices[i])); /* for (int i = 0; i < _listView.GetItemCount(); i++) @@ -196,7 +253,7 @@ void CPanel::GetSelectedNames(UStringVector &selectedNames) LVITEMW item; item.iItem = i; item.pszText = name; - item.cchTextMax = kSize; + item.cchTextMax = kSize; item.iSubItem = 0; item.mask = LVIF_TEXT | LVIF_PARAM; if (!_listView.GetItem(&item)) @@ -228,7 +285,7 @@ void CPanel::SaveSelectedState(CSelectedState &s) LVITEMW item; item.iItem = focusedItem; item.pszText = name; - item.cchTextMax = kSize; + item.cchTextMax = kSize; item.iSubItem = 0; item.mask = LVIF_TEXT; if (_listView.GetItem(&item)) @@ -276,6 +333,7 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool // OutputDebugStringA("=======\n"); // OutputDebugStringA("s1 \n"); CDisableTimerProcessing timerProcessing(*this); + CDisableNotify disableNotify(*this); if (focusedPos < 0) focusedPos = 0; @@ -286,7 +344,14 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool LVITEMW item; ZeroMemory(&item, sizeof(item)); + // DWORD tickCount0 = GetTickCount(); + _enableItemChangeNotify = false; _listView.DeleteAllItems(); + _enableItemChangeNotify = true; + + + int listViewItemCount = 0; + _selectedStatusVector.Clear(); // _realIndices.Clear(); _startGroupSelect = 0; @@ -294,7 +359,6 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool _selectionIsDefined = false; // m_Files.Clear(); - // _folder.Release(); if (!_folder) { @@ -304,12 +368,25 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool _headerToolBar.EnableButton(kParentFolderID, !IsRootFolder()); - CMyComPtr folderSetFlatMode; - _folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode); - if (folderSetFlatMode) - folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode)); + { + CMyComPtr folderSetFlatMode; + _folder.QueryInterface(IID_IFolderSetFlatMode, &folderSetFlatMode); + if (folderSetFlatMode) + folderSetFlatMode->SetFlatMode(BoolToInt(_flatMode)); + } + /* + { + CMyComPtr setShow; + _folder.QueryInterface(IID_IFolderSetShowNtfsStreamsMode, &setShow); + if (setShow) + setShow->SetShowNtfsStreamsMode(BoolToInt(_showNtfsStrems_Mode)); + } + */ + + // DWORD tickCount1 = GetTickCount(); RINOK(_folder->LoadItems()); + // DWORD tickCount2 = GetTickCount(); RINOK(InitColumns()); // OutputDebugString(TEXT("Start Dir\n")); @@ -320,18 +397,40 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool _listView.SetItemCount(numItems + (showDots ? 1 : 0)); - _selectedStatusVector.Reserve(numItems); + _selectedStatusVector.ClearAndReserve(numItems); int cursorIndex = -1; CMyComPtr folderGetSystemIconIndex; if (!IsFSFolder() || _showRealFileIcons) _folder.QueryInterface(IID_IFolderGetSystemIconIndex, &folderGetSystemIconIndex); + if (!IsFSFolder()) + { + CMyComPtr getFolderArcProps; + _folder.QueryInterface(IID_IGetFolderArcProps, &getFolderArcProps); + _thereAreDeletedItems = false; + if (getFolderArcProps) + { + CMyComPtr arcProps; + getFolderArcProps->GetFolderArcProps(&arcProps); + if (arcProps) + { + UInt32 numLevels; + if (arcProps->GetArcNumLevels(&numLevels) != S_OK) + numLevels = 0; + NCOM::CPropVariant prop; + if (arcProps->GetArcProp(numLevels - 1, kpidIsDeleted, &prop) == S_OK) + if (prop.vt == VT_BOOL && VARIANT_BOOLToBool(prop.boolVal)) + _thereAreDeletedItems = true; + } + } + } + if (showDots) { UString itemName = L".."; - item.iItem = _listView.GetItemCount(); - if (itemName.CompareNoCase(focusedName) == 0) + item.iItem = listViewItemCount; + if (itemName == focusedName) cursorIndex = item.iItem; item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; int subItem = 0; @@ -344,20 +443,59 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool item.iImage = 0; if (_listView.InsertItem(&item) == -1) return E_FAIL; + listViewItemCount++; } // OutputDebugStringA("S1\n"); + UString correctedName; + UString itemName; + UString relPath; for (UInt32 i = 0; i < numItems; i++) { - UString itemName = GetItemName(i); - const UString relPath = GetItemRelPath(i); - if (relPath.CompareNoCase(focusedName) == 0) - cursorIndex = _listView.GetItemCount(); + const wchar_t *name = NULL; + unsigned nameLen = 0; + if (_folderGetItemName) + _folderGetItemName->GetItemName(i, &name, &nameLen); + if (name == NULL) + { + GetItemNameFast(i, itemName); + name = itemName; + nameLen = itemName.Len(); + } bool selected = false; - if (selectedNames.FindInSorted(relPath) >= 0) - selected = true; - _selectedStatusVector.Add(selected); + if (!focusedName.IsEmpty() || !selectedNames.IsEmpty()) + { + relPath.Empty(); + + // relPath += GetItemPrefix(i); + // change it (_flatMode) + if (i != kParentIndex && _flatMode) + { + const wchar_t *prefix = NULL; + if (_folderGetItemName) + { + unsigned prefixLen = 0; + _folderGetItemName->GetItemPrefix(i, &prefix, &prefixLen); + if (prefix) + relPath += prefix; + } + if (!prefix) + { + NCOM::CPropVariant prop; + if (_folder->GetProperty(i, kpidPrefix, &prop) != S_OK) + throw 2723400; + if (prop.vt == VT_BSTR) + relPath += prop.bstrVal; + } + } + relPath += name; + if (relPath == focusedName) + cursorIndex = listViewItemCount; + if (selectedNames.FindInSorted(relPath) >= 0) + selected = true; + } + _selectedStatusVector.AddInReserved(selected); item.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; @@ -369,21 +507,34 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool } int subItem = 0; - item.iItem = _listView.GetItemCount(); + item.iItem = listViewItemCount; item.iSubItem = subItem++; item.lParam = i; - UString correctedName; - if (itemName.Find(L" ") >= 0) + /* + int finish = nameLen - 4; + int j; + for (j = 0; j < finish; j++) { + if (name[j ] == ' ' && + name[j + 1] == ' ' && + name[j + 2] == ' ' && + name[j + 3] == ' ' && + name[j + 4] == ' ') + break; + } + if (j < finish) + { + correctedName.Empty(); + correctedName = L"virus"; int pos = 0; for (;;) { int posNew = itemName.Find(L" ", pos); if (posNew < 0) { - correctedName += itemName.Mid(pos); + correctedName += itemName.Ptr(pos); break; } correctedName += itemName.Mid(pos, posNew - pos); @@ -394,18 +545,28 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool item.pszText = const_cast((const wchar_t *)correctedName); } else - item.pszText = const_cast((const wchar_t *)itemName); + */ + { + // item.pszText = const_cast((const wchar_t *)name); + item.pszText = LPSTR_TEXTCALLBACKW; + /* LPSTR_TEXTCALLBACKW works, but in some cases there are problems, + since we block notify handler. */ + } + UInt32 attrib = 0; + // for (int yyy = 0; yyy < 6000000; yyy++) { NCOM::CPropVariant prop; RINOK(_folder->GetProperty(i, kpidAttrib, &prop)); - UInt32 attrib = 0; if (prop.vt == VT_UI4) + { + // char s[256]; sprintf(s, "attrib = %7x", attrib); OutputDebugStringA(s); attrib = prop.ulVal; - else if (IsItemFolder(i)) + } + else if (IsItem_Folder(i)) attrib |= FILE_ATTRIBUTE_DIRECTORY; + // } - bool defined = false; - + bool defined = false; if (folderGetSystemIconIndex) { folderGetSystemIconIndex->GetSystemIconIndex(i, &item.iImage); @@ -416,25 +577,29 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool if (_currentFolderPrefix.IsEmpty()) { int iconIndexTemp; - GetRealIconIndex(us2fs(itemName) + FCHAR_PATH_SEPARATOR, attrib, iconIndexTemp); + GetRealIconIndex(us2fs((UString)name) + FCHAR_PATH_SEPARATOR, attrib, iconIndexTemp); item.iImage = iconIndexTemp; } else { - item.iImage = _extToIconMap.GetIconIndex(attrib, itemName); + item.iImage = _extToIconMap.GetIconIndex(attrib, name); } } if (item.iImage < 0) item.iImage = 0; if (_listView.InsertItem(&item) == -1) - return E_FAIL; // error + return E_FAIL; + listViewItemCount++; } // OutputDebugStringA("End2\n"); if (_listView.GetItemCount() > 0 && cursorIndex >= 0) SetFocusedSelectedItem(cursorIndex, selectFocused); + // DWORD tickCount3 = GetTickCount(); + SetSortRawStatus(); _listView.SortItems(CompareItems, (LPARAM)this); + // DWORD tickCount4 = GetTickCount(); if (cursorIndex < 0 && _listView.GetItemCount() > 0) { if (focusedPos >= _listView.GetItemCount()) @@ -443,14 +608,45 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool SetFocusedSelectedItem(focusedPos, showDots); } // m_RedrawEnabled = true; + // DWORD tickCount5 = GetTickCount(); _listView.EnsureVisible(_listView.GetFocusedItem(), false); + // DWORD tickCount6 = GetTickCount(); + + disableNotify.SetMemMode_Enable(); + disableNotify.Restore(); _listView.SetRedraw(true); + // DWORD tickCount7 = GetTickCount(); _listView.InvalidateRect(NULL, true); + // DWORD tickCount8 = GetTickCount(); // OutputDebugStringA("End1\n"); /* _listView.UpdateWindow(); */ Refresh_StatusBar(); + // DWORD tickCount9 = GetTickCount(); + /* + char s[256]; + sprintf(s, + // "attribMap = %5d, extMap = %5d, " + "delete = %5d, load = %5d, list = %5d, sort = %5d, end = %5d", + // _extToIconMap._attribMap.Size(), + // _extToIconMap._extMap.Size(), + tickCount1 - tickCount0, + tickCount2 - tickCount1, + tickCount3 - tickCount2, + tickCount4 - tickCount3, + tickCount5 - tickCount4 + ); + sprintf(s, + "5 = %5d, 6 = %5d, 7 = %5d, 8 = %5d, 9 = %5d", + tickCount5 - tickCount4, + tickCount6 - tickCount5, + tickCount7 - tickCount6, + tickCount8 - tickCount7, + tickCount9 - tickCount8 + ); + OutputDebugStringA(s); + */ return S_OK; } @@ -466,10 +662,10 @@ void CPanel::GetSelectedItemsIndices(CRecordVector &indices) const indices.Add(param); } */ - for (int i = 0; i < _selectedStatusVector.Size(); i++) + FOR_VECTOR (i, _selectedStatusVector) if (_selectedStatusVector[i]) indices.Add(i); - HeapSort(&indices.Front(), indices.Size()); + // HeapSort(&indices.Front(), indices.Size()); } void CPanel::GetOperatedItemIndices(CRecordVector &indices) const @@ -528,16 +724,45 @@ void CPanel::GetOperatedListViewIndices(CRecordVector &indices) const } */ -void CPanel::EditItem() +void CPanel::EditItem(bool useEditor) { + if (!useEditor) + { + CMyComPtr calcItemFullSize; + _folder.QueryInterface(IID_IFolderCalcItemFullSize, &calcItemFullSize); + if (calcItemFullSize) + { + bool needRefresh = false; + CRecordVector indices; + GetOperatedItemIndices(indices); + FOR_VECTOR (i, indices) + { + UInt32 index = indices[i]; + if (IsItem_Folder(index)) + { + calcItemFullSize->CalcItemFullSize(index, NULL); + needRefresh = true; + } + } + if (needRefresh) + { + // _listView.RedrawItem(0); + // _listView.RedrawAllItems(); + InvalidateList(); + return; + } + } + } + + int focusedItem = _listView.GetFocusedItem(); if (focusedItem < 0) return; int realIndex = GetRealItemIndex(focusedItem); if (realIndex == kParentIndex) return; - if (!IsItemFolder(realIndex)) - EditItem(realIndex); + if (!IsItem_Folder(realIndex)) + EditItem(realIndex, useEditor); } void CPanel::OpenFocusedItemAsInternal() @@ -546,7 +771,7 @@ void CPanel::OpenFocusedItemAsInternal() if (focusedItem < 0) return; int realIndex = GetRealItemIndex(focusedItem); - if (IsItemFolder(realIndex)) + if (IsItem_Folder(realIndex)) OpenFolder(realIndex); else OpenItem(realIndex, true, false); @@ -558,7 +783,7 @@ void CPanel::OpenSelectedItems(bool tryInternal) GetOperatedItemIndices(indices); if (indices.Size() > 20) { - MessageBoxErrorLang(IDS_TOO_MANY_ITEMS, 0x02000606); + MessageBoxErrorLang(IDS_TOO_MANY_ITEMS); return; } @@ -571,11 +796,11 @@ void CPanel::OpenSelectedItems(bool tryInternal) } bool dirIsStarted = false; - for (int i = 0; i < indices.Size(); i++) + FOR_VECTOR (i, indices) { UInt32 index = indices[i]; // CFileInfo &aFile = m_Files[index]; - if (IsItemFolder(index)) + if (IsItem_Folder(index)) { if (!dirIsStarted) { @@ -606,6 +831,22 @@ UString CPanel::GetItemName(int itemIndex) const return prop.bstrVal; } +void CPanel::GetItemNameFast(int itemIndex, UString &s) const +{ + if (itemIndex == kParentIndex) + { + s = L".."; + return; + } + NCOM::CPropVariant prop; + if (_folder->GetProperty(itemIndex, kpidName, &prop) != S_OK) + throw 2723400; + if (prop.vt != VT_BSTR) + throw 2723401; + s.Empty(); + s += prop.bstrVal; +} + UString CPanel::GetItemPrefix(int itemIndex) const { if (itemIndex == kParentIndex) @@ -629,42 +870,64 @@ UString CPanel::GetItemFullPath(int itemIndex) const return _currentFolderPrefix + GetItemRelPath(itemIndex); } -bool CPanel::IsItemFolder(int itemIndex) const +bool CPanel::GetItem_BoolProp(UInt32 itemIndex, PROPID propID) const { - if (itemIndex == kParentIndex) - return true; NCOM::CPropVariant prop; - if (_folder->GetProperty(itemIndex, kpidIsDir, &prop) != S_OK) + if (_folder->GetProperty(itemIndex, propID, &prop) != S_OK) throw 2723400; if (prop.vt == VT_BOOL) return VARIANT_BOOLToBool(prop.boolVal); if (prop.vt == VT_EMPTY) return false; - return false; + throw 2723401; +} + +bool CPanel::IsItem_Deleted(int itemIndex) const +{ + if (itemIndex == kParentIndex) + return false; + return GetItem_BoolProp(itemIndex, kpidIsDeleted); +} + +bool CPanel::IsItem_Folder(int itemIndex) const +{ + if (itemIndex == kParentIndex) + return true; + return GetItem_BoolProp(itemIndex, kpidIsDir); +} + +bool CPanel::IsItem_AltStream(int itemIndex) const +{ + if (itemIndex == kParentIndex) + return false; + return GetItem_BoolProp(itemIndex, kpidIsAltStream); } -UINT64 CPanel::GetItemSize(int itemIndex) const +UInt64 CPanel::GetItemSize(int itemIndex) const { if (itemIndex == kParentIndex) return 0; + if (_folderGetItemName) + return _folderGetItemName->GetItemSize(itemIndex); NCOM::CPropVariant prop; if (_folder->GetProperty(itemIndex, kpidSize, &prop) != S_OK) throw 2723400; - if (prop.vt == VT_EMPTY) - return 0; - return ConvertPropVariantToUInt64(prop); + UInt64 val = 0; + if (ConvertPropVariantToUInt64(prop, val)) + return val; + return 0; } void CPanel::ReadListViewInfo() { _typeIDString = GetFolderTypeID(); if (!_typeIDString.IsEmpty()) - ::ReadListViewInfo(_typeIDString, _listViewInfo); + _listViewInfo.Read(_typeIDString); } void CPanel::SaveListViewInfo() { - int i; + unsigned i; for (i = 0; i < _visibleProperties.Size(); i++) { CItemProperty &prop = _visibleProperties[i]; @@ -704,13 +967,11 @@ void CPanel::SaveListViewInfo() } } - // viewInfo.SortIndex = viewInfo.FindColumnWithID(sortPropID); viewInfo.SortID = sortPropID; - viewInfo.Ascending = _ascending; if (!_listViewInfo.IsEqual(viewInfo)) { - ::SaveListViewInfo(_typeIDString, viewInfo); + viewInfo.Save(_typeIDString); _listViewInfo = viewInfo; } } @@ -729,14 +990,13 @@ bool CPanel::OnRightClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActiveate, LRESULT & void CPanel::ShowColumnsContextMenu(int x, int y) { - CMenu menu; CMenuDestroyer menuDestroyer(menu); menu.CreatePopup(); const int kCommandStart = 100; - for (int i = 0; i < _properties.Size(); i++) + FOR_VECTOR (i, _properties) { const CItemProperty &prop = _properties[i]; UINT flags = MF_STRING; @@ -746,8 +1006,10 @@ void CPanel::ShowColumnsContextMenu(int x, int y) flags |= MF_GRAYED; menu.AppendItem(flags, kCommandStart + i, prop.Name); } + int menuResult = menu.Track(TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, x, y, _listView); - if (menuResult >= kCommandStart && menuResult <= kCommandStart + _properties.Size()) + + if (menuResult >= kCommandStart && menuResult <= kCommandStart + (int)_properties.Size()) { int index = menuResult - kCommandStart; CItemProperty &prop = _properties[index]; @@ -793,6 +1055,8 @@ void CPanel::OnTimer() { if (!_processTimer) return; + if (!AutoRefresh_Mode) + return; CMyComPtr folderWasChanged; if (_folder.QueryInterface(IID_IFolderWasChanged, &folderWasChanged) != S_OK) return; diff --git a/CPP/7zip/UI/FileManager/PanelKey.cpp b/CPP/7zip/UI/FileManager/PanelKey.cpp old mode 100755 new mode 100644 index 8e3eaaa1..db8e3311 --- a/CPP/7zip/UI/FileManager/PanelKey.cpp +++ b/CPP/7zip/UI/FileManager/PanelKey.cpp @@ -8,6 +8,8 @@ #include "../../PropID.h" #include "App.h" +using namespace NWindows; + // static LPCWSTR kHelpTopic = L"FM/index.htm"; struct CVKeyPropIDPair @@ -27,7 +29,7 @@ static CVKeyPropIDPair g_VKeyPropIDPairs[] = static int FindVKeyPropIDPair(WORD vKey) { - for (int i = 0; i < sizeof(g_VKeyPropIDPairs) / sizeof(g_VKeyPropIDPairs[0]); i++) + for (int i = 0; i < ARRAY_SIZE(g_VKeyPropIDPairs); i++) if (g_VKeyPropIDPairs[i].VKey == vKey) return i; return -1; @@ -41,11 +43,11 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) _panelCallback->OnTab(); return false; } - bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0; - bool rightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0; - bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; + bool alt = IsKeyDown(VK_MENU); + bool ctrl = IsKeyDown(VK_CONTROL); + // bool leftCtrl = IsKeyDown(VK_LCONTROL); + bool rightCtrl = IsKeyDown(VK_RCONTROL); + bool shift = IsKeyDown(VK_SHIFT); result = 0; if (keyDownInfo->wVKey >= '0' && keyDownInfo->wVKey <= '9' && @@ -107,11 +109,20 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) } break; } + case VK_F3: + { + if (!alt && !ctrl && !shift) + { + EditItem(false); + return true; + } + break; + } case VK_F4: { if (!alt && !ctrl && !shift) { - EditItem(); + EditItem(true); return true; } if (!alt && !ctrl && shift) @@ -139,17 +150,18 @@ bool CPanel::OnKeyDown(LPNMLVKEYDOWN keyDownInfo, LRESULT &result) } break; } - /* case VK_F7: { if (!alt && !ctrl && !shift) { + /* we can process F7 via menu ACCELERATOR. + But menu loading can be slow in case of UNC paths and system menu. + So we use don't use ACCELERATOR */ CreateFolder(); return true; } break; } - */ case VK_DELETE: { DeleteItems(!shift); diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp old mode 100755 new mode 100644 index f28311a4..7be6aa62 --- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp +++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp @@ -4,79 +4,76 @@ #include "resource.h" -#include "Common/IntToString.h" -#include "Common/StringConvert.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/StringConvert.h" -#include "Windows/PropVariant.h" -#include "Windows/PropVariantConversions.h" +#include "../../../Windows/PropVariant.h" +#include "../../../Windows/PropVariantConv.h" #include "../Common/PropIDUtils.h" #include "../../PropID.h" +#include "App.h" #include "Panel.h" #include "FormatUtils.h" using namespace NWindows; -/* -static UString ConvertSizeToStringShort(UInt64 value) +static void ConvertSizeToString(UInt64 value, wchar_t *dest) { - wchar_t s[32]; - wchar_t c, c2 = L'B'; - if (value < (UInt64)10000) - { - c = L'B'; - c2 = L'\0'; - } - else if (value < ((UInt64)10000 << 10)) - { - value >>= 10; - c = L'K'; - } - else if (value < ((UInt64)10000 << 20)) + char s[32]; + ConvertUInt64ToString(value, s); + unsigned i = MyStringLen(s); + unsigned pos = ARRAY_SIZE(s); + s[--pos] = 0; + while (i > 3) { - value >>= 20; - c = L'M'; + s[--pos] = s[--i]; + s[--pos] = s[--i]; + s[--pos] = s[--i]; + s[--pos] = L' '; } - else + while (i > 0) + s[--pos] = s[--i]; + + for (;;) { - value >>= 30; - c = L'G'; + char c = s[pos++]; + *dest++ = (unsigned char)c; + if (c == 0) + break; } - ConvertUInt64ToString(value, s); - int p = MyStringLen(s); - s[p++] = L' '; - s[p++] = c; - s[p++] = c2; - s[p++] = L'\0'; - return s; } -*/ UString ConvertSizeToString(UInt64 value) { wchar_t s[32]; - ConvertUInt64ToString(value, s); - int i = MyStringLen(s); - int pos = sizeof(s) / sizeof(s[0]); - s[--pos] = L'\0'; - while (i > 3) + ConvertSizeToString(value, s); + return s; +} + +static inline char GetHex(Byte value) +{ + return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10))); +} + +void HexToString(char *dest, const Byte *data, UInt32 size) +{ + for (UInt32 i = 0; i < size; i++) { - s[--pos] = s[--i]; - s[--pos] = s[--i]; - s[--pos] = s[--i]; - s[--pos] = L' '; + Byte b = data[i]; + dest[0] = GetHex((Byte)((b >> 4) & 0xF)); + dest[1] = GetHex((Byte)(b & 0xF)); + dest += 2; } - while (i > 0) - s[--pos] = s[--i]; - return s + pos; + *dest = 0; } LRESULT CPanel::SetItemText(LVITEMW &item) { + if (_dontShowMode) return 0; - UInt32 realIndex = GetRealIndex(item); /* if ((item.mask & LVIF_IMAGE) != 0) @@ -112,23 +109,106 @@ LRESULT CPanel::SetItemText(LVITEMW &item) if (realIndex == kParentIndex) return 0; - UString s; - UInt32 subItemIndex = item.iSubItem; - PROPID propID = _visibleProperties[subItemIndex].ID; + const CItemProperty &property = _visibleProperties[item.iSubItem]; + PROPID propID = property.ID; + + if (property.IsRawProp) + { + const void *data; + UInt32 dataSize; + UInt32 propType; + RINOK(_folderRawProps->GetRawProp(realIndex, propID, &data, &dataSize, &propType)); + int limit = item.cchTextMax - 1; + if (dataSize == 0) + { + item.pszText[0] = 0; + return 0; + } + + if (propID == kpidNtReparse) + { + UString s; + ConvertNtReparseToString((const Byte *)data, dataSize, s); + if (!s.IsEmpty()) + { + int i; + for (i = 0; i < limit; i++) + { + wchar_t c = s[i]; + if (c == 0) + break; + item.pszText[i] = c; + } + item.pszText[i] = 0; + return 0; + } + } + else if (propID == kpidNtSecure) + { + AString s; + ConvertNtSecureToString((const Byte *)data, dataSize, s); + if (!s.IsEmpty()) + { + int i; + for (i = 0; i < limit; i++) + { + wchar_t c = s[i]; + if (c == 0) + break; + item.pszText[i] = c; + } + item.pszText[i] = 0; + return 0; + } + } + { + const UInt32 kMaxDataSize = 64; + if (dataSize > kMaxDataSize) + { + char temp[64]; + MyStringCopy(temp, "data:"); + ConvertUInt32ToString(dataSize, temp + 5); + int i; + for (i = 0; i < limit; i++) + { + wchar_t c = temp[i]; + if (c == 0) + break; + item.pszText[i] = c; + } + item.pszText[i] = 0; + } + else + { + if ((int)dataSize > limit) + dataSize = limit; + WCHAR *dest = item.pszText; + for (UInt32 i = 0; i < dataSize; i++) + { + Byte b = ((const Byte *)data)[i]; + dest[0] = GetHex((Byte)((b >> 4) & 0xF)); + dest[1] = GetHex((Byte)(b & 0xF)); + dest += 2; + } + *dest = 0; + } + } + return 0; + } /* { - NCOM::CPropVariant property; + NCOM::CPropVariant prop; if (propID == kpidType) string = GetFileType(index); else { - HRESULT result = m_ArchiveFolder->GetProperty(index, propID, &property); + HRESULT result = m_ArchiveFolder->GetProperty(index, propID, &prop); if (result != S_OK) { // PrintMessage("GetPropertyValue error"); return 0; } - string = ConvertPropertyToString(property, propID, false); + string = ConvertPropertyToString(prop, propID, false); } } */ @@ -149,11 +229,81 @@ LRESULT CPanel::SetItemText(LVITEMW &item) if (needRead) */ + if (item.cchTextMax < 32) + { + if (item.cchTextMax > 0) + item.pszText[0] = 0; + return 0; + } + + if (propID == kpidName) + { + if (_folderGetItemName) + { + const wchar_t *name = NULL; + unsigned nameLen = 0; + _folderGetItemName->GetItemName(realIndex, &name, &nameLen); + if (name) + { + int dest = 0; + int limit = item.cchTextMax - 1; + for (int i = 0; dest < limit;) + { + wchar_t c = name[i++]; + if (c == 0) + break; + item.pszText[dest++] = c; + if (c != ' ') + continue; + if (name[i + 1] != ' ') + continue; + + int t = 2; + for (; name[i + t] == ' '; t++); + if (t >= 4 && dest + 4 <= limit) + { + item.pszText[dest++] = '.'; + item.pszText[dest++] = '.'; + item.pszText[dest++] = '.'; + item.pszText[dest++] = ' '; + i += t; + } + } + item.pszText[dest] = 0; + return 0; + } + } + } + if (propID == kpidPrefix) + { + if (_folderGetItemName) + { + const wchar_t *name = NULL; + unsigned nameLen = 0; + _folderGetItemName->GetItemPrefix(realIndex, &name, &nameLen); + if (name) + { + int dest = 0; + int limit = item.cchTextMax - 1; + for (int i = 0; dest < limit;) + { + wchar_t c = name[i++]; + if (c == 0) + break; + item.pszText[dest++] = c; + } + item.pszText[dest] = 0; + return 0; + } + } + } HRESULT res = _folder->GetProperty(realIndex, propID, &prop); if (res != S_OK) - s = UString(L"Error: ") + HResultToMessage(res); - else - if ((prop.vt == VT_UI8 || prop.vt == VT_UI4) && ( + { + MyStringCopy(item.pszText, L"Error: "); + // s = UString(L"Error: ") + HResultToMessage(res); + } + else if ((prop.vt == VT_UI8 || prop.vt == VT_UI4 || prop.vt == VT_UI2) && ( propID == kpidSize || propID == kpidPackSize || propID == kpidNumSubDirs || @@ -162,21 +312,43 @@ LRESULT CPanel::SetItemText(LVITEMW &item) propID == kpidNumBlocks || propID == kpidClusterSize || propID == kpidTotalSize || - propID == kpidFreeSpace + propID == kpidFreeSpace || + propID == kpidUnpackSize )) - s = ConvertSizeToString(ConvertPropVariantToUInt64(prop)); - else { - s = ConvertPropertyToString(prop, propID, false); - s.Replace(wchar_t(0xA), L' '); - s.Replace(wchar_t(0xD), L' '); + UInt64 v = 0; + ConvertPropVariantToUInt64(prop, v); + ConvertSizeToString(v, item.pszText); } - int size = item.cchTextMax; - if (size > 0) + else if (prop.vt == VT_BSTR) { - if (s.Length() + 1 > size) - s = s.Left(size - 1); - MyStringCopy(item.pszText, (const wchar_t *)s); + int limit = item.cchTextMax - 1; + const wchar_t *src = prop.bstrVal; + int i; + for (i = 0; i < limit; i++) + { + wchar_t c = src[i]; + if (c == 0) break; + if (c == 0xA) c = ' '; + if (c == 0xD) c = ' '; + item.pszText[i] = c; + } + item.pszText[i] = 0; + } + else + { + char temp[64]; + ConvertPropertyToShortString(temp, prop, propID, false); + int i; + int limit = item.cchTextMax - 1; + for (i = 0; i < limit; i++) + { + wchar_t c = temp[i]; + if (c == 0) + break; + item.pszText[i] = c; + } + item.pszText[i] = 0; } return 0; } @@ -201,11 +373,9 @@ extern bool g_LVN_ITEMACTIVATE_Support; void CPanel::OnNotifyActivateItems() { - // bool leftCtrl = (::GetKeyState(VK_LCONTROL) & 0x8000) != 0; - // bool rightCtrl = (::GetKeyState(VK_RCONTROL) & 0x8000) != 0; - bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - bool shift = (::GetKeyState(VK_SHIFT) & 0x8000) != 0; + bool alt = IsKeyDown(VK_MENU); + bool ctrl = IsKeyDown(VK_CONTROL); + bool shift = IsKeyDown(VK_SHIFT); if (!shift && alt && !ctrl) Properties(); else @@ -222,7 +392,14 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) { if (!_mySelectMode) OnItemChanged((LPNMLISTVIEW)header); - Post_Refresh_StatusBar(); + + // Post_Refresh_StatusBar(); + /* 9.26: we don't call Post_Refresh_StatusBar. + it was very slow if we select big number of files + and then clead slection by selecting just new file. + probably it called slow Refresh_StatusBar for each item deselection. + I hope Refresh_StatusBar still will be called for each key / mouse action. + */ } return false; } @@ -247,8 +424,17 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) } case LVN_KEYDOWN: { - bool boolResult = OnKeyDown(LPNMLVKEYDOWN(header), result); - Post_Refresh_StatusBar(); + LPNMLVKEYDOWN keyDownInfo = LPNMLVKEYDOWN(header); + bool boolResult = OnKeyDown(keyDownInfo, result); + switch(keyDownInfo->wVKey) + { + case VK_CONTROL: + case VK_SHIFT: + case VK_MENU: + break; + default: + Post_Refresh_StatusBar(); + } return boolResult; } @@ -318,7 +504,7 @@ bool CPanel::OnNotifyList(LPNMHDR header, LRESULT &result) case NM_CUSTOMDRAW: { - if (_mySelectMode) + if (_mySelectMode || (_markDeletedItems && _thereAreDeletedItems)) return OnCustomDraw((LPNMLVCUSTOMDRAW)header, result); break; } @@ -352,14 +538,18 @@ bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result) lplvcd->nmcd.lItemlParam); */ int realIndex = (int)lplvcd->nmcd.lItemlParam; - bool selected = false; - if (realIndex != kParentIndex) - selected = _selectedStatusVector[realIndex]; - if (selected) - lplvcd->clrTextBk = RGB(255, 192, 192); - // lplvcd->clrText = RGB(255, 0, 128); - else - lplvcd->clrTextBk = _listView.GetBkColor(); + lplvcd->clrTextBk = _listView.GetBkColor(); + if (_mySelectMode) + { + if (realIndex != kParentIndex && _selectedStatusVector[realIndex]) + lplvcd->clrTextBk = RGB(255, 192, 192); + } + + if (_markDeletedItems && _thereAreDeletedItems) + { + if (IsItem_Deleted(realIndex)) + lplvcd->clrText = RGB(255, 0, 0); + } // lplvcd->clrText = RGB(0, 0, 0); // result = CDRF_NEWFONT; result = CDRF_NOTIFYITEMDRAW; @@ -392,38 +582,75 @@ bool CPanel::OnCustomDraw(LPNMLVCUSTOMDRAW lplvcd, LRESULT &result) void CPanel::Refresh_StatusBar() { + /* + g_name_cnt++; + char s[256]; + sprintf(s, "g_name_cnt = %8d", g_name_cnt); + OutputDebugStringA(s); + */ + // DWORD dw = GetTickCount(); + CRecordVector indices; GetOperatedItemIndices(indices); - _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, 0x02000301, NumberToString(indices.Size()))); + wchar_t temp[32]; + ConvertUInt32ToString(indices.Size(), temp); - UString selectSizeString; + // UString s1 = MyFormatNew(g_App.LangString_N_SELECTED_ITEMS, NumberToString(indices.Size())); + // UString s1 = MyFormatNew(IDS_N_SELECTED_ITEMS, NumberToString(indices.Size())); + _statusBar.SetText(0, MyFormatNew(g_App.LangString_N_SELECTED_ITEMS, temp)); + // _statusBar.SetText(0, MyFormatNew(IDS_N_SELECTED_ITEMS, NumberToString(indices.Size()))); + + wchar_t selectSizeString[32]; + selectSizeString[0] = 0; if (indices.Size() > 0) { + // for (int ttt = 0; ttt < 1000; ttt++) { UInt64 totalSize = 0; - for (int i = 0; i < indices.Size(); i++) + FOR_VECTOR (i, indices) totalSize += GetItemSize(indices[i]); - selectSizeString = ConvertSizeToString(totalSize); + ConvertSizeToString(totalSize, selectSizeString); + // } } _statusBar.SetText(1, selectSizeString); int focusedItem = _listView.GetFocusedItem(); - UString sizeString; - UString dateString; + wchar_t sizeString[32]; + sizeString[0] = 0; + wchar_t dateString[32]; + dateString[0] = 0; if (focusedItem >= 0 && _listView.GetSelectedCount() > 0) { int realIndex = GetRealItemIndex(focusedItem); if (realIndex != kParentIndex) { - sizeString = ConvertSizeToString(GetItemSize(realIndex)); + ConvertSizeToString(GetItemSize(realIndex), sizeString); NCOM::CPropVariant prop; if (_folder->GetProperty(realIndex, kpidMTime, &prop) == S_OK) - dateString = ConvertPropertyToString(prop, kpidMTime, false); + { + char dateString2[32]; + dateString2[0] = 0; + ConvertPropertyToShortString(dateString2, prop, kpidMTime, false); + for (int i = 0;; i++) + { + char c = dateString2[i]; + dateString[i] = c; + if (c == 0) + break; + } + } } } _statusBar.SetText(2, sizeString); _statusBar.SetText(3, dateString); + // _statusBar.SetText(4, nameString); // _statusBar2.SetText(1, MyFormatNew(L"{0} bytes", NumberToStringW(totalSize))); + // } + /* + dw = GetTickCount() - dw; + sprintf(s, "status = %8d ms", dw); + OutputDebugStringA(s); + */ } diff --git a/CPP/7zip/UI/FileManager/PanelMenu.cpp b/CPP/7zip/UI/FileManager/PanelMenu.cpp old mode 100755 new mode 100644 index badf531b..d6dcf6c1 --- a/CPP/7zip/UI/FileManager/PanelMenu.cpp +++ b/CPP/7zip/UI/FileManager/PanelMenu.cpp @@ -1,12 +1,13 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/StringConvert.h" -#include "Windows/COM.h" -#include "Windows/Clipboard.h" -#include "Windows/Menu.h" -#include "Windows/PropVariant.h" -#include "Windows/PropVariantConversions.h" +#include "../../../Windows/COM.h" +#include "../../../Windows/Clipboard.h" +#include "../../../Windows/Menu.h" +#include "../../../Windows/PropVariant.h" +#include "../../../Windows/PropVariantConv.h" #include "../../PropID.h" #include "../Common/PropIDUtils.h" @@ -24,8 +25,8 @@ using namespace NWindows; LONG g_DllRefCount = 0; -static const UINT kSevenZipStartMenuID = kPluginMenuStartID ; -static const UINT kSystemStartMenuID = kPluginMenuStartID + 100; +static const UINT kSevenZipStartMenuID = kMenuCmdID_Plugin_Start; +static const UINT kSystemStartMenuID = kMenuCmdID_Plugin_Start + 100; void CPanel::InvokeSystemCommand(const char *command) { @@ -54,6 +55,8 @@ static const wchar_t *kPropValueSeparator = L": "; extern UString ConvertSizeToString(UInt64 value); +UString GetOpenArcErrorMessage(UInt32 errorFlags); + static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR, const NCOM::CPropVariant &prop, UString &s) { @@ -61,7 +64,17 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR, { UString val; - if ((prop.vt == VT_UI8 || prop.vt == VT_UI4) && ( + if (propID == kpidErrorFlags || + propID == kpidWarningFlags) + { + UInt32 flags = GetOpenArcErrorFlags(prop); + if (flags == 0) + return; + if (flags != 0) + val = GetOpenArcErrorMessage(flags); + } + if (val.IsEmpty()) + if ((prop.vt == VT_UI8 || prop.vt == VT_UI4 || prop.vt == VT_UI2) && ( propID == kpidSize || propID == kpidPackSize || propID == kpidNumSubDirs || @@ -72,11 +85,16 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR, propID == kpidFreeSpace || propID == kpidPhySize || propID == kpidHeadersSize || - propID == kpidFreeSpace + propID == kpidFreeSpace || + propID == kpidUnpackSize )) - val = ConvertSizeToString(ConvertPropVariantToUInt64(prop)); + { + UInt64 v = 0; + ConvertPropVariantToUInt64(prop, v); + val = ConvertSizeToString(v); + } else - val = ConvertPropertyToString(prop, propID); + ConvertPropertyToString(val, prop, propID); if (!val.IsEmpty()) { @@ -92,6 +110,25 @@ static void AddPropertyString(PROPID propID, const wchar_t *nameBSTR, } } +static inline char GetHex(Byte value) +{ + return (char)((value < 10) ? ('0' + value) : ('A' + (value - 10))); +} + +static const Byte kSpecProps[] = +{ + kpidPath, + kpidType, + kpidErrorType, + kpidError, + kpidErrorFlags, + kpidWarning, + kpidWarningFlags, + kpidOffset, + kpidPhySize, + kpidTailSize +}; + void CPanel::Properties() { CMyComPtr getFolderArcProps; @@ -129,6 +166,57 @@ void CPanel::Properties() AddPropertyString(propID, name, prop, message); } } + + + if (_folderRawProps) + { + _folderRawProps->GetNumRawProps(&numProps); + for (UInt32 i = 0; i < numProps; i++) + { + CMyComBSTR name; + PROPID propID; + if (_folderRawProps->GetRawPropInfo(i, &name, &propID) != S_OK) + continue; + + const void *data; + UInt32 dataSize; + UInt32 propType; + if (_folderRawProps->GetRawProp(index, propID, &data, &dataSize, &propType) != S_OK) + continue; + + if (dataSize != 0) + { + AString s; + if (propID == kpidNtSecure) + ConvertNtSecureToString((const Byte *)data, dataSize, s); + else + { + const UInt32 kMaxDataSize = 64; + if (dataSize > kMaxDataSize) + { + char temp[64]; + s += "data:"; + ConvertUInt32ToString(dataSize, temp); + s += temp; + } + else + { + for (UInt32 i = 0; i < dataSize; i++) + { + Byte b = ((const Byte *)data)[i]; + s += GetHex((Byte)((b >> 4) & 0xF)); + s += GetHex((Byte)(b & 0xF)); + } + } + } + message += GetNameOfProperty(propID, name); + message += kPropValueSeparator; + message += GetUnicodeString(s); + message += L'\n'; + } + } + } + message += kSeparator; } @@ -187,21 +275,19 @@ void CPanel::Properties() UInt32 numProps; if (getProps->GetArcNumProps(level, &numProps) == S_OK) { + const int kNumSpecProps = ARRAY_SIZE(kSpecProps); + message += kSeparator; - for (Int32 i = -3; i < (Int32)numProps; i++) + + for (Int32 i = -(int)kNumSpecProps; i < (Int32)numProps; i++) { CMyComBSTR name; PROPID propID; VARTYPE vt; - switch (i) - { - case -3: propID = kpidPath; break; - case -2: propID = kpidType; break; - case -1: propID = kpidError; break; - default: - if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK) - continue; - } + if (i < 0) + propID = kSpecProps[i + kNumSpecProps]; + else if (getProps->GetArcPropInfo(level, i, &name, &propID, &vt) != S_OK) + continue; NCOM::CPropVariant prop; if (getProps->GetArcProp(level, propID, &prop) != S_OK) continue; @@ -209,6 +295,7 @@ void CPanel::Properties() } } } + if (level2 != numLevels - 1) { UInt32 level = numLevels - 1 - level2; @@ -233,7 +320,7 @@ void CPanel::Properties() } } } - ::MessageBoxW(*(this), message, LangString(IDS_PROPERTIES, 0x03020900), MB_OK); + ::MessageBoxW(*(this), message, LangString(IDS_PROPERTIES), MB_OK); } } @@ -256,7 +343,7 @@ void CPanel::EditCopy() UString s; CRecordVector indices; GetSelectedItemsIndices(indices); - for (int i = 0; i < indices.Size(); i++) + FOR_VECTOR (i, indices) { if (i > 0) s += L"\xD\n"; @@ -274,7 +361,7 @@ void CPanel::EditPaste() UString s; for (int i = 0; i < names.Size(); i++) { - s += L" "; + s += L' '; s += names[i]; } @@ -323,8 +410,8 @@ HRESULT CPanel::CreateShellContextMenu( // Get a pidl for the file itself. CRecordVector pidls; - pidls.Reserve(operatedIndices.Size()); - for (int i = 0; i < operatedIndices.Size(); i++) + pidls.ClearAndReserve(operatedIndices.Size()); + FOR_VECTOR (i, operatedIndices) { LPITEMIDLIST pidl; UString fileName = GetItemRelPath(operatedIndices[i]); @@ -332,7 +419,7 @@ HRESULT CPanel::CreateShellContextMenu( fileName += WCHAR_PATH_SEPARATOR; RINOK(parentFolder->ParseDisplayName(GetParent(), 0, (wchar_t *)(const wchar_t *)fileName, &eaten, &pidl, 0)); - pidls.Add(pidl); + pidls.AddInReserved(pidl); } ITEMIDLIST temp; @@ -431,7 +518,7 @@ void CPanel::CreateSystemMenu(HMENU menuSpec, menuItem.fType = MFT_STRING; menuItem.hSubMenu = popupMenu.Detach(); // menuDestroyer.Disable(); - menuItem.StringValue = LangString(IDS_SYSTEM, 0x030202A0); + LangString(IDS_SYSTEM, menuItem.StringValue); menu.InsertItem(0, true, menuItem); } /* @@ -489,11 +576,11 @@ void CPanel::CreateSevenZipMenu(HMENU menuSpec, */ UString currentFolderUnicode = _currentFolderPrefix; UStringVector names; - int i; - for(i = 0; i < operatedIndices.Size(); i++) + unsigned i; + for (i = 0; i < operatedIndices.Size(); i++) names.Add(currentFolderUnicode + GetItemRelPath(operatedIndices[i])); CRecordVector namePointers; - for(i = 0; i < operatedIndices.Size(); i++) + for (i = 0; i < operatedIndices.Size(); i++) namePointers.Add(names[i]); // NFile::NDirectory::MySetCurrentDirectory(currentFolderUnicode); @@ -524,19 +611,24 @@ void CPanel::CreateFileMenu(HMENU menuSpec, CMenu menu; menu.Attach(menuSpec); - - CreateSevenZipMenu(menu, operatedIndices, sevenZipContextMenu); - if (g_App.ShowSystemMenu) - CreateSystemMenu(menu, operatedIndices, systemContextMenu); + + if (!IsArcFolder()) + { + CreateSevenZipMenu(menu, operatedIndices, sevenZipContextMenu); + // CreateSystemMenu is very slow if you call it inside ZIP archive with big number of files + // Windows probably can parse items inside ZIP archive. + if (g_App.ShowSystemMenu) + CreateSystemMenu(menu, operatedIndices, systemContextMenu); + } /* if (menu.GetItemCount() > 0) menu.AppendItem(MF_SEPARATOR, 0, (LPCTSTR)0); */ - int i; + unsigned i; for (i = 0; i < operatedIndices.Size(); i++) - if (IsItemFolder(operatedIndices[i])) + if (IsItem_Folder(operatedIndices[i])) break; bool allAreFiles = (i == operatedIndices.Size()); LoadFileMenu(menu, menu.GetItemCount(), programMenu, @@ -627,7 +719,9 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos) CRecordVector operatedIndices; GetOperatedItemIndices(operatedIndices); - if (xPos < 0 || yPos < 0) + // negative x,y are possible for multi-screen modes. + // x=-1 && y=-1 for keyboard call (SHIFT+F10 and others). + if (xPos == -1 && yPos == -1) { if (operatedIndices.Size() == 0) { @@ -669,7 +763,7 @@ bool CPanel::OnContextMenu(HANDLE windowHandle, int xPos, int yPos) if (result == 0) return true; - if (result >= kPluginMenuStartID) + if (result >= kMenuCmdID_Plugin_Start) { InvokePluginCommand(result, sevenZipContextMenu, systemContextMenu); return true; diff --git a/CPP/7zip/UI/FileManager/PanelOperations.cpp b/CPP/7zip/UI/FileManager/PanelOperations.cpp old mode 100755 new mode 100644 index 9c109d0d..4633aead --- a/CPP/7zip/UI/FileManager/PanelOperations.cpp +++ b/CPP/7zip/UI/FileManager/PanelOperations.cpp @@ -2,14 +2,13 @@ #include "StdAfx.h" -#include "Common/DynamicBuffer.h" -#include "Common/StringConvert.h" +#include "../../../Common/DynamicBuffer.h" +#include "../../../Common/StringConvert.h" +#include "../../../Common/Wildcard.h" -#include "Windows/COM.h" -#include "Windows/FileDir.h" -#include "Windows/PropVariant.h" -#include "Windows/ResourceString.h" -#include "Windows/Thread.h" +#include "../../../Windows/COM.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/PropVariant.h" #include "ComboDialog.h" @@ -23,6 +22,7 @@ using namespace NWindows; using namespace NFile; +using namespace NName; #ifndef _UNICODE extern bool g_IsNT; @@ -82,7 +82,7 @@ HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progr UpdateCallbackSpec->ProgressDialog = &ProgressDialog; ProgressDialog.WaitMode = true; - ProgressDialog.Sync.SetErrorMessageTitle(titleError); + ProgressDialog.Sync.FinalMessage.ErrorMessage.Title = titleError; Result = S_OK; bool usePassword = false; @@ -97,8 +97,8 @@ HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progr UpdateCallbackSpec->Init(usePassword, password); ProgressDialog.MainWindow = panel._mainWindow; // panel.GetParent() - ProgressDialog.MainTitle = LangString(IDS_APP_TITLE, 0x03000000); - ProgressDialog.MainAddTitle = progressTitle + UString(L" "); + ProgressDialog.MainTitle = L"7-Zip"; // LangString(IDS_APP_TITLE); + ProgressDialog.MainAddTitle = progressTitle + L' '; RINOK(Create(progressTitle, ProgressDialog.MainWindow)); return Result; @@ -108,9 +108,17 @@ HRESULT CThreadFolderOperations::DoOperation(CPanel &panel, const UString &progr typedef int (WINAPI * SHFileOperationWP)(LPSHFILEOPSTRUCTW lpFileOp); #endif -void CPanel::DeleteItems(bool toRecycleBin) +void CPanel::MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID) { - CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); + if (errorCode == E_NOINTERFACE) + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); + else + MessageBoxError(errorCode, LangString(resourceID)); +} + +void CPanel::DeleteItems(bool NON_CE_VAR(toRecycleBin)) +{ + CDisableTimerProcessing disableTimerProcessing(*this); CRecordVector indices; GetOperatedItemIndices(indices); if (indices.IsEmpty()) @@ -120,23 +128,19 @@ void CPanel::DeleteItems(bool toRecycleBin) #ifndef UNDER_CE // WM6 / SHFileOperationW doesn't ask user! So we use internal delete - bool useInternalDelete = false; if (IsFSFolder() && toRecycleBin) { + bool useInternalDelete = false; #ifndef _UNICODE if (!g_IsNT) { CDynamicBuffer buffer; - size_t size = 0; - for (int i = 0; i < indices.Size(); i++) + FOR_VECTOR (i, indices) { const AString path = GetSystemString(GetFsPath() + GetItemRelPath(indices[i])); - buffer.EnsureCapacity(size + path.Length() + 1); - memmove(((CHAR *)buffer) + size, (const CHAR *)path, (path.Length() + 1) * sizeof(CHAR)); - size += path.Length() + 1; + memcpy(buffer.GetCurPtrAndGrow(path.Len() + 1), (const CHAR *)path, (path.Len() + 1) * sizeof(CHAR)); } - buffer.EnsureCapacity(size + 1); - ((CHAR *)buffer)[size] = 0; + *buffer.GetCurPtrAndGrow(1) = 0; SHFILEOPSTRUCTA fo; fo.hwnd = GetParent(); fo.wFunc = FO_DELETE; @@ -158,25 +162,21 @@ void CPanel::DeleteItems(bool toRecycleBin) #endif { CDynamicBuffer buffer; - size_t size = 0; - int maxLen = 0; - for (int i = 0; i < indices.Size(); i++) + unsigned maxLen = 0; + FOR_VECTOR (i, indices) { // L"\\\\?\\") doesn't work here. const UString path = GetFsPath() + GetItemRelPath(indices[i]); - if (path.Length() > maxLen) - maxLen = path.Length(); - buffer.EnsureCapacity(size + path.Length() + 1); - memmove(((WCHAR *)buffer) + size, (const WCHAR *)path, (path.Length() + 1) * sizeof(WCHAR)); - size += path.Length() + 1; + if (path.Len() > maxLen) + maxLen = path.Len(); + memcpy(buffer.GetCurPtrAndGrow(path.Len() + 1), (const WCHAR *)path, (path.Len() + 1) * sizeof(WCHAR)); } - buffer.EnsureCapacity(size + 1); - ((WCHAR *)buffer)[size] = 0; + *buffer.GetCurPtrAndGrow(1) = 0; if (maxLen >= MAX_PATH) { if (toRecycleBin) { - MessageBoxErrorLang(IDS_ERROR_LONG_PATH_TO_RECYCLE, 0x03020218); + MessageBoxErrorLang(IDS_ERROR_LONG_PATH_TO_RECYCLE); return; } useInternalDelete = true; @@ -210,67 +210,60 @@ void CPanel::DeleteItems(bool toRecycleBin) if (fo.fAnyOperationsAborted) MessageBoxError(result, LangString(IDS_ERROR_DELETING, 0x03020217)); */ + if (!useInternalDelete) + { + RefreshListCtrl(state); + return; + } } - else - useInternalDelete = true; - if (useInternalDelete) #endif - DeleteItemsInternal(indices); - RefreshListCtrl(state); -} + + // DeleteItemsInternal -void CPanel::MessageBoxErrorForUpdate(HRESULT errorCode, UINT resourceID, UInt32 langID) -{ - if (errorCode == E_NOINTERFACE) - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); - else - MessageBoxError(errorCode, LangString(resourceID, langID)); -} - -void CPanel::DeleteItemsInternal(CRecordVector &indices) -{ CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_DELETING, 0x03020217); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_DELETING); return; } - UString title; - UString message; + UInt32 titleID, messageID; + UString messageParam; if (indices.Size() == 1) { int index = indices[0]; - const UString itemName = GetItemRelPath(index); - if (IsItemFolder(index)) + messageParam = GetItemRelPath(index); + if (IsItem_Folder(index)) { - title = LangString(IDS_CONFIRM_FOLDER_DELETE, 0x03020211); - message = MyFormatNew(IDS_WANT_TO_DELETE_FOLDER, 0x03020214, itemName); + titleID = IDS_CONFIRM_FOLDER_DELETE; + messageID = IDS_WANT_TO_DELETE_FOLDER; } else { - title = LangString(IDS_CONFIRM_FILE_DELETE, 0x03020210); - message = MyFormatNew(IDS_WANT_TO_DELETE_FILE, 0x03020213, itemName); + titleID = IDS_CONFIRM_FILE_DELETE; + messageID = IDS_WANT_TO_DELETE_FILE; } } else { - title = LangString(IDS_CONFIRM_ITEMS_DELETE, 0x03020212); - message = MyFormatNew(IDS_WANT_TO_DELETE_ITEMS, 0x03020215, - NumberToString(indices.Size())); + titleID = IDS_CONFIRM_ITEMS_DELETE; + messageID = IDS_WANT_TO_DELETE_ITEMS; + messageParam = NumberToString(indices.Size()); } - if (::MessageBoxW(GetParent(), message, title, MB_OKCANCEL | MB_ICONQUESTION) != IDOK) + if (::MessageBoxW(GetParent(), MyFormatNew(messageID, messageParam), LangString(titleID), MB_OKCANCEL | MB_ICONQUESTION) != IDOK) return; + CDisableNotify disableNotify(*this); { CThreadFolderOperations op(FOLDER_TYPE_DELETE); op.FolderOperations = folderOperations; op.Indices = indices; op.DoOperation(*this, - LangString(IDS_DELETING, 0x03020216), - LangString(IDS_ERROR_DELETING, 0x03020217)); + LangString(IDS_DELETING), + LangString(IDS_ERROR_DELETING)); } RefreshTitleAlways(); + RefreshListCtrl(state); } BOOL CPanel::OnBeginLabelEdit(LV_DISPINFOW * lpnmh) @@ -291,10 +284,10 @@ static UString GetLastPart(const UString name) int slash1Pos = name.ReverseFind(L'\\'); slashPos = MyMax(slashPos, slash1Pos); #endif - return name.Mid(slashPos + 1); + return name.Ptr(slashPos + 1); } -bool IsCorrectFsName(const UString name) +bool IsCorrectFsName(const UString &name) { const UString lastPart = GetLastPart(name); return @@ -302,23 +295,41 @@ bool IsCorrectFsName(const UString name) lastPart != L".."; } +bool CorrectFsPath(const UString &relBase, const UString &path, UString &result); + +bool CPanel::CorrectFsPath(const UString &path2, UString &result) +{ + return ::CorrectFsPath(_currentFolderPrefix, path2, result); +} + BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) { if (lpnmh->item.pszText == NULL) return FALSE; + CDisableTimerProcessing disableTimerProcessing2(*this); CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_RENAMING, 0x03020221); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_ERROR_RENAMING); return FALSE; } - const UString newName = lpnmh->item.pszText; + UString newName = lpnmh->item.pszText; if (!IsCorrectFsName(newName)) { MessageBoxError(E_INVALIDARG); return FALSE; } - CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); + + if (IsFSFolder()) + { + UString correctName; + if (!CorrectFsPath(newName, correctName)) + { + MessageBoxError(E_INVALIDARG); + return FALSE; + } + newName = correctName; + } SaveSelectedState(_selectedState); @@ -328,16 +339,21 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) const UString prefix = GetItemPrefix(realIndex); + CDisableNotify disableNotify(*this); { CThreadFolderOperations op(FOLDER_TYPE_RENAME); op.FolderOperations = folderOperations; op.Index = realIndex; op.Name = newName; - HRESULT res = op.DoOperation(*this, - LangString(IDS_RENAMING, 0x03020220), - LangString(IDS_ERROR_RENAMING, 0x03020221)); + /* HRESULTres = */ op.DoOperation(*this, + LangString(IDS_RENAMING), + LangString(IDS_ERROR_RENAMING)); + // fixed in 9.26: we refresh list even after errors + // (it's more safe, since error can be at different stages, so list can be incorrect). + /* if (res != S_OK) return FALSE; + */ } // Can't use RefreshListCtrl here. @@ -357,48 +373,66 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh) return TRUE; } +bool Dlg_CreateFolder(HWND wnd, UString &destName); + void CPanel::CreateFolder() { CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FOLDER_ERROR, 0x03020233); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FOLDER_ERROR); return; } - CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); + CDisableTimerProcessing disableTimerProcessing2(*this); CSelectedState state; SaveSelectedState(state); - CComboDialog comboDialog; - comboDialog.Title = LangString(IDS_CREATE_FOLDER, 0x03020230); - comboDialog.Static = LangString(IDS_CREATE_FOLDER_NAME, 0x03020231); - comboDialog.Value = LangString(IDS_CREATE_FOLDER_DEFAULT_NAME, /*0x03020232*/ (UInt32)-1); - if (comboDialog.Create(GetParent()) == IDCANCEL) + + UString newName; + if (!Dlg_CreateFolder(GetParent(), newName)) return; - UString newName = comboDialog.Value; if (!IsCorrectFsName(newName)) { MessageBoxError(E_INVALIDARG); return; } + + if (IsFSFolder()) + { + UString correctName; + if (!CorrectFsPath(newName, correctName)) + { + MessageBoxError(E_INVALIDARG); + return; + } + newName = correctName; + } + HRESULT res; + CDisableNotify disableNotify(*this); { CThreadFolderOperations op(FOLDER_TYPE_CREATE_FOLDER); op.FolderOperations = folderOperations; op.Name = newName; - HRESULT res = op.DoOperation(*this, - LangString(IDS_CREATE_FOLDER, 0x03020230), - LangString(IDS_CREATE_FOLDER_ERROR, 0x03020233)); + res = op.DoOperation(*this, + LangString(IDS_CREATE_FOLDER), + LangString(IDS_CREATE_FOLDER_ERROR)); + /* + // fixed for 9.26: we must refresh always if (res != S_OK) return; + */ + } + if (res == S_OK) + { + int pos = newName.Find(WCHAR_PATH_SEPARATOR); + if (pos >= 0) + newName.DeleteFrom(pos); + if (!_mySelectMode) + state.SelectedNames.Clear(); + state.FocusedName = newName; + state.SelectFocused = true; } - int pos = newName.Find(WCHAR_PATH_SEPARATOR); - if (pos >= 0) - newName = newName.Left(pos); - if (!_mySelectMode) - state.SelectedNames.Clear(); - state.FocusedName = newName; - state.SelectFocused = true; RefreshTitleAlways(); RefreshListCtrl(state); } @@ -408,28 +442,44 @@ void CPanel::CreateFile() CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FILE_ERROR, 0x03020243); + MessageBoxErrorForUpdate(E_NOINTERFACE, IDS_CREATE_FILE_ERROR); return; } - CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); + CDisableTimerProcessing disableTimerProcessing2(*this); CSelectedState state; SaveSelectedState(state); - CComboDialog comboDialog; - comboDialog.Title = LangString(IDS_CREATE_FILE, 0x03020240); - comboDialog.Static = LangString(IDS_CREATE_FILE_NAME, 0x03020241); - comboDialog.Value = LangString(IDS_CREATE_FILE_DEFAULT_NAME, /*0x03020242*/ (UInt32)-1); - if (comboDialog.Create(GetParent()) == IDCANCEL) + CComboDialog dlg; + LangString(IDS_CREATE_FILE, dlg.Title); + LangString(IDS_CREATE_FILE_NAME, dlg.Static); + LangString(IDS_CREATE_FILE_DEFAULT_NAME, dlg.Value); + + if (dlg.Create(GetParent()) != IDOK) return; - UString newName = comboDialog.Value; + + CDisableNotify disableNotify(*this); + + UString newName = dlg.Value; + + if (IsFSFolder()) + { + UString correctName; + if (!CorrectFsPath(newName, correctName)) + { + MessageBoxError(E_INVALIDARG); + return; + } + newName = correctName; + } + HRESULT result = folderOperations->CreateFile(newName, 0); if (result != S_OK) { - MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR, 0x03020243); + MessageBoxErrorForUpdate(result, IDS_CREATE_FILE_ERROR); return; } int pos = newName.Find(WCHAR_PATH_SEPARATOR); if (pos >= 0) - newName = newName.Left(pos); + newName.DeleteFrom(pos); if (!_mySelectMode) state.SelectedNames.Clear(); state.FocusedName = newName; @@ -446,7 +496,7 @@ void CPanel::RenameFile() void CPanel::ChangeComment() { - CPanel::CDisableTimerProcessing disableTimerProcessing2(*this); + CDisableTimerProcessing disableTimerProcessing2(*this); int index = _listView.GetFocusedItem(); if (index < 0) return; @@ -458,7 +508,7 @@ void CPanel::ChangeComment() CMyComPtr folderOperations; if (_folder.QueryInterface(IID_IFolderOperations, &folderOperations) != S_OK) { - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } @@ -473,19 +523,20 @@ void CPanel::ChangeComment() return; } UString name = GetItemRelPath(realIndex); - CComboDialog comboDialog; - comboDialog.Title = name + L" " + LangString(IDS_COMMENT, 0x03020290); - comboDialog.Value = comment; - comboDialog.Static = LangString(IDS_COMMENT2, 0x03020291); - if (comboDialog.Create(GetParent()) == IDCANCEL) + CComboDialog dlg; + dlg.Title = name + L' ' + LangString(IDS_COMMENT); + dlg.Value = comment; + LangString(IDS_COMMENT2, dlg.Static); + if (dlg.Create(GetParent()) != IDOK) return; - NCOM::CPropVariant propVariant = comboDialog.Value; + NCOM::CPropVariant propVariant = dlg.Value; + CDisableNotify disableNotify(*this); HRESULT result = folderOperations->SetProperty(realIndex, kpidComment, &propVariant, NULL); if (result != S_OK) { if (result == E_NOINTERFACE) - MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); else MessageBoxError(result, L"Set Comment Error"); } diff --git a/CPP/7zip/UI/FileManager/PanelSelect.cpp b/CPP/7zip/UI/FileManager/PanelSelect.cpp old mode 100755 new mode 100644 index b31c2e9d..a40997c2 --- a/CPP/7zip/UI/FileManager/PanelSelect.cpp +++ b/CPP/7zip/UI/FileManager/PanelSelect.cpp @@ -4,14 +4,12 @@ #include "resource.h" -#include "Common/StringConvert.h" -#include "Common/Wildcard.h" - -#include "Panel.h" +#include "../../../Common/StringConvert.h" +#include "../../../Common/Wildcard.h" #include "ComboDialog.h" - #include "LangUtils.h" +#include "Panel.h" void CPanel::OnShiftSelectMessage() { @@ -145,17 +143,15 @@ void CPanel::UpdateSelection() void CPanel::SelectSpec(bool selectMode) { - CComboDialog comboDialog; - comboDialog.Title = selectMode ? - LangString(IDS_SELECT, 0x03020250): - LangString(IDS_DESELECT, 0x03020251); - comboDialog.Static = LangString(IDS_SELECT_MASK, 0x03020252); - comboDialog.Value = L"*"; - if (comboDialog.Create(GetParent()) == IDCANCEL) + CComboDialog dlg; + LangString(selectMode ? IDS_SELECT : IDS_DESELECT, dlg.Title ); + LangString(IDS_SELECT_MASK, dlg.Static); + dlg.Value = L'*'; + if (dlg.Create(GetParent()) != IDOK) return; - const UString &mask = comboDialog.Value; - for (int i = 0; i < _selectedStatusVector.Size(); i++) - if (CompareWildCardWithName(mask, GetItemName(i))) + const UString &mask = dlg.Value; + FOR_VECTOR (i, _selectedStatusVector) + if (DoesWildcardMatchName(mask, GetItemName(i))) _selectedStatusVector[i] = selectMode; UpdateSelection(); } @@ -167,7 +163,7 @@ void CPanel::SelectByType(bool selectMode) return; int realIndex = GetRealItemIndex(focusedItem); UString name = GetItemName(realIndex); - bool isItemFolder = IsItemFolder(realIndex); + bool isItemFolder = IsItem_Folder(realIndex); /* UInt32 numItems; @@ -178,8 +174,8 @@ void CPanel::SelectByType(bool selectMode) if (isItemFolder) { - for (int i = 0; i < _selectedStatusVector.Size(); i++) - if (IsItemFolder(i) == isItemFolder) + FOR_VECTOR (i, _selectedStatusVector) + if (IsItem_Folder(i) == isItemFolder) _selectedStatusVector[i] = selectMode; } else @@ -187,15 +183,16 @@ void CPanel::SelectByType(bool selectMode) int pos = name.ReverseFind(L'.'); if (pos < 0) { - for (int i = 0; i < _selectedStatusVector.Size(); i++) - if (IsItemFolder(i) == isItemFolder && GetItemName(i).ReverseFind(L'.') < 0) + FOR_VECTOR (i, _selectedStatusVector) + if (IsItem_Folder(i) == isItemFolder && GetItemName(i).ReverseFind(L'.') < 0) _selectedStatusVector[i] = selectMode; } else { - UString mask = UString(L'*') + name.Mid(pos); - for (int i = 0; i < _selectedStatusVector.Size(); i++) - if (IsItemFolder(i) == isItemFolder && CompareWildCardWithName(mask, GetItemName(i))) + UString mask = L'*'; + mask += name.Ptr(pos); + FOR_VECTOR (i, _selectedStatusVector) + if (IsItem_Folder(i) == isItemFolder && DoesWildcardMatchName(mask, GetItemName(i))) _selectedStatusVector[i] = selectMode; } } @@ -204,7 +201,7 @@ void CPanel::SelectByType(bool selectMode) void CPanel::SelectAll(bool selectMode) { - for (int i = 0; i < _selectedStatusVector.Size(); i++) + FOR_VECTOR (i, _selectedStatusVector) _selectedStatusVector[i] = selectMode; UpdateSelection(); } @@ -213,8 +210,8 @@ void CPanel::InvertSelection() { if (!_mySelectMode) { - int numSelected = 0; - for (int i = 0; i < _selectedStatusVector.Size(); i++) + unsigned numSelected = 0; + FOR_VECTOR (i, _selectedStatusVector) if (_selectedStatusVector[i]) numSelected++; if (numSelected == 1) @@ -229,7 +226,7 @@ void CPanel::InvertSelection() } } } - for (int i = 0; i < _selectedStatusVector.Size(); i++) + FOR_VECTOR (i, _selectedStatusVector) _selectedStatusVector[i] = !_selectedStatusVector[i]; UpdateSelection(); } @@ -267,9 +264,9 @@ void CPanel::OnLeftClick(MY_NMLISTVIEW_NMITEMACTIVATE *itemActivate) int focusedIndex = _startGroupSelect; if (focusedIndex < 0) return; - int startItem = MyMin(focusedIndex, indexInList); - int finishItem = MyMax(focusedIndex, indexInList); - for (int i = 0; i < _selectedStatusVector.Size(); i++) + unsigned startItem = MyMin((unsigned)focusedIndex, (unsigned)indexInList); + unsigned finishItem = MyMax((unsigned)focusedIndex, (unsigned)indexInList); + FOR_VECTOR (i, _selectedStatusVector) { int realIndex = GetRealItemIndex(i); if (realIndex == kParentIndex) diff --git a/CPP/7zip/UI/FileManager/PanelSort.cpp b/CPP/7zip/UI/FileManager/PanelSort.cpp old mode 100755 new mode 100644 index 5ac04800..2ca29a15 --- a/CPP/7zip/UI/FileManager/PanelSort.cpp +++ b/CPP/7zip/UI/FileManager/PanelSort.cpp @@ -2,7 +2,8 @@ #include "StdAfx.h" -#include "Windows/PropVariant.h" +#include "../../../../C/CpuArch.h" +#include "../../../Windows/PropVariant.h" #include "../../PropID.h" @@ -10,46 +11,156 @@ using namespace NWindows; -static UString GetExtension(const UString &name) +int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2) +{ + for (;;) + { + wchar_t c1 = *s1; + wchar_t c2 = *s2; + if ((c1 >= '0' && c1 <= '9') && + (c2 >= '0' && c2 <= '9')) + { + for (; *s1 == '0'; s1++); + for (; *s2 == '0'; s2++); + size_t len1 = 0; + size_t len2 = 0; + for (; (s1[len1] >= '0' && s1[len1] <= '9'); len1++); + for (; (s2[len2] >= '0' && s2[len2] <= '9'); len2++); + if (len1 < len2) return -1; + if (len1 > len2) return 1; + for (; len1 > 0; s1++, s2++, len1--) + { + if (*s1 == *s2) continue; + return (*s1 < *s2) ? -1 : 1; + } + c1 = *s1; + c2 = *s2; + } + s1++; + s2++; + if (c1 != c2) + { + // Probably we need to change the order for special characters like in Explorer. + wchar_t u1 = MyCharUpper(c1); + wchar_t u2 = MyCharUpper(c2); + if (u1 < u2) return -1; + if (u1 > u2) return 1; + } + if (c1 == 0) return 0; + } +} + +static int CompareFileNames_Le16(const Byte *s1, unsigned size1, const Byte *s2, unsigned size2) +{ + size1 &= ~1; + size2 &= ~1; + for (unsigned i = 0;; i += 2) + { + if (i >= size1) + return (i >= size2) ? 0 : -1; + if (i >= size2) + return 1; + UInt16 c1 = GetUi16(s1 + i); + UInt16 c2 = GetUi16(s2 + i); + if (c1 == c2) + { + if (c1 == 0) + return 0; + continue; + } + if (c1 < c2) + return -1; + return 1; + } +} + +static inline const wchar_t *GetExtensionPtr(const UString &name) { int dotPos = name.ReverseFind(L'.'); - if (dotPos < 0) - return UString(); - return name.Mid(dotPos); + return name.Ptr((dotPos < 0) ? name.Len() : dotPos); } +void CPanel::SetSortRawStatus() +{ + _isRawSortProp = false; + FOR_VECTOR (i, _properties) + { + const CItemProperty &prop = _properties[i]; + if (prop.ID == _sortID) + { + _isRawSortProp = prop.IsRawProp ? 1 : 0; + return; + } + } +} + + int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) { if (lpData == NULL) return 0; CPanel *panel = (CPanel*)lpData; - switch(panel->_sortID) + + PROPID propID = panel->_sortID; + + if (propID == kpidNoProperty) + return MyCompare(lParam1, lParam2); + + if (panel->_isRawSortProp) + { + // Sha1, NtSecurity, NtReparse + const void *data1; + const void *data2; + UInt32 dataSize1; + UInt32 dataSize2; + UInt32 propType1; + UInt32 propType2; + if (panel->_folderRawProps->GetRawProp((UInt32)lParam1, propID, &data1, &dataSize1, &propType1) != 0) return 0; + if (panel->_folderRawProps->GetRawProp((UInt32)lParam2, propID, &data2, &dataSize2, &propType2) != 0) return 0; + if (dataSize1 == 0) + return (dataSize2 == 0) ? 0 : -1; + if (dataSize2 == 0) + return 1; + if (propType1 != NPropDataType::kRaw) return 0; + if (propType2 != NPropDataType::kRaw) return 0; + if (propID == kpidNtReparse) + { + NFile::CReparseShortInfo r1; r1.Parse((const Byte *)data1, dataSize1); + NFile::CReparseShortInfo r2; r2.Parse((const Byte *)data2, dataSize2); + return CompareFileNames_Le16( + (const Byte *)data1 + r1.Offset, r1.Size, + (const Byte *)data2 + r2.Offset, r2.Size); + } + } + + if (panel->_folderCompare) + return panel->_folderCompare->CompareItems((UInt32)lParam1, (UInt32)lParam2, propID, panel->_isRawSortProp); + + switch (propID) { // if (panel->_sortIndex == 0) case kpidName: { const UString name1 = panel->GetItemName((int)lParam1); const UString name2 = panel->GetItemName((int)lParam2); - int res = name1.CompareNoCase(name2); + int res = CompareFileNames_ForFolderList(name1, name2); /* if (res != 0 || !panel->_flatMode) return res; const UString prefix1 = panel->GetItemPrefix(lParam1); const UString prefix2 = panel->GetItemPrefix(lParam2); - return res = prefix1.CompareNoCase(prefix2); + return res = CompareFileNames_ForFolderList(prefix1, prefix2); */ return res; } - case kpidNoProperty: - { - return MyCompare(lParam1, lParam2); - } case kpidExtension: { - const UString ext1 = GetExtension(panel->GetItemName((int)lParam1)); - const UString ext2 = GetExtension(panel->GetItemName((int)lParam2)); - return ext1.CompareNoCase(ext2); + const UString name1 = panel->GetItemName((int)lParam1); + const UString name2 = panel->GetItemName((int)lParam2); + return CompareFileNames_ForFolderList( + GetExtensionPtr(name1), + GetExtensionPtr(name2)); } } /* @@ -59,7 +170,6 @@ int CALLBACK CompareItems2(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) */ // PROPID propID = panel->_properties[panel->_sortIndex].ID; - PROPID propID = panel->_sortID; NCOM::CPropVariant prop1, prop2; // Name must be first property @@ -85,8 +195,8 @@ int CALLBACK CompareItems(LPARAM lParam1, LPARAM lParam2, LPARAM lpData) CPanel *panel = (CPanel*)lpData; - bool isDir1 = panel->IsItemFolder((int)lParam1); - bool isDir2 = panel->IsItemFolder((int)lParam2); + bool isDir1 = panel->IsItem_Folder((int)lParam1); + bool isDir2 = panel->IsItem_Folder((int)lParam2); if (isDir1 && !isDir2) return -1; if (isDir2 && !isDir1) return 1; @@ -145,6 +255,7 @@ void CPanel::SortItemsWithPropID(PROPID propID) break; } } + SetSortRawStatus(); _listView.SortItems(CompareItems, (LPARAM)this); _listView.EnsureVisible(_listView.GetFocusedItem(), false); } diff --git a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp old mode 100755 new mode 100644 index ba0bedf8..ce15fcc5 --- a/CPP/7zip/UI/FileManager/PanelSplitFile.cpp +++ b/CPP/7zip/UI/FileManager/PanelSplitFile.cpp @@ -2,12 +2,10 @@ #include "StdAfx.h" -#include "Common/IntToString.h" +#include "../../../Common/IntToString.h" -#include "Windows/Error.h" -#include "Windows/FileIO.h" -#include "Windows/FileFind.h" -#include "Windows/FileName.h" +#include "../../../Windows/ErrorMsg.h" +#include "../../../Windows/FileName.h" #include "../GUI/ExtractRes.h" @@ -20,7 +18,11 @@ #include "SplitDialog.h" #include "SplitUtils.h" +#include "PropertyNameRes.h" + using namespace NWindows; +using namespace NFile; +using namespace NDir; static const wchar_t *g_Message_FileWriteError = L"File write error"; @@ -42,47 +44,38 @@ struct CVolSeqName bool ParseName(const UString &name) { - if (name.Right(2) != L"01") + if (name.Len() < 2) return false; - int numLetters = 2; - while (numLetters < name.Length()) - { - if (name[name.Length() - numLetters - 1] != '0') - break; - numLetters++; - } - UnchangedPart = name.Left(name.Length() - numLetters); - ChangedPart = name.Right(numLetters); + if (name.Back() != L'1' || name[name.Len() - 2] != L'0') + return false; + + unsigned pos = name.Len() - 2; + for (; pos > 0 && name[pos - 1] == '0'; pos--); + UnchangedPart.SetFrom(name, pos); + ChangedPart = name.Ptr(pos); return true; } - UString GetNextName() + UString GetNextName(); +}; + + +UString CVolSeqName::GetNextName() +{ + for (int i = (int)ChangedPart.Len() - 1; i >= 0; i--) { - UString newName; - int i; - int numLetters = ChangedPart.Length(); - for (i = numLetters - 1; i >= 0; i--) + wchar_t c = ChangedPart[i]; + if (c != L'9') { - wchar_t c = ChangedPart[i]; - if (c == L'9') - { - c = L'0'; - newName = c + newName; - if (i == 0) - newName = UString(L'1') + newName; - continue; - } - c++; - newName = c + newName; - i--; - for (; i >= 0; i--) - newName = ChangedPart[i] + newName; + ChangedPart.ReplaceOneCharAtPos(i, (wchar_t)(c + 1)); break; } - ChangedPart = newName; - return UnchangedPart + ChangedPart; + ChangedPart.ReplaceOneCharAtPos(i, L'0'); + if (i == 0) + ChangedPart.InsertAtFront(L'1'); } -}; + return UnchangedPart + ChangedPart; +} static const UInt32 kBufSize = (1 << 20); @@ -98,10 +91,10 @@ public: HRESULT CThreadSplit::ProcessVirt() { - NFile::NIO::CInFile inFile; + NIO::CInFile inFile; if (!inFile.Open(FilePath)) return GetLastError(); - NFile::NIO::COutFile outFile; + NIO::COutFile outFile; CMyBuffer bufferObject; if (!bufferObject.Allocate(kBufSize)) return E_OUTOFMEMORY; @@ -114,11 +107,11 @@ HRESULT CThreadSplit::ProcessVirt() return GetLastError(); CProgressSync &sync = ProgressDialog.Sync; - sync.SetProgress(length, 0); + sync.Set_NumBytesTotal(length); UInt64 pos = 0; UInt64 numFiles = 0; - int volIndex = 0; + unsigned volIndex = 0; for (;;) { @@ -140,8 +133,8 @@ HRESULT CThreadSplit::ProcessVirt() FString name = VolBasePath; name += FTEXT('.'); name += us2fs(seqName.GetNextName()); - sync.SetCurrentFileName(fs2us(name)); - sync.SetNumFilesCur(numFiles++); + sync.Set_FilePath(fs2us(name)); + sync.Set_NumFilesCur(numFiles++); if (!outFile.Create(name, false)) { HRESULT res = GetLastError(); @@ -162,9 +155,9 @@ HRESULT CThreadSplit::ProcessVirt() curVolSize = 0; } pos += processedSize; - RINOK(sync.SetPosAndCheckPaused(pos)); + RINOK(sync.Set_NumBytesCur(pos)); } - sync.SetNumFilesCur(numFiles); + sync.Set_NumFilesCur(numFiles); return S_OK; } @@ -174,7 +167,7 @@ void CApp::Split() CPanel &srcPanel = Panels[srcPanelIndex]; if (!srcPanel.IsFSFolder()) { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } CRecordVector indices; @@ -183,13 +176,13 @@ void CApp::Split() return; if (indices.Size() != 1) { - srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02); + srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE); return; } int index = indices[0]; - if (srcPanel.IsItemFolder(index)) + if (srcPanel.IsItem_Folder(index)) { - srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE, 0x03020A02); + srcPanel.MessageBoxErrorLang(IDS_SELECT_ONE_FILE); return; } const UString itemName = srcPanel.GetItemName(index); @@ -204,10 +197,10 @@ void CApp::Split() CSplitDialog splitDialog; splitDialog.FilePath = srcPanel.GetItemRelPath(index); splitDialog.Path = path; - if (splitDialog.Create(srcPanel.GetParent()) == IDCANCEL) + if (splitDialog.Create(srcPanel.GetParent()) != IDOK) return; - NFile::NFind::CFileInfo fileInfo; + NFind::CFileInfo fileInfo; if (!fileInfo.Find(us2fs(srcPath + itemName))) { srcPanel.MessageBoxMyError(L"Can not find file"); @@ -215,7 +208,7 @@ void CApp::Split() } if (fileInfo.Size <= splitDialog.VolumeSizes.Front()) { - srcPanel.MessageBoxErrorLang(IDS_SPLIT_VOL_MUST_BE_SMALLER, 0x03020522); + srcPanel.MessageBoxErrorLang(IDS_SPLIT_VOL_MUST_BE_SMALLER); return; } const UInt64 numVolumes = GetNumberOfVolumes(fileInfo.Size, splitDialog.VolumeSizes); @@ -223,17 +216,17 @@ void CApp::Split() { wchar_t s[32]; ConvertUInt64ToString(numVolumes, s); - if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, 0x03020521, s), - LangString(IDS_SPLIT_CONFIRM_TITLE, 0x03020520), + if (::MessageBoxW(srcPanel, MyFormatNew(IDS_SPLIT_CONFIRM_MESSAGE, s), + LangString(IDS_SPLIT_CONFIRM_TITLE), MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES) return; } path = splitDialog.Path; - NFile::NName::NormalizeDirPathPrefix(path); - if (!NFile::NDirectory::CreateComplexDirectory(us2fs(path))) + NName::NormalizeDirPathPrefix(path); + if (!CreateComplexDir(us2fs(path))) { - srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path)); + srcPanel.MessageBoxError2Lines(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), ::GetLastError()); return; } @@ -243,15 +236,15 @@ void CApp::Split() CProgressDialog &progressDialog = spliter.ProgressDialog; - UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - UString title = LangString(IDS_SPLITTING, 0x03020510); + UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE, 0x03000000); + UString title = LangString(IDS_SPLITTING); progressDialog.ShowCompressionInfo = false; progressDialog.MainWindow = _window; progressDialog.MainTitle = progressWindowTitle; - progressDialog.MainAddTitle = title + UString(L" "); - progressDialog.Sync.SetTitleFileName(itemName); + progressDialog.MainAddTitle = title + L' '; + progressDialog.Sync.Set_TitleFileName(itemName); spliter.FilePath = us2fs(srcPath + itemName); @@ -269,8 +262,8 @@ void CApp::Split() RefreshTitleAlways(); - // disableTimerProcessing1.Restore(); - // disableTimerProcessing2.Restore(); + // disableNotify.Restore(); + // disableNotify.Restore(); // srcPanel.SetFocusToList(); // srcPanel.RefreshListCtrlSaveFocused(); } @@ -288,7 +281,7 @@ public: HRESULT CThreadCombine::ProcessVirt() { - NFile::NIO::COutFile outFile; + NIO::COutFile outFile; if (!outFile.Create(OutputPath, false)) { HRESULT res = GetLastError(); @@ -297,16 +290,16 @@ HRESULT CThreadCombine::ProcessVirt() } CProgressSync &sync = ProgressDialog.Sync; - sync.SetProgress(TotalSize, 0); + sync.Set_NumBytesTotal(TotalSize); CMyBuffer bufferObject; if (!bufferObject.Allocate(kBufSize)) return E_OUTOFMEMORY; Byte *buffer = (Byte *)(void *)bufferObject; UInt64 pos = 0; - for (int i = 0; i < Names.Size(); i++) + FOR_VECTOR (i, Names) { - NFile::NIO::CInFile inFile; + NIO::CInFile inFile; const FString nextName = InputDirPrefix + Names[i]; if (!inFile.Open(nextName)) { @@ -314,7 +307,7 @@ HRESULT CThreadCombine::ProcessVirt() SetErrorPath1(nextName); return res; } - sync.SetCurrentFileName(fs2us(nextName)); + sync.Set_FilePath(fs2us(nextName)); for (;;) { UInt32 processedSize; @@ -336,15 +329,15 @@ HRESULT CThreadCombine::ProcessVirt() if (needSize != processedSize) throw g_Message_FileWriteError; pos += processedSize; - RINOK(sync.SetPosAndCheckPaused(pos)); + RINOK(sync.Set_NumBytesCur(pos)); } } return S_OK; } -extern void AddValuePair2(UINT resourceID, UInt32 langID, UInt64 num, UInt64 size, UString &s); +extern void AddValuePair2(UString &s, UINT resourceID, UInt64 num, UInt64 size); -static void AddInfoFileName(const UString &name, UString &dest) +static void AddInfoFileName(UString &dest, const UString &name) { dest += L"\n "; dest += name; @@ -356,7 +349,7 @@ void CApp::Combine() CPanel &srcPanel = Panels[srcPanelIndex]; if (!srcPanel.IsFSFolder()) { - srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED, 0x03020208); + srcPanel.MessageBoxErrorLang(IDS_OPERATION_IS_NOT_SUPPORTED); return; } CRecordVector indices; @@ -364,9 +357,9 @@ void CApp::Combine() if (indices.IsEmpty()) return; int index = indices[0]; - if (indices.Size() != 1 || srcPanel.IsItemFolder(index)) + if (indices.Size() != 1 || srcPanel.IsItem_Folder(index)) { - srcPanel.MessageBoxErrorLang(IDS_COMBINE_SELECT_ONE_FILE, 0x03020620); + srcPanel.MessageBoxErrorLang(IDS_COMBINE_SELECT_ONE_FILE); return; } const UString itemName = srcPanel.GetItemName(index); @@ -382,7 +375,7 @@ void CApp::Combine() CVolSeqName volSeqName; if (!volSeqName.ParseName(itemName)) { - srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_DETECT_SPLIT_FILE, 0x03020621); + srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_DETECT_SPLIT_FILE); return; } @@ -393,7 +386,7 @@ void CApp::Combine() combiner.TotalSize = 0; for (;;) { - NFile::NFind::CFileInfo fileInfo; + NFind::CFileInfo fileInfo; if (!fileInfo.Find(us2fs(srcPath + nextName)) || fileInfo.IsDir()) break; combiner.Names.Add(us2fs(nextName)); @@ -402,7 +395,7 @@ void CApp::Combine() } if (combiner.Names.Size() == 1) { - srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART, 0x03020622); + srcPanel.MessageBoxErrorLang(IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART); return; } @@ -413,38 +406,38 @@ void CApp::Combine() } UString info; - AddValuePair2(IDS_FILES_COLON, 0x02000320, combiner.Names.Size(), combiner.TotalSize, info); + AddValuePair2(info, IDS_PROP_FILES, combiner.Names.Size(), combiner.TotalSize); info += L"\n"; info += srcPath; - int i; + unsigned i; for (i = 0; i < combiner.Names.Size() && i < 2; i++) - AddInfoFileName(fs2us(combiner.Names[i]), info); + AddInfoFileName(info, fs2us(combiner.Names[i])); if (i != combiner.Names.Size()) { if (i + 1 != combiner.Names.Size()) - AddInfoFileName(L"...", info); - AddInfoFileName(fs2us(combiner.Names.Back()), info); + AddInfoFileName(info, L"..."); + AddInfoFileName(info, fs2us(combiner.Names.Back())); } { CCopyDialog copyDialog; copyDialog.Value = path; - copyDialog.Title = LangString(IDS_COMBINE, 0x03020600); + LangString(IDS_COMBINE, copyDialog.Title); copyDialog.Title += ' '; copyDialog.Title += srcPanel.GetItemRelPath(index); - copyDialog.Static = LangString(IDS_COMBINE_TO, 0x03020601); + LangString(IDS_COMBINE_TO, copyDialog.Static); copyDialog.Info = info; - if (copyDialog.Create(srcPanel.GetParent()) == IDCANCEL) + if (copyDialog.Create(srcPanel.GetParent()) != IDOK) return; path = copyDialog.Value; } - NFile::NName::NormalizeDirPathPrefix(path); - if (!NFile::NDirectory::CreateComplexDirectory(us2fs(path))) + NName::NormalizeDirPathPrefix(path); + if (!CreateComplexDir(us2fs(path))) { - srcPanel.MessageBoxMyError(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, 0x02000603, path)); + srcPanel.MessageBoxError2Lines(MyFormatNew(IDS_CANNOT_CREATE_FOLDER, path), ::GetLastError()); return; } @@ -458,24 +451,24 @@ void CApp::Combine() if (outName.IsEmpty()) outName = L"file"; - NFile::NFind::CFileInfo fileInfo; + NFind::CFileInfo fileInfo; UString destFilePath = path + outName; combiner.OutputPath = us2fs(destFilePath); if (fileInfo.Find(combiner.OutputPath)) { - srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, 0x03020A04, destFilePath)); + srcPanel.MessageBoxMyError(MyFormatNew(IDS_FILE_EXIST, destFilePath)); return; } CProgressDialog &progressDialog = combiner.ProgressDialog; progressDialog.ShowCompressionInfo = false; - UString progressWindowTitle = LangString(IDS_APP_TITLE, 0x03000000); - UString title = LangString(IDS_COMBINING, 0x03020610); + UString progressWindowTitle = L"7-Zip"; // LangString(IDS_APP_TITLE, 0x03000000); + UString title = LangString(IDS_COMBINING); progressDialog.MainWindow = _window; progressDialog.MainTitle = progressWindowTitle; - progressDialog.MainAddTitle = title + UString(L" "); + progressDialog.MainAddTitle = title + L' '; combiner.InputDirPrefix = us2fs(srcPath); @@ -487,8 +480,8 @@ void CApp::Combine() } RefreshTitleAlways(); - // disableTimerProcessing1.Restore(); - // disableTimerProcessing2.Restore(); + // disableNotify.Restore(); + // disableNotify.Restore(); // srcPanel.SetFocusToList(); // srcPanel.RefreshListCtrlSaveFocused(); } diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.cpp b/CPP/7zip/UI/FileManager/PasswordDialog.cpp old mode 100755 new mode 100644 index 92826a1f..6ead39c3 --- a/CPP/7zip/UI/FileManager/PasswordDialog.cpp +++ b/CPP/7zip/UI/FileManager/PasswordDialog.cpp @@ -9,42 +9,40 @@ #endif #ifdef LANG -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_STATIC_PASSWORD_HEADER, 0x02000B01 }, - { IDC_CHECK_PASSWORD_SHOW, 0x02000B02 }, - { IDOK, 0x02000702 }, - { IDCANCEL, 0x02000710 } + IDT_PASSWORD_ENTER, + IDX_PASSWORD_SHOW }; #endif void CPasswordDialog::ReadControls() { - _passwordControl.GetText(Password); - ShowPassword = IsButtonCheckedBool(IDC_CHECK_PASSWORD_SHOW); + _passwordEdit.GetText(Password); + ShowPassword = IsButtonCheckedBool(IDX_PASSWORD_SHOW); } void CPasswordDialog::SetTextSpec() { - _passwordControl.SetPasswordChar(ShowPassword ? 0: TEXT('*')); - _passwordControl.SetText(Password); + _passwordEdit.SetPasswordChar(ShowPassword ? 0: TEXT('*')); + _passwordEdit.SetText(Password); } bool CPasswordDialog::OnInit() { #ifdef LANG - LangSetWindowText(HWND(*this), 0x02000B00); - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetWindowText(*this, IDD_PASSWORD); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); #endif - _passwordControl.Attach(GetItem(IDC_EDIT_PASSWORD)); - CheckButton(IDC_CHECK_PASSWORD_SHOW, ShowPassword); + _passwordEdit.Attach(GetItem(IDE_PASSWORD_PASSWORD)); + CheckButton(IDX_PASSWORD_SHOW, ShowPassword); SetTextSpec(); return CModalDialog::OnInit(); } bool CPasswordDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { - if (buttonID == IDC_CHECK_PASSWORD_SHOW) + if (buttonID == IDX_PASSWORD_SHOW) { ReadControls(); SetTextSpec(); diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.h b/CPP/7zip/UI/FileManager/PasswordDialog.h old mode 100755 new mode 100644 index 1d903249..339ebdaf --- a/CPP/7zip/UI/FileManager/PasswordDialog.h +++ b/CPP/7zip/UI/FileManager/PasswordDialog.h @@ -3,13 +3,15 @@ #ifndef __PASSWORD_DIALOG_H #define __PASSWORD_DIALOG_H -#include "Windows/Control/Dialog.h" -#include "Windows/Control/Edit.h" +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/Edit.h" + #include "PasswordDialogRes.h" class CPasswordDialog: public NWindows::NControl::CModalDialog { - NWindows::NControl::CEdit _passwordControl; + NWindows::NControl::CEdit _passwordEdit; + virtual void OnOK(); virtual bool OnInit(); virtual bool OnButtonClicked(int buttonID, HWND buttonHWND); @@ -18,8 +20,9 @@ class CPasswordDialog: public NWindows::NControl::CModalDialog public: UString Password; bool ShowPassword; + CPasswordDialog(): ShowPassword(false) {} - INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_DIALOG_PASSWORD, parentWindow); } + INT_PTR Create(HWND parentWindow = 0) { return CModalDialog::Create(IDD_PASSWORD, parentWindow); } }; #endif diff --git a/CPP/7zip/UI/FileManager/PasswordDialog.rc b/CPP/7zip/UI/FileManager/PasswordDialog.rc old mode 100755 new mode 100644 index 2328ac56..90c57efa --- a/CPP/7zip/UI/FileManager/PasswordDialog.rc +++ b/CPP/7zip/UI/FileManager/PasswordDialog.rc @@ -4,11 +4,11 @@ #define xc 140 #define yc 72 -IDD_DIALOG_PASSWORD MY_DIALOG +IDD_PASSWORD DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT CAPTION "Enter password" BEGIN - LTEXT "&Enter password:", IDC_STATIC_PASSWORD_HEADER, m, m, xc, 8 - EDITTEXT IDC_EDIT_PASSWORD, m, 20, xc, 14, ES_PASSWORD | ES_AUTOHSCROLL - CONTROL "&Show password", IDC_CHECK_PASSWORD_SHOW, MY_CHECKBOX, m, 42, xc, 10 + LTEXT "&Enter password:", IDT_PASSWORD_ENTER, m, m, xc, 8 + EDITTEXT IDE_PASSWORD_PASSWORD, m, 20, xc, 14, ES_PASSWORD | ES_AUTOHSCROLL + CONTROL "&Show password", IDX_PASSWORD_SHOW, MY_CHECKBOX, m, 42, xc, 10 OK_CANCEL END diff --git a/CPP/7zip/UI/FileManager/PasswordDialogRes.h b/CPP/7zip/UI/FileManager/PasswordDialogRes.h old mode 100755 new mode 100644 index e0b42661..1fe32e10 --- a/CPP/7zip/UI/FileManager/PasswordDialogRes.h +++ b/CPP/7zip/UI/FileManager/PasswordDialogRes.h @@ -1,4 +1,5 @@ -#define IDD_DIALOG_PASSWORD 501 -#define IDC_STATIC_PASSWORD_HEADER 1000 -#define IDC_EDIT_PASSWORD 1001 -#define IDC_CHECK_PASSWORD_SHOW 1002 +#define IDD_PASSWORD 3800 +#define IDT_PASSWORD_ENTER 3801 +#define IDX_PASSWORD_SHOW 3803 + +#define IDE_PASSWORD_PASSWORD 120 diff --git a/CPP/7zip/UI/FileManager/PluginInterface.h b/CPP/7zip/UI/FileManager/PluginInterface.h old mode 100755 new mode 100644 index 72711fde..3ce5fa8e --- a/CPP/7zip/UI/FileManager/PluginInterface.h +++ b/CPP/7zip/UI/FileManager/PluginInterface.h @@ -11,7 +11,7 @@ PLUGIN_INTERFACE(IInitContextMenu, 0x00) { - STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UINT32 numFiles) PURE; + STDMETHOD(InitContextMenu)(const wchar_t *folder, const wchar_t **names, UInt32 numFiles) PURE; }; PLUGIN_INTERFACE(IPluginOptionsCallback, 0x01) diff --git a/CPP/7zip/UI/FileManager/PluginLoader.h b/CPP/7zip/UI/FileManager/PluginLoader.h old mode 100755 new mode 100644 index cb7d4d7c..fed38d65 --- a/CPP/7zip/UI/FileManager/PluginLoader.h +++ b/CPP/7zip/UI/FileManager/PluginLoader.h @@ -3,19 +3,17 @@ #ifndef __PLUGIN_LOADER_H #define __PLUGIN_LOADER_H -#include "Windows/DLL.h" +#include "../../../Windows/DLL.h" #include "IFolder.h" -typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject); - class CPluginLibrary: public NWindows::NDLL::CLibrary { public: HRESULT CreateManager(REFGUID clsID, IFolderManager **manager) { - CreateObjectPointer createObject = (CreateObjectPointer)GetProc("CreateObject"); - if (createObject == NULL) + Func_CreateObject createObject = (Func_CreateObject)GetProc("CreateObject"); + if (!createObject) return GetLastError(); return createObject(&clsID, &IID_IFolderManager, (void **)manager); } diff --git a/CPP/7zip/UI/FileManager/PluginsPage.cpp b/CPP/7zip/UI/FileManager/PluginsPage.cpp old mode 100755 new mode 100644 index 0eeec9d6..39671b75 --- a/CPP/7zip/UI/FileManager/PluginsPage.cpp +++ b/CPP/7zip/UI/FileManager/PluginsPage.cpp @@ -13,19 +13,19 @@ #include "ProgramLocation.h" #include "PluginInterface.h" -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_PLUGINS_STATIC_PLUGINS, 0x03010101}, - { IDC_PLUGINS_BUTTON_OPTIONS, 0x03010110} + IDT_PLUGINS_PLUGINS, + IDB_PLUGINS_OPTIONS }; static LPCWSTR kPluginsTopic = L"FM/options.htm#plugins"; bool CPluginsPage::OnInit() { - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); - _listView.Attach(GetItem(IDC_PLUGINS_LIST)); + _listView.Attach(GetItem(IDL_PLUGINS)); UINT32 newFlags = /* LVS_EX_CHECKBOXES | */ LVS_EX_FULLROWSELECT; _listView.SetExtendedListViewStyle(newFlags, newFlags); @@ -83,7 +83,7 @@ bool CPluginsPage::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { - case IDC_PLUGINS_BUTTON_OPTIONS: + case IDB_PLUGINS_OPTIONS: OnButtonOptions(); break; default: @@ -148,32 +148,32 @@ void CPluginsPage::OnButtonOptions() CPluginInfo pluginInfo = _plugins[index]; if (!pluginInfo.OptionsClassIDDefined) { - MessageBoxW(HWND(*this), L"There are no options", L"7-Zip", 0); + MessageBoxW(*this, L"There are no options", L"7-Zip", 0); return; } NWindows::NDLL::CLibrary lib; CMyComPtr pluginOptions; if (!lib.Load(pluginInfo.FilePath)) { - MessageBoxW(HWND(*this), L"Can't load plugin", L"7-Zip", 0); + MessageBoxW(*this, L"Can't load plugin", L"7-Zip", 0); return; } typedef UINT32 (WINAPI * CreateObjectPointer)(const GUID *clsID, const GUID *interfaceID, void **outObject); CreateObjectPointer createObject = (CreateObjectPointer)lib.GetProc("CreateObject"); if (createObject == NULL) { - MessageBoxW(HWND(*this), L"Incorrect plugin", L"7-Zip", 0); + MessageBoxW(*this, L"Incorrect plugin", L"7-Zip", 0); return; } if (createObject(&pluginInfo.OptionsClassID, &IID_IPluginOptions, (void **)&pluginOptions) != S_OK) { - MessageBoxW(HWND(*this), L"There are no options", L"7-Zip", 0); + MessageBoxW(*this, L"There are no options", L"7-Zip", 0); return; } CPluginOptionsCallback *callbackSpec = new CPluginOptionsCallback; CMyComPtr callback(callbackSpec); callbackSpec->Init(pluginInfo.Name); - pluginOptions->PluginOptions(HWND(*this), callback); + pluginOptions->PluginOptions(*this, callback); } bool CPluginsPage::OnNotify(UINT controlID, LPNMHDR lParam) diff --git a/CPP/7zip/UI/FileManager/PluginsPage.h b/CPP/7zip/UI/FileManager/PluginsPage.h old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/PluginsPage.rc b/CPP/7zip/UI/FileManager/PluginsPage.rc old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/PluginsPageRes.h b/CPP/7zip/UI/FileManager/PluginsPageRes.h old mode 100755 new mode 100644 index ca07ca5c..81196d3c --- a/CPP/7zip/UI/FileManager/PluginsPageRes.h +++ b/CPP/7zip/UI/FileManager/PluginsPageRes.h @@ -1,4 +1,4 @@ -#define IDD_PLUGINS 541 -#define IDC_PLUGINS_STATIC_PLUGINS 1000 -#define IDC_PLUGINS_LIST 1001 -#define IDC_PLUGINS_BUTTON_OPTIONS 1002 +#define IDD_PLUGINS 999 +#define IDT_PLUGINS_PLUGINS 999 +#define IDL_PLUGINS 999 +#define IDB_PLUGINS_OPTIONS 999 diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.cpp b/CPP/7zip/UI/FileManager/ProgramLocation.cpp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/ProgramLocation.h b/CPP/7zip/UI/FileManager/ProgramLocation.h old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.cpp b/CPP/7zip/UI/FileManager/ProgressDialog.cpp old mode 100755 new mode 100644 index cdb8399e..6c185769 --- a/CPP/7zip/UI/FileManager/ProgressDialog.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#include "Common/IntToString.h" +#include "../../../Common/IntToString.h" #include "resource.h" @@ -19,13 +19,6 @@ static const UINT kTimerElapse = 100; #include "LangUtils.h" #endif -#ifdef LANG -static CIDLangPair kIDLangPairs[] = -{ - { IDCANCEL, 0x02000711 } -}; -#endif - HRESULT CProgressSync::ProcessStopAndPause() { for (;;) @@ -54,15 +47,14 @@ void CProgressDialog::AddToTitle(LPCWSTR s) bool CProgressDialog::OnInit() { - _range = (UInt64)-1; + _range = (UInt64)(Int64)-1; _prevPercentValue = -1; _wasCreated = true; _dialogCreatedEvent.Set(); #ifdef LANG - // LangSetWindowText(HWND(*this), 0x02000C00); - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItemsText(*this, NULL, 0); #endif m_ProgressBar.Attach(GetItem(IDC_PROGRESS1)); @@ -173,7 +165,7 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) bool paused = Sync.GetPaused(); Sync.SetPaused(true); _inCancelMessageBox = true; - int res = ::MessageBoxW(HWND(*this), L"Are you sure you want to cancel?", _title, MB_YESNOCANCEL); + int res = ::MessageBoxW(*this, L"Are you sure you want to cancel?", _title, MB_YESNOCANCEL); _inCancelMessageBox = false; Sync.SetPaused(paused); if (res == IDCANCEL || res == IDNO) diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.h b/CPP/7zip/UI/FileManager/ProgressDialog.h old mode 100755 new mode 100644 index 429ed740..175db017 --- a/CPP/7zip/UI/FileManager/ProgressDialog.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog.h @@ -3,11 +3,11 @@ #ifndef __PROGRESS_DIALOG_H #define __PROGRESS_DIALOG_H -#include "Windows/Synchronization.h" -#include "Windows/Thread.h" +#include "../../../Windows/Synchronization.h" +#include "../../../Windows/Thread.h" -#include "Windows/Control/Dialog.h" -#include "Windows/Control/ProgressBar.h" +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/ProgressBar.h" #include "ProgressDialogRes.h" @@ -136,14 +136,14 @@ public: INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0) { _title = title; - INT_PTR res = CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); + INT_PTR res = CModalDialog::Create(IDD_PROGRESS, wndParent); thread.Wait(); return res; } enum { - kCloseMessage = WM_USER + 1 + kCloseMessage = WM_APP + 1 }; virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); diff --git a/CPP/7zip/UI/FileManager/ProgressDialog.rc b/CPP/7zip/UI/FileManager/ProgressDialog.rc old mode 100755 new mode 100644 index 3a65338f..55d99233 --- a/CPP/7zip/UI/FileManager/ProgressDialog.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog.rc @@ -4,7 +4,7 @@ #define xc 172 #define yc 44 -IDD_DIALOG_PROGRESS MY_DIALOG +IDD_PROGRESS DIALOG 0, 0, xs, ys MY_MODAL_DIALOG_STYLE MY_FONT CAPTION "Progress" BEGIN PUSHBUTTON "Cancel", IDCANCEL, bx, by, bxs, bys diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp old mode 100755 new mode 100644 index a4ff7f58..bccb6e88 --- a/CPP/7zip/UI/FileManager/ProgressDialog2.cpp +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.cpp @@ -2,11 +2,11 @@ #include "StdAfx.h" -#include "Common/IntToString.h" -#include "Common/StringConvert.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/StringConvert.h" -#include "Windows/Control/Static.h" -#include "Windows/Error.h" +#include "../../../Windows/Control/Static.h" +#include "../../../Windows/ErrorMsg.h" #include "ProgressDialog2.h" #include "DialogSize.h" @@ -21,7 +21,8 @@ extern HINSTANCE g_hInstance; static const UINT_PTR kTimerID = 3; -static const UINT kCloseMessage = WM_USER + 1; +static const UINT kCloseMessage = WM_APP + 1; +// we can't use WM_USER, since WM_USER can be used by standard Windows procedure for Dialog static const UINT kTimerElapse = #ifdef UNDER_CE @@ -31,51 +32,194 @@ static const UINT kTimerElapse = #endif ; +static const UINT kCreateDelay = + #ifdef UNDER_CE + 2500 + #else + 500 + #endif + ; + +static const DWORD kPauseSleepTime = 100; + #include "LangUtils.h" #ifdef LANG -static CIDLangPair kIDLangPairs[] = + +static const UInt32 kLangIDs[] = +{ + IDT_PROGRESS_ELAPSED, + IDT_PROGRESS_REMAINING, + IDT_PROGRESS_TOTAL, + IDT_PROGRESS_SPEED, + IDT_PROGRESS_PROCESSED, + IDT_PROGRESS_RATIO, + IDT_PROGRESS_ERRORS, + IDB_PROGRESS_BACKGROUND, + IDB_PAUSE +}; + +static const UInt32 kLangIDs_Colon[] = { - { IDCANCEL, 0x02000C00 }, - { IDC_PROGRESS_ELAPSED, 0x02000C01 }, - { IDC_PROGRESS_REMAINING, 0x02000C02 }, - { IDC_PROGRESS_TOTAL, 0x02000C03 }, - { IDC_PROGRESS_SPEED, 0x02000C04 }, - { IDC_PROGRESS_UNPACKED, 0x02000C05 }, - { IDC_PROGRESS_PACKED, 0x02000323 }, - { IDC_PROGRESS_RATIO, 0x02000C06 }, - { IDC_PROGRESS_SPEED, 0x02000C04 }, - { IDC_PROGRESS_FILES, 0x02000320 }, - { IDC_PROGRESS_ERRORS, 0x0308000A }, - { IDC_BUTTON_PROGRESS_PRIORITY, 0x02000C10 }, - { IDC_BUTTON_PAUSE, 0x02000C12 }, - { IDCANCEL, 0x02000711 }, + IDT_PROGRESS_PACKED, + IDT_PROGRESS_FILES }; + #endif -HRESULT CProgressSync::ProcessStopAndPause() + +#define UNDEFINED_VAL ((UInt64)(Int64)-1) +#define INIT_AS_UNDEFINED(v) v = UNDEFINED_VAL; +#define IS_UNDEFINED_VAL(v) ((v) == UNDEFINED_VAL) +#define IS_DEFINED_VAL(v) ((v) != UNDEFINED_VAL) + +CProgressSync::CProgressSync(): + _stopped(false), _paused(false), + _bytesProgressMode(true), + _totalBytes(UNDEFINED_VAL), _completedBytes(0), + _totalFiles(UNDEFINED_VAL), _curFiles(0), + _inSize(UNDEFINED_VAL), + _outSize(UNDEFINED_VAL), + _isDir(false) + {} + +#define CHECK_STOP if (_stopped) return E_ABORT; if (!_paused) return S_OK; +#define CRITICAL_LOCK NSynchronization::CCriticalSectionLock lock(_cs); + +bool CProgressSync::Get_Paused() +{ + CRITICAL_LOCK + return _paused; +} + +HRESULT CProgressSync::CheckStop() { for (;;) { - if (GetStopped()) - return E_ABORT; - if (!GetPaused()) - break; - ::Sleep(100); + { + CRITICAL_LOCK + CHECK_STOP + } + ::Sleep(kPauseSleepTime); } - return S_OK; } -HRESULT CProgressSync::SetPosAndCheckPaused(UInt64 completed) +HRESULT CProgressSync::ScanProgress(UInt64 numFiles, UInt64 totalSize, const UString &fileName, bool isDir) { - RINOK(ProcessStopAndPause()); - SetPos(completed); - return S_OK; + { + CRITICAL_LOCK + _totalFiles = numFiles; + _totalBytes = totalSize; + _filePath = fileName; + _isDir = isDir; + // _completedBytes = 0; + CHECK_STOP + } + return CheckStop(); +} + +void CProgressSync::Set_NumFilesTotal(UInt64 val) +{ + CRITICAL_LOCK + _totalFiles = val; +} + +void CProgressSync::Set_NumBytesTotal(UInt64 val) +{ + CRITICAL_LOCK + _totalBytes = val; +} + +void CProgressSync::Set_NumFilesCur(UInt64 val) +{ + CRITICAL_LOCK + _curFiles = val; +} + +HRESULT CProgressSync::Set_NumBytesCur(const UInt64 *val) +{ + { + CRITICAL_LOCK + if (val) + _completedBytes = *val; + CHECK_STOP + } + return CheckStop(); +} + +HRESULT CProgressSync::Set_NumBytesCur(UInt64 val) +{ + { + CRITICAL_LOCK + _completedBytes = val; + CHECK_STOP + } + return CheckStop(); +} + +void CProgressSync::Set_Ratio(const UInt64 *inSize, const UInt64 *outSize) +{ + CRITICAL_LOCK + if (inSize) + _inSize = *inSize; + if (outSize) + _outSize = *outSize; +} + +void CProgressSync::Set_TitleFileName(const UString &fileName) +{ + CRITICAL_LOCK + _titleFileName = fileName; +} +void CProgressSync::Set_Status(const UString &s) +{ + CRITICAL_LOCK + _status = s; +} + +void CProgressSync::Set_FilePath(const UString &path, bool isDir) +{ + CRITICAL_LOCK + _filePath = path; + _isDir = isDir; } +void CProgressSync::AddError_Message(const wchar_t *message) +{ + CRITICAL_LOCK + Messages.Add(message); +} + +void CProgressSync::AddError_Message_Name(const wchar_t *message, const wchar_t *name) +{ + UString s; + if (name && *name != 0) + s += name; + if (message && *message != 0 ) + { + if (!s.IsEmpty()) + s += L'\n'; + s += message; + if (!s.IsEmpty() && s.Back() == L'\n') + s.DeleteBack(); + } + AddError_Message(s); +} + +void CProgressSync::AddError_Code_Name(DWORD systemError, const wchar_t *name) +{ + UString s = NError::MyFormatMessage(systemError); + if (systemError == 0) + s = L"Error"; + AddError_Message_Name(s, name); +} + CProgressDialog::CProgressDialog(): _timer(0), CompressingMode(true), MainWindow(0) { + _isDir = false; + + _numMessages = 0; IconID = -1; MessagesDisplayed = false; _wasCreated = false; @@ -100,6 +244,7 @@ CProgressDialog::CProgressDialog(): _timer(0), CompressingMode(true), MainWindow } #ifndef _SFX + CProgressDialog::~CProgressDialog() { SetTaskbarProgressState(TBPF_NOPROGRESS); @@ -110,7 +255,7 @@ void CProgressDialog::AddToTitle(LPCWSTR s) if (MainWindow != 0) { CWindow window(MainWindow); - window.SetText(s + UString(MainTitle)); + window.SetText((UString)s + MainTitle); } } @@ -122,7 +267,7 @@ void CProgressDialog::SetTaskbarProgressState() if (_taskbarList && _hwndForTaskbar) { TBPFLAG tbpFlags; - if (Sync.GetPaused()) + if (Sync.Get_Paused()) tbpFlags = TBPF_PAUSED; else tbpFlags = _errorsWereDisplayed ? TBPF_ERROR: TBPF_NORMAL; @@ -130,21 +275,22 @@ void CProgressDialog::SetTaskbarProgressState() } } -static const int kTitleFileNameSizeLimit = 36; -static const int kCurrentFileNameSizeLimit = 82; +static const unsigned kTitleFileNameSizeLimit = 36; +static const unsigned kCurrentFileNameSizeLimit = 82; -static void ReduceString(UString &s, int size) +static void ReduceString(UString &s, unsigned size) { - if (s.Length() > size) - s = s.Left(size / 2) + UString(L" ... ") + s.Right(size / 2); + if (s.Len() <= size) + return; + s.Delete(size / 2, s.Len() - size); + s.Insert(size / 2, L" ... "); } void CProgressDialog::EnableErrorsControls(bool enable) { - int cmdShow = enable ? SW_SHOW : SW_HIDE; - ShowItem(IDC_PROGRESS_ERRORS, cmdShow); - ShowItem(IDC_PROGRESS_ERRORS_VALUE, cmdShow); - ShowItem(IDC_PROGRESS_LIST, cmdShow); + ShowItem_Bool(IDT_PROGRESS_ERRORS, enable); + ShowItem_Bool(IDT_PROGRESS_ERRORS_VAL, enable); + ShowItem_Bool(IDL_PROGRESS_MESSAGES, enable); } bool CProgressDialog::OnInit() @@ -153,67 +299,75 @@ bool CProgressDialog::OnInit() if (!_hwndForTaskbar) _hwndForTaskbar = GetParent(); if (!_hwndForTaskbar) - _hwndForTaskbar = (HWND)*this; - - _range = (UInt64)(Int64)-1; - _prevPercentValue = (UInt32)-1; - _prevElapsedSec = (UInt32)-1; - _prevRemainingSec = (UInt32)-1; - _prevSpeed = (UInt32)-1; - _prevMode = kSpeedBytes; + _hwndForTaskbar = *this; + + INIT_AS_UNDEFINED(_progressBar_Range); + INIT_AS_UNDEFINED(_progressBar_Pos); + + INIT_AS_UNDEFINED(_prevPercentValue); + INIT_AS_UNDEFINED(_prevElapsedSec); + INIT_AS_UNDEFINED(_prevRemainingSec); + + INIT_AS_UNDEFINED(_prevSpeed); + _prevSpeed_MoveBits = 0; + _prevTime = ::GetTickCount(); _elapsedTime = 0; + + INIT_AS_UNDEFINED(_totalBytes_Prev); + INIT_AS_UNDEFINED(_processed_Prev); + INIT_AS_UNDEFINED(_packed_Prev); + INIT_AS_UNDEFINED(_ratio_Prev); + _filesStr_Prev.Empty(); + _foreground = true; m_ProgressBar.Attach(GetItem(IDC_PROGRESS1)); - _messageList.Attach(GetItem(IDC_PROGRESS_LIST)); + _messageList.Attach(GetItem(IDL_PROGRESS_MESSAGES)); _messageList.SetUnicodeFormat(); _wasCreated = true; _dialogCreatedEvent.Set(); #ifdef LANG - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); + LangSetDlgItems_Colon(*this, kLangIDs_Colon, ARRAY_SIZE(kLangIDs_Colon)); #endif - CWindow window(GetItem(IDC_BUTTON_PROGRESS_PRIORITY)); - window.GetText(backgroundString); - backgroundedString = backgroundString; - backgroundedString.Replace(L"&", L""); + CWindow window(GetItem(IDB_PROGRESS_BACKGROUND)); + window.GetText(_background_String); + _backgrounded_String = _background_String; + _backgrounded_String.RemoveChar(L'&'); - window = GetItem(IDC_BUTTON_PAUSE); - window.GetText(pauseString); + window = GetItem(IDB_PAUSE); + window.GetText(_pause_String); - foregroundString = LangStringSpec(IDS_PROGRESS_FOREGROUND, 0x02000C11); - continueString = LangStringSpec(IDS_PROGRESS_CONTINUE, 0x02000C13); - pausedString = LangStringSpec(IDS_PROGRESS_PAUSED, 0x02000C20); + LangString(IDS_PROGRESS_FOREGROUND, _foreground_String); + LangString(IDS_CONTINUE, _continue_String); + LangString(IDS_PROGRESS_PAUSED, _paused_String); SetText(_title); SetPauseText(); SetPriorityText(); _messageList.InsertColumn(0, L"", 30); - - const UString s = LangStringSpec(IDS_MESSAGES_DIALOG_MESSAGE_COLUMN, 0x02000A80); - - _messageList.InsertColumn(1, s, 600); + _messageList.InsertColumn(1, L"", 600); _messageList.SetColumnWidthAuto(0); _messageList.SetColumnWidthAuto(1); - EnableErrorsControls(false); - GetItemSizes(IDCANCEL, buttonSizeX, buttonSizeY); + GetItemSizes(IDCANCEL, _buttonSizeX, _buttonSizeY); _numReduceSymbols = kCurrentFileNameSizeLimit; NormalizeSize(true); if (!ShowCompressionInfo) { - HideItem(IDC_PROGRESS_PACKED); - HideItem(IDC_PROGRESS_PACKED_VALUE); - HideItem(IDC_PROGRESS_RATIO); - HideItem(IDC_PROGRESS_RATIO_VALUE); + HideItem(IDT_PROGRESS_PACKED); + HideItem(IDT_PROGRESS_PACKED_VAL); + HideItem(IDT_PROGRESS_RATIO); + HideItem(IDT_PROGRESS_RATIO_VAL); } if (IconID >= 0) @@ -234,22 +388,35 @@ bool CProgressDialog::OnInit() return CModalDialog::OnInit(); } +static const UINT kIDs[] = +{ + IDT_PROGRESS_ELAPSED, IDT_PROGRESS_ELAPSED_VAL, + IDT_PROGRESS_REMAINING, IDT_PROGRESS_REMAINING_VAL, + IDT_PROGRESS_FILES, IDT_PROGRESS_FILES_VAL, + IDT_PROGRESS_RATIO, IDT_PROGRESS_RATIO_VAL, + IDT_PROGRESS_ERRORS, IDT_PROGRESS_ERRORS_VAL, + + IDT_PROGRESS_TOTAL, IDT_PROGRESS_TOTAL_VAL, + IDT_PROGRESS_SPEED, IDT_PROGRESS_SPEED_VAL, + IDT_PROGRESS_PROCESSED, IDT_PROGRESS_PROCESSED_VAL, + IDT_PROGRESS_PACKED, IDT_PROGRESS_PACKED_VAL +}; + bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) { int sY; int sStep; int mx, my; { - RECT rect; - GetClientRectOfItem(IDC_PROGRESS_ELAPSED, rect); - mx = rect.left; - my = rect.top; - sY = rect.bottom - rect.top; - GetClientRectOfItem(IDC_PROGRESS_REMAINING, rect); - sStep = rect.top - my; + RECT r; + GetClientRectOfItem(IDT_PROGRESS_ELAPSED, r); + mx = r.left; + my = r.top; + sY = RECT_SIZE_Y(r); + GetClientRectOfItem(IDT_PROGRESS_REMAINING, r); + sStep = r.top - my; } - InvalidateRect(NULL); int xSizeClient = xSize - mx * 2; @@ -262,12 +429,13 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) _numReduceSymbols = i / 4; } - int yPos = ySize - my - buttonSizeY; + int yPos = ySize - my - _buttonSizeY; - ChangeSubWindowSizeX(GetItem(IDC_PROGRESS_FILE_NAME), xSize - mx * 2); + ChangeSubWindowSizeX(GetItem(IDT_PROGRESS_STATUS), xSize - mx * 2); + ChangeSubWindowSizeX(GetItem(IDT_PROGRESS_FILE_NAME), xSize - mx * 2); ChangeSubWindowSizeX(GetItem(IDC_PROGRESS1), xSize - mx * 2); - int bSizeX = buttonSizeX; + int bSizeX = _buttonSizeX; int mx2 = mx; for (;; mx2--) { @@ -284,11 +452,11 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) bSizeX = 2; { - RECT rect; - GetClientRectOfItem(IDC_PROGRESS_LIST, rect); - int y = rect.top; + RECT r; + GetClientRectOfItem(IDL_PROGRESS_MESSAGES, r); + int y = r.top; int ySize2 = yPos - my - y; - const int kMinYSize = buttonSizeY + buttonSizeY * 3 / 4; + const int kMinYSize = _buttonSizeY + _buttonSizeY * 3 / 4; int xx = xSize - mx * 2; if (ySize2 < kMinYSize) { @@ -303,11 +471,11 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) { int xPos = xSize - mx; xPos -= bSizeX; - MoveItem(IDCANCEL, xPos, yPos, bSizeX, buttonSizeY); + MoveItem(IDCANCEL, xPos, yPos, bSizeX, _buttonSizeY); xPos -= (mx2 + bSizeX); - MoveItem(IDC_BUTTON_PAUSE, xPos, yPos, bSizeX, buttonSizeY); + MoveItem(IDB_PAUSE, xPos, yPos, bSizeX, _buttonSizeY); xPos -= (mx2 + bSizeX); - MoveItem(IDC_BUTTON_PROGRESS_PRIORITY, xPos, yPos, bSizeX, buttonSizeY); + MoveItem(IDB_PROGRESS_BACKGROUND, xPos, yPos, bSizeX, _buttonSizeY); } int valueSize; @@ -315,7 +483,7 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) int padSize; labelSize = Units_To_Pixels_X(MY_PROGRESS_LABEL_UNITS_MIN); - valueSize = Units_To_Pixels_X(MY_PROGRESS_VALUE_UNITS); + valueSize = Units_To_Pixels_X(MY_PROGRESS_VAL_UNITS); padSize = Units_To_Pixels_X(MY_PROGRESS_PAD_UNITS); int requiredSize = (labelSize + valueSize) * 2 + padSize; @@ -337,22 +505,8 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) labelSize = gSize - valueSize; - UINT IDs[] = - { - IDC_PROGRESS_ELAPSED, IDC_PROGRESS_ELAPSED_VALUE, - IDC_PROGRESS_REMAINING, IDC_PROGRESS_REMAINING_VALUE, - IDC_PROGRESS_FILES, IDC_PROGRESS_FILES_VALUE, - IDC_PROGRESS_RATIO, IDC_PROGRESS_RATIO_VALUE, - IDC_PROGRESS_ERRORS, IDC_PROGRESS_ERRORS_VALUE, - - IDC_PROGRESS_TOTAL, IDC_PROGRESS_TOTAL_VALUE, - IDC_PROGRESS_SPEED, IDC_PROGRESS_SPEED_VALUE, - IDC_PROGRESS_UNPACKED, IDC_PROGRESS_UNPACKED_VALUE, - IDC_PROGRESS_PACKED, IDC_PROGRESS_PACKED_VALUE - }; - yPos = my; - for (int i = 0; i < sizeof(IDs) / sizeof(IDs[0]); i += 2) + for (int i = 0; i < ARRAY_SIZE(kIDs); i += 2) { int x = mx; const int kNumColumn1Items = 5 * 2; @@ -362,281 +516,371 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) yPos = my; x = mx + gSize + padSize; } - MoveItem(IDs[i], x, yPos, labelSize, sY); - MoveItem(IDs[i + 1], x + labelSize, yPos, valueSize, sY); + MoveItem(kIDs[i], x, yPos, labelSize, sY); + MoveItem(kIDs[i + 1], x + labelSize, yPos, valueSize, sY); yPos += sStep; } return false; } -void CProgressDialog::OnCancel() { Sync.SetStopped(true); } +void CProgressDialog::OnCancel() { Sync.Set_Stopped(true); } void CProgressDialog::OnOK() { } -static void ConvertSizeToString(UInt64 value, wchar_t *s) +void CProgressDialog::SetProgressRange(UInt64 range) { - const wchar_t *kModif = L" KM"; - for (int i = 0; ; i++) - if (i == 2 || value < (UInt64(10000) << (i * 10))) - { - ConvertUInt64ToString(value >> (i * 10), s); - s += wcslen(s); - *s++ = ' '; - if (i != 0) - *s++ = kModif[i]; - *s++ = L'B'; - *s++ = L'\0'; - return; - } + if (range == _progressBar_Range) + return; + _progressBar_Range = range; + INIT_AS_UNDEFINED(_progressBar_Pos); + _progressConv.Init(range); + m_ProgressBar.SetRange32(0, _progressConv.Count(range)); } -void CProgressDialog::SetRange(UInt64 range) +void CProgressDialog::SetProgressPos(UInt64 pos) { - _range = range; - _previousPos = (UInt64)(Int64)-1; - _converter.Init(range); - m_ProgressBar.SetRange32(0, _converter.Count(range)); + if (pos >= _progressBar_Range || + pos <= _progressBar_Pos || + pos - _progressBar_Pos >= (_progressBar_Range >> 10)) + { + m_ProgressBar.SetPos(_progressConv.Count(pos)); + if (_taskbarList && _hwndForTaskbar) + _taskbarList->SetProgressValue(_hwndForTaskbar, pos, _progressBar_Range); + _progressBar_Pos = pos; + } } -void CProgressDialog::SetPos(UInt64 pos) +#define UINT_TO_STR_2(val) { s[0] = (wchar_t)('0' + (val) / 10); s[1] = (wchar_t)('0' + (val) % 10); s += 2; } + +void GetTimeString(UInt64 timeValue, wchar_t *s) { - bool redraw = true; - if (pos < _range && pos > _previousPos) + UInt64 hours = timeValue / 3600; + UInt32 seconds = (UInt32)(timeValue - hours * 3600); + UInt32 minutes = seconds / 60; + seconds %= 60; + if (hours > 99) { - if (pos - _previousPos < (_range >> 10)) - redraw = false; + ConvertUInt64ToString(hours, s); + for (; *s != 0; s++); } - if (redraw) + else { - m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100% - if (_taskbarList && _hwndForTaskbar) - _taskbarList->SetProgressValue(_hwndForTaskbar, pos, _range); - _previousPos = pos; + UInt32 hours32 = (UInt32)hours; + UINT_TO_STR_2(hours32); } + *s++ = ':'; UINT_TO_STR_2(minutes); + *s++ = ':'; UINT_TO_STR_2(seconds); + *s = 0; } -static void GetTimeString(UInt64 timeValue, TCHAR *s) +static void ConvertSizeToString(UInt64 v, wchar_t *s) { - wsprintf(s, TEXT("%02d:%02d:%02d"), - UInt32(timeValue / 3600), - UInt32((timeValue / 60) % 60), - UInt32(timeValue % 60)); + Byte c = 0; + if (v >= ((UInt64)100000 << 20)) { v >>= 30; c = 'G'; } + else if (v >= ((UInt64)100000 << 10)) { v >>= 20; c = 'M'; } + else if (v >= ((UInt64)100000 << 0)) { v >>= 10; c = 'K'; } + ConvertUInt64ToString(v, s); + if (c != 0) + { + s += MyStringLen(s); + *s++ = ' '; + *s++ = c; + *s++ = 0; + } } -void CProgressDialog::ShowSize(int id, UInt64 value) +void CProgressDialog::ShowSize(int id, UInt64 val, UInt64 &prev) { + if (val == prev) + return; + prev = val; wchar_t s[40]; s[0] = 0; - if (value != (UInt64)(Int64)-1) - ConvertSizeToString(value, s); + if (IS_DEFINED_VAL(val)) + ConvertSizeToString(val, s); SetItemText(id, s); } +static void GetChangedString(const UString &newStr, UString &prevStr, bool &hasChanged) +{ + hasChanged = !(prevStr == newStr); + if (hasChanged) + prevStr = newStr; +} + +static unsigned GetPower32(UInt32 val) +{ + const unsigned kStart = 32; + UInt32 mask = ((UInt32)1 << (kStart - 1)); + for (unsigned i = kStart;; i--) + { + if (i == 0 || (val & mask) != 0) + return i; + mask >>= 1; + } +} + +static unsigned GetPower64(UInt64 val) +{ + UInt32 high = (UInt32)(val >> 32); + if (high == 0) + return GetPower32((UInt32)val); + return GetPower32(high) + 32; + +} + +static UInt64 MyMultAndDiv(UInt64 mult1, UInt64 mult2, UInt64 divider) +{ + unsigned pow1 = GetPower64(mult1); + unsigned pow2 = GetPower64(mult2); + while (pow1 + pow2 > 64) + { + if (pow1 > pow2) { pow1--; mult1 >>= 1; } + else { pow2--; mult2 >>= 1; } + divider >>= 1; + } + UInt64 res = mult1 * mult2; + if (divider != 0) + res /= divider; + return res; +} + void CProgressDialog::UpdateStatInfo(bool showAll) { UInt64 total, completed, totalFiles, completedFiles, inSize, outSize; bool bytesProgressMode; - Sync.GetProgress(total, completed, totalFiles, completedFiles, inSize, outSize, bytesProgressMode); - UInt32 curTime = ::GetTickCount(); + bool titleFileName_Changed; + bool curFilePath_Changed; + bool status_Changed; + unsigned numErrors; + { + NSynchronization::CCriticalSectionLock lock(Sync._cs); + total = Sync._totalBytes; + completed = Sync._completedBytes; + totalFiles = Sync._totalFiles; + completedFiles = Sync._curFiles; + inSize = Sync._inSize; + outSize = Sync._outSize; + bytesProgressMode = Sync._bytesProgressMode; + + GetChangedString(Sync._titleFileName, _titleFileName, titleFileName_Changed); + GetChangedString(Sync._filePath, _filePath, curFilePath_Changed); + GetChangedString(Sync._status, _status, status_Changed); + if (_isDir != Sync._isDir) + { + curFilePath_Changed = true; + _isDir = Sync._isDir; + } + numErrors = Sync.Messages.Size(); + } - UInt64 progressTotal = bytesProgressMode ? total : totalFiles; - UInt64 progressCompleted = bytesProgressMode ? completed : completedFiles; + UInt32 curTime = ::GetTickCount(); - if (progressTotal != _range) - SetRange(progressTotal); - if (progressTotal == (UInt64)(Int64)-1) { - SetPos(0); - SetRange(progressCompleted); + UInt64 progressTotal = bytesProgressMode ? total : totalFiles; + UInt64 progressCompleted = bytesProgressMode ? completed : completedFiles; + + if (IS_UNDEFINED_VAL(progressTotal)) + { + // SetPos(0); + // SetRange(progressCompleted); + } + else + { + if (_progressBar_Pos != 0 || progressCompleted != 0 || + (_progressBar_Range == 0 && progressTotal != 0)) + { + SetProgressRange(progressTotal); + SetProgressPos(progressCompleted); + } + } } - else - SetPos(progressCompleted); - wchar_t s[32] = { 0 }; - if (total != (UInt64)(Int64)-1) - ConvertSizeToString(total, s); - SetItemText(IDC_PROGRESS_TOTAL_VALUE, s); + ShowSize(IDT_PROGRESS_TOTAL_VAL, total, _totalBytes_Prev); _elapsedTime += (curTime - _prevTime); _prevTime = curTime; - - UInt32 elapsedSec = _elapsedTime / 1000; - + UInt64 elapsedSec = _elapsedTime / 1000; bool elapsedChanged = false; if (elapsedSec != _prevElapsedSec) { - TCHAR s[40]; - GetTimeString(elapsedSec, s); - SetItemText(IDC_PROGRESS_ELAPSED_VALUE, s); _prevElapsedSec = elapsedSec; elapsedChanged = true; + wchar_t s[40]; + GetTimeString(elapsedSec, s); + SetItemText(IDT_PROGRESS_ELAPSED_VAL, s); } + bool needSetTitle = false; if (elapsedChanged || showAll) { + if (numErrors > _numPostedMessages) { - UInt64 numErrors; - - { - NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); - numErrors = Sync.Messages.Size(); - } - if (numErrors > 0) + UpdateMessagesDialog(); + wchar_t s[32]; + ConvertUInt64ToString(numErrors, s); + SetItemText(IDT_PROGRESS_ERRORS_VAL, s); + if (!_errorsWereDisplayed) { - UpdateMessagesDialog(); - TCHAR s[40]; - ConvertUInt64ToString(numErrors, s); - SetItemText(IDC_PROGRESS_ERRORS_VALUE, s); - if (!_errorsWereDisplayed) - { - _errorsWereDisplayed = true; - EnableErrorsControls(true); - SetTaskbarProgressState(); - } + _errorsWereDisplayed = true; + EnableErrorsControls(true); + SetTaskbarProgressState(); } } if (completed != 0) { - - if (total == (UInt64)(Int64)-1) - { - SetItemText(IDC_PROGRESS_REMAINING_VALUE, L""); - } - else - { - UInt64 remainingTime = 0; - if (completed < total) - remainingTime = _elapsedTime * (total - completed) / completed; - UInt64 remainingSec = remainingTime / 1000; - if (remainingSec != _prevRemainingSec) - { - TCHAR s[40]; - GetTimeString(remainingSec, s); - SetItemText(IDC_PROGRESS_REMAINING_VALUE, s); - _prevRemainingSec = remainingSec; - } - } - { - UInt32 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime; - UInt64 speedB = (completed * 1000) / elapsedTime; - UInt64 speedKB = speedB / 1024; - UInt64 speedMB = speedKB / 1024; - const UInt32 kLimit1 = 10; - TCHAR s[40]; - bool needRedraw = false; - if (speedMB >= kLimit1) + if (IS_UNDEFINED_VAL(total)) { - if (_prevMode != kSpeedMBytes || speedMB != _prevSpeed) + if (IS_DEFINED_VAL(_prevRemainingSec)) { - ConvertUInt64ToString(speedMB, s); - lstrcat(s, TEXT(" MB/s")); - _prevMode = kSpeedMBytes; - _prevSpeed = speedMB; - needRedraw = true; + INIT_AS_UNDEFINED(_prevRemainingSec); + SetItemText(IDT_PROGRESS_REMAINING_VAL, L""); } } - else if (speedKB >= kLimit1) + else { - if (_prevMode != kSpeedKBytes || speedKB != _prevSpeed) + UInt64 remainingTime = 0; + if (completed < total) + remainingTime = MyMultAndDiv(_elapsedTime, total - completed, completed); + UInt64 remainingSec = remainingTime / 1000; + if (remainingSec != _prevRemainingSec) { - ConvertUInt64ToString(speedKB, s); - lstrcat(s, TEXT(" KB/s")); - _prevMode = kSpeedKBytes; - _prevSpeed = speedKB; - needRedraw = true; + _prevRemainingSec = remainingSec; + wchar_t s[40]; + GetTimeString(remainingSec, s); + SetItemText(IDT_PROGRESS_REMAINING_VAL, s); } } - else { - if (_prevMode != kSpeedBytes || speedB != _prevSpeed) + UInt64 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime; + UInt64 v = (completed * 1000) / elapsedTime; + Byte c = 0; + unsigned moveBits = 0; + if (v >= ((UInt64)10000 << 10)) { moveBits = 20; c = 'M'; } + else if (v >= ((UInt64)10000 << 0)) { moveBits = 10; c = 'K'; } + v >>= moveBits; + if (moveBits != _prevSpeed_MoveBits || v != _prevSpeed) { - ConvertUInt64ToString(speedB, s); - lstrcat(s, TEXT(" B/s")); - _prevMode = kSpeedBytes; - _prevSpeed = speedB; - needRedraw = true; + _prevSpeed_MoveBits = moveBits; + _prevSpeed = v; + wchar_t s[40]; + ConvertUInt64ToString(v, s); + unsigned pos = MyStringLen(s); + s[pos++] = ' '; + if (moveBits != 0) + s[pos++] = c; + s[pos++] = 'B'; + s[pos++] = '/'; + s[pos++] = 's'; + s[pos++] = 0; + SetItemText(IDT_PROGRESS_SPEED_VAL, s); } } - if (needRedraw) - SetItemText(IDC_PROGRESS_SPEED_VALUE, s); - } } - if (total == 0) - total = 1; - UInt32 percentValue = (UInt32)(completed * 100 / total); - UString titleName; - Sync.GetTitleFileName(titleName); - if (percentValue != _prevPercentValue || _prevTitleName != titleName) { - _prevPercentValue = percentValue; - SetTitleText(); - _prevTitleName = titleName; + UInt64 percent = 0; + { + if (IS_DEFINED_VAL(total)) + { + percent = completed * 100; + if (total != 0) + percent /= total; + } + } + if (percent != _prevPercentValue) + { + _prevPercentValue = percent; + needSetTitle = true; + } } - TCHAR s[64]; - ConvertUInt64ToString(completedFiles, s); - if (totalFiles != (UInt64)(Int64)-1) { - lstrcat(s, TEXT(" / ")); - ConvertUInt64ToString(totalFiles, s + lstrlen(s)); + wchar_t s[64]; + ConvertUInt64ToString(completedFiles, s); + if (IS_DEFINED_VAL(totalFiles)) + { + wcscat(s, L" / "); + ConvertUInt64ToString(totalFiles, s + wcslen(s)); + } + if (_filesStr_Prev != s) + { + _filesStr_Prev = s; + SetItemText(IDT_PROGRESS_FILES_VAL, s); + } } - SetItemText(IDC_PROGRESS_FILES_VALUE, s); - const UInt64 packSize = CompressingMode ? outSize : inSize; const UInt64 unpackSize = CompressingMode ? inSize : outSize; - if (unpackSize == (UInt64)(Int64)-1 && packSize == (UInt64)(Int64)-1) + if (IS_UNDEFINED_VAL(unpackSize) && + IS_UNDEFINED_VAL(packSize)) { - ShowSize(IDC_PROGRESS_UNPACKED_VALUE, completed); - SetItemText(IDC_PROGRESS_PACKED_VALUE, L""); + ShowSize(IDT_PROGRESS_PROCESSED_VAL, completed, _processed_Prev); + ShowSize(IDT_PROGRESS_PACKED_VAL, UNDEFINED_VAL, _packed_Prev); } else { - ShowSize(IDC_PROGRESS_UNPACKED_VALUE, unpackSize); - ShowSize(IDC_PROGRESS_PACKED_VALUE, packSize); + ShowSize(IDT_PROGRESS_PROCESSED_VAL, unpackSize, _processed_Prev); + ShowSize(IDT_PROGRESS_PACKED_VAL, packSize, _packed_Prev); - if (packSize != (UInt64)(Int64)-1 && unpackSize != (UInt64)(Int64)-1 && unpackSize != 0) + if (IS_DEFINED_VAL(packSize) && + IS_DEFINED_VAL(unpackSize) && + unpackSize != 0) { + wchar_t s[32]; UInt64 ratio = packSize * 100 / unpackSize; - ConvertUInt64ToString(ratio, s); - lstrcat(s, TEXT("%")); - SetItemText(IDC_PROGRESS_RATIO_VALUE, s); + if (_ratio_Prev != ratio) + { + _ratio_Prev = ratio; + ConvertUInt64ToString(ratio, s); + wcscat(s, L"%"); + SetItemText(IDT_PROGRESS_RATIO_VAL, s); + } } } } + if (needSetTitle || titleFileName_Changed) + SetTitleText(); - UString fileName; - Sync.GetCurrentFileName(fileName); - if (_prevFileName != fileName) + if (status_Changed) + { + UString s = _status; + ReduceString(s, _numReduceSymbols); + SetItemText(IDT_PROGRESS_STATUS, _status); + } + + if (curFilePath_Changed) { - int slashPos = fileName.ReverseFind(WCHAR_PATH_SEPARATOR); UString s1, s2; - if (slashPos >= 0) + if (_isDir) + s1 = _filePath; + else { - s1 = fileName.Left(slashPos + 1); - s2 = fileName.Mid(slashPos + 1); + int slashPos = _filePath.ReverseFind(WCHAR_PATH_SEPARATOR); + if (slashPos >= 0) + { + s1.SetFrom(_filePath, slashPos + 1); + s2 = _filePath.Ptr(slashPos + 1); + } + else + s2 = _filePath; } - else - s2 = fileName; ReduceString(s1, _numReduceSymbols); ReduceString(s2, _numReduceSymbols); - UString s = s1 + L"\n" + s2; - SetItemText(IDC_PROGRESS_FILE_NAME, s); - _prevFileName == fileName; + s1 += L'\n'; + s1 += s2; + SetItemText(IDT_PROGRESS_FILE_NAME, s1); } } bool CProgressDialog::OnTimer(WPARAM /* timerID */, LPARAM /* callback */) { - if (Sync.GetPaused()) + if (Sync.Get_Paused()) return true; - CheckNeedClose(); - UpdateStatInfo(false); return true; } @@ -668,19 +912,13 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread, CWaitCursor waitCursor; HANDLE h[] = { thread, _createDialogEvent }; - WRes res = WaitForMultipleObjects(sizeof(h) / sizeof(h[0]), h, FALSE, - #ifdef UNDER_CE - 2500 - #else - 1000 - #endif - ); + WRes res = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay); if (res == WAIT_OBJECT_0 && !Sync.ThereIsMessage()) return 0; } _title = title; BIG_DIALOG_SIZE(360, 192); - res = CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_PROGRESS), wndParent); + res = CModalDialog::Create(SIZED_DIALOG(IDD_PROGRESS), wndParent); } catch(...) { @@ -690,7 +928,7 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread, } thread.Wait(); if (!MessagesDisplayed) - MessageBoxW(wndParent, L"Progress Error", L"7-Zip", MB_ICONERROR | MB_OK); + MessageBoxW(wndParent, L"Progress Error", L"7-Zip", MB_ICONERROR); return res; } @@ -703,38 +941,33 @@ bool CProgressDialog::OnExternalCloseMessage() UpdateStatInfo(true); - HideItem(IDC_BUTTON_PROGRESS_PRIORITY); - HideItem(IDC_BUTTON_PAUSE); - SetItemText(IDCANCEL, LangStringSpec(IDS_CLOSE, 0x02000713)); + SetItemText(IDCANCEL, LangString(IDS_CLOSE)); + ::SendMessage(GetItem(IDCANCEL), BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE, 0)); + HideItem(IDB_PROGRESS_BACKGROUND); + HideItem(IDB_PAUSE); bool thereAreMessages; - UString okMessage; - UString okMessageTitle; - UString errorMessage; - UString errorMessageTitle; + CProgressFinalMessage fm; { - NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); - errorMessage = Sync.ErrorMessage; - errorMessageTitle = Sync.ErrorMessageTitle; - okMessage = Sync.OkMessage; - okMessageTitle = Sync.OkMessageTitle; + NSynchronization::CCriticalSectionLock lock(Sync._cs); thereAreMessages = !Sync.Messages.IsEmpty(); + fm = Sync.FinalMessage; } - if (!errorMessage.IsEmpty()) + if (!fm.ErrorMessage.Message.IsEmpty()) { MessagesDisplayed = true; - if (errorMessageTitle.IsEmpty()) - errorMessageTitle = L"7-Zip"; - MessageBoxW(*this, errorMessage, errorMessageTitle, MB_ICONERROR | MB_OK); + if (fm.ErrorMessage.Title.IsEmpty()) + fm.ErrorMessage.Title = L"7-Zip"; + MessageBoxW(*this, fm.ErrorMessage.Message, fm.ErrorMessage.Title, MB_ICONERROR); } else if (!thereAreMessages) { MessagesDisplayed = true; - if (!okMessage.IsEmpty()) + if (!fm.OkMessage.Message.IsEmpty()) { - if (okMessageTitle.IsEmpty()) - okMessageTitle = L"7-Zip"; - MessageBoxW(*this, okMessage, okMessageTitle, MB_OK); + if (fm.OkMessage.Title.IsEmpty()) + fm.OkMessage.Title = L"7-Zip"; + MessageBoxW(*this, fm.OkMessage.Message, fm.OkMessage.Title, MB_OK); } } @@ -751,7 +984,7 @@ bool CProgressDialog::OnExternalCloseMessage() bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { - switch(message) + switch (message) { case kCloseMessage: { @@ -778,51 +1011,56 @@ bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) void CProgressDialog::SetTitleText() { - UString title; - if (Sync.GetPaused()) + UString s; + if (Sync.Get_Paused()) { - title = pausedString; - title += L' '; + s += _paused_String; + s += L' '; } - if (_prevPercentValue != (UInt32)-1) + if (IS_DEFINED_VAL(_prevPercentValue)) { - wchar_t s[64]; - ConvertUInt64ToString(_prevPercentValue, s); - title += s; - title += L'%'; + wchar_t temp[32]; + ConvertUInt64ToString(_prevPercentValue, temp); + s += temp; + s += L'%'; } if (!_foreground) { - title += L' '; - title += backgroundedString; + s += L' '; + s += _backgrounded_String; } - title += L' '; - UString totalTitle = title + _title; - UString fileName; - Sync.GetTitleFileName(fileName); - if (!fileName.IsEmpty()) + + s += L' '; + #ifndef _SFX { - ReduceString(fileName, kTitleFileNameSizeLimit); - totalTitle += L' '; - totalTitle += fileName; + unsigned len = s.Len(); + s += MainAddTitle; + AddToTitle(s); + s.DeleteFrom(len); } - SetText(totalTitle); - #ifndef _SFX - AddToTitle(title + MainAddTitle); #endif + + s += _title; + if (!_titleFileName.IsEmpty()) + { + UString fileName = _titleFileName; + ReduceString(fileName, kTitleFileNameSizeLimit); + s += L' '; + s += fileName; + } + SetText(s); } void CProgressDialog::SetPauseText() { - SetItemText(IDC_BUTTON_PAUSE, Sync.GetPaused() ? - continueString : pauseString); + SetItemText(IDB_PAUSE, Sync.Get_Paused() ? _continue_String : _pause_String); SetTitleText(); } void CProgressDialog::OnPauseButton() { - bool paused = !Sync.GetPaused(); - Sync.SetPaused(paused); + bool paused = !Sync.Get_Paused(); + Sync.Set_Paused(paused); UInt32 curTime = ::GetTickCount(); if (paused) _elapsedTime += (curTime - _prevTime); @@ -833,9 +1071,9 @@ void CProgressDialog::OnPauseButton() void CProgressDialog::SetPriorityText() { - SetItemText(IDC_BUTTON_PROGRESS_PRIORITY, _foreground ? - backgroundString : - foregroundString); + SetItemText(IDB_PROGRESS_BACKGROUND, _foreground ? + _background_String : + _foreground_String); SetTitleText(); } @@ -843,17 +1081,18 @@ void CProgressDialog::OnPriorityButton() { _foreground = !_foreground; #ifndef UNDER_CE - SetPriorityClass(GetCurrentProcess(), _foreground ? - NORMAL_PRIORITY_CLASS: IDLE_PRIORITY_CLASS); + SetPriorityClass(GetCurrentProcess(), _foreground ? NORMAL_PRIORITY_CLASS: IDLE_PRIORITY_CLASS); #endif SetPriorityText(); } -void CProgressDialog::AddMessageDirect(LPCWSTR message) +void CProgressDialog::AddMessageDirect(LPCWSTR message, bool needNumber) { int itemIndex = _messageList.GetItemCount(); - wchar_t sz[32]; - ConvertInt64ToString(itemIndex, sz); + wchar_t sz[16]; + sz[0] = 0; + if (needNumber) + ConvertUInt32ToString(_numMessages + 1, sz); _messageList.InsertItem(itemIndex, sz); _messageList.SetSubItem(itemIndex, 1, message); } @@ -861,22 +1100,25 @@ void CProgressDialog::AddMessageDirect(LPCWSTR message) void CProgressDialog::AddMessage(LPCWSTR message) { UString s = message; + bool needNumber = true; while (!s.IsEmpty()) { int pos = s.Find(L'\n'); if (pos < 0) break; - AddMessageDirect(s.Left(pos)); - s.Delete(0, pos + 1); + AddMessageDirect(s.Left(pos), needNumber); + needNumber = false; + s.DeleteFrontal(pos + 1); } - AddMessageDirect(s); + AddMessageDirect(s, needNumber); + _numMessages++; } -static unsigned GetNumDigits(UInt32 value) +static unsigned GetNumDigits(UInt32 val) { unsigned i; - for (i = 0; value >= 10; i++) - value /= 10; + for (i = 0; val >= 10; i++) + val /= 10; return i; } @@ -884,14 +1126,19 @@ void CProgressDialog::UpdateMessagesDialog() { UStringVector messages; { - NWindows::NSynchronization::CCriticalSectionLock lock(Sync._cs); - for (int i = _numPostedMessages; i < Sync.Messages.Size(); i++) - messages.Add(Sync.Messages[i]); - _numPostedMessages = Sync.Messages.Size(); + NSynchronization::CCriticalSectionLock lock(Sync._cs); + unsigned num = Sync.Messages.Size(); + if (num > _numPostedMessages) + { + messages.ClearAndReserve(num - _numPostedMessages); + for (unsigned i = _numPostedMessages; i < num; i++) + messages.AddInReserved(Sync.Messages[i]); + _numPostedMessages = num; + } } if (!messages.IsEmpty()) { - for (int i = 0; i < messages.Size(); i++) + FOR_VECTOR (i, messages) AddMessage(messages[i]); if (_numAutoSizeMessages < 256 || GetNumDigits(_numPostedMessages) > GetNumDigits(_numAutoSizeMessages)) { @@ -905,7 +1152,7 @@ void CProgressDialog::UpdateMessagesDialog() bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { - switch(buttonID) + switch (buttonID) { // case IDOK: // if IDCANCEL is not DEFPUSHBUTTON case IDCANCEL: @@ -917,13 +1164,11 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) break; } - bool paused = Sync.GetPaused(); + bool paused = Sync.Get_Paused(); if (!paused) OnPauseButton(); _inCancelMessageBox = true; - int res = ::MessageBoxW(HWND(*this), - LangStringSpec(IDS_PROGRESS_ASK_CANCEL, 0x02000C30), - _title, MB_YESNOCANCEL); + int res = ::MessageBoxW(*this, LangString(IDS_PROGRESS_ASK_CANCEL), _title, MB_YESNOCANCEL); _inCancelMessageBox = false; if (!paused) OnPauseButton(); @@ -939,10 +1184,10 @@ bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND) break; } - case IDC_BUTTON_PAUSE: + case IDB_PAUSE: OnPauseButton(); return true; - case IDC_BUTTON_PROGRESS_PRIORITY: + case IDB_PROGRESS_BACKGROUND: OnPriorityButton(); return true; } @@ -979,16 +1224,6 @@ HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow) return S_OK; } -UString HResultToMessage(HRESULT errorCode) -{ - UString message; - if (errorCode == E_OUTOFMEMORY) - message = LangStringSpec(IDS_MEM_ERROR, 0x0200060B); - else - message = NError::MyFormatMessageW(errorCode); - return message; -} - static void AddMessageToString(UString &dest, const UString &src) { if (!src.IsEmpty()) @@ -1007,28 +1242,42 @@ void CProgressThreadVirt::Process() catch(const wchar_t *s) { m = s; } catch(const UString &s) { m = s; } catch(const char *s) { m = GetUnicodeString(s); } + catch(int v) + { + wchar_t s[16]; + ConvertUInt32ToString(v, s); + m = L"Error #"; + m += s; + } catch(...) { m = L"Error"; } if (Result != E_ABORT) { if (m.IsEmpty() && Result != S_OK) m = HResultToMessage(Result); } - AddMessageToString(m, ErrorMessage); + AddMessageToString(m, FinalMessage.ErrorMessage.Message); AddMessageToString(m, fs2us(ErrorPath1)); AddMessageToString(m, fs2us(ErrorPath2)); + CProgressSync &sync = ProgressDialog.Sync; + NSynchronization::CCriticalSectionLock lock(sync._cs); if (m.IsEmpty()) { - if (!OkMessage.IsEmpty()) - { - ProgressDialog.Sync.SetOkMessageTitle(OkMessageTitle); - ProgressDialog.Sync.SetOkMessage(OkMessage); - } + if (!FinalMessage.OkMessage.Message.IsEmpty()) + sync.FinalMessage.OkMessage = FinalMessage.OkMessage; } else { - ProgressDialog.Sync.SetErrorMessage(m); + sync.FinalMessage.ErrorMessage.Message = m; if (Result == S_OK) Result = E_FAIL; } } + +UString HResultToMessage(HRESULT errorCode) +{ + if (errorCode == E_OUTOFMEMORY) + return LangString(IDS_MEM_ERROR); + else + return NError::MyFormatMessage(errorCode); +} diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.h b/CPP/7zip/UI/FileManager/ProgressDialog2.h old mode 100755 new mode 100644 index 6bb13603..632d022a --- a/CPP/7zip/UI/FileManager/ProgressDialog2.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.h @@ -1,249 +1,184 @@ // ProgressDialog2.h -#ifndef __PROGRESS_DIALOG2_H -#define __PROGRESS_DIALOG2_H +#ifndef __PROGRESS_DIALOG_2_H +#define __PROGRESS_DIALOG_2_H -#include "Common/MyCom.h" +#include "../../../Common/MyCom.h" -#include "Windows/Synchronization.h" -#include "Windows/Thread.h" +#include "../../../Windows/ErrorMsg.h" +#include "../../../Windows/Synchronization.h" +#include "../../../Windows/Thread.h" -#include "Windows/Control/Dialog.h" -#include "Windows/Control/ListView.h" -#include "Windows/Control/ProgressBar.h" +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/ListView.h" +#include "../../../Windows/Control/ProgressBar.h" #include "MyWindowsNew.h" +struct CProgressMessageBoxPair +{ + UString Title; + UString Message; +}; + +struct CProgressFinalMessage +{ + CProgressMessageBoxPair ErrorMessage; + CProgressMessageBoxPair OkMessage; + + bool ThereIsMessage() const { return !ErrorMessage.Message.IsEmpty() || !OkMessage.Message.IsEmpty(); } +}; + class CProgressSync { bool _stopped; bool _paused; - bool _bytesProgressMode; +public: + bool _bytesProgressMode; UInt64 _totalBytes; - UInt64 _curBytes; + UInt64 _completedBytes; UInt64 _totalFiles; UInt64 _curFiles; UInt64 _inSize; UInt64 _outSize; UString _titleFileName; - UString _currentFileName; + UString _status; + UString _filePath; + bool _isDir; -public: UStringVector Messages; - UString ErrorMessage; - UString ErrorMessageTitle; - - UString OkMessage; - UString OkMessageTitle; + CProgressFinalMessage FinalMessage; NWindows::NSynchronization::CCriticalSection _cs; - CProgressSync(): - _stopped(false), _paused(false), - _totalBytes((UInt64)(Int64)-1), _curBytes(0), - _totalFiles((UInt64)(Int64)-1), _curFiles(0), - _inSize((UInt64)(Int64)-1), - _outSize((UInt64)(Int64)-1), - _bytesProgressMode(true) - {} + CProgressSync(); - bool GetStopped() + bool Get_Stopped() { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); return _stopped; } - void SetStopped(bool value) + void Set_Stopped(bool val) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _stopped = value; + _stopped = val; } - bool GetPaused() - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - return _paused; - } - void SetPaused(bool value) + + bool Get_Paused(); + void Set_Paused(bool val) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _paused = value; + _paused = val; } - void SetBytesProgressMode(bool bytesProgressMode) + + void Set_BytesProgressMode(bool bytesProgressMode) { NWindows::NSynchronization::CCriticalSectionLock lock(_cs); _bytesProgressMode = bytesProgressMode; } - void SetProgress(UInt64 total, UInt64 completed) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _totalBytes = total; - _curBytes = completed; - } - void SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - if (inSize) - _inSize = *inSize; - if (outSize) - _outSize = *outSize; - } - void SetPos(UInt64 completed) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _curBytes = completed; - } - void SetNumBytesTotal(UInt64 value) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _totalBytes = value; - } - void SetNumFilesTotal(UInt64 value) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _totalFiles = value; - } - void SetNumFilesCur(UInt64 value) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _curFiles = value; - } - HRESULT ProcessStopAndPause(); - HRESULT SetPosAndCheckPaused(UInt64 completed); - void GetProgress(UInt64 &total, UInt64 &completed, - UInt64 &totalFiles, UInt64 &curFiles, - UInt64 &inSize, UInt64 &outSize, - bool &bytesProgressMode) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - total = _totalBytes; - completed = _curBytes; - totalFiles = _totalFiles; - curFiles = _curFiles; - inSize = _inSize; - outSize = _outSize; - bytesProgressMode = _bytesProgressMode; - } - void SetTitleFileName(const UString &fileName) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _titleFileName = fileName; - } - void GetTitleFileName(UString &fileName) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - fileName = _titleFileName; - } - void SetCurrentFileName(const UString &fileName) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - _currentFileName = fileName; - } - void GetCurrentFileName(UString &fileName) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - fileName = _currentFileName; - } - - void AddErrorMessage(LPCWSTR message) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - Messages.Add(message); - } - - void SetErrorMessage(const UString &message) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - ErrorMessage = message; - } - - void SetOkMessage(const UString &message) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - OkMessage = message; - } - - void SetOkMessageTitle(const UString &title) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - OkMessageTitle = title; - } + + HRESULT CheckStop(); + HRESULT ScanProgress(UInt64 numFiles, UInt64 totalSize, const UString &fileName, bool isDir = false); - void SetErrorMessageTitle(const UString &title) - { - NWindows::NSynchronization::CCriticalSectionLock lock(_cs); - ErrorMessageTitle = title; - } + void Set_NumFilesTotal(UInt64 val); + void Set_NumBytesTotal(UInt64 val); + void Set_NumFilesCur(UInt64 val); + HRESULT Set_NumBytesCur(const UInt64 *val); + HRESULT Set_NumBytesCur(UInt64 val); + void Set_Ratio(const UInt64 *inSize, const UInt64 *outSize); - bool ThereIsMessage() const - { - return !Messages.IsEmpty() || !ErrorMessage.IsEmpty() || !OkMessage.IsEmpty(); - } -}; + void Set_TitleFileName(const UString &fileName); + void Set_Status(const UString &s); + void Set_FilePath(const UString &path, bool isDir = false); -class CU64ToI32Converter -{ - UInt64 _numShiftBits; -public: - void Init(UInt64 range) - { - // Windows CE doesn't like big number here. - for (_numShiftBits = 0; range > (1 << 15); _numShiftBits++) - range >>= 1; - } - int Count(UInt64 value) { return int(value >> _numShiftBits); } -}; + void AddError_Message(const wchar_t *message); + void AddError_Message_Name(const wchar_t *message, const wchar_t *name); + void AddError_Code_Name(DWORD systemError, const wchar_t *name); -enum ESpeedMode -{ - kSpeedBytes, - kSpeedKBytes, - kSpeedMBytes + bool ThereIsMessage() const { return !Messages.IsEmpty() || FinalMessage.ThereIsMessage(); } }; class CProgressDialog: public NWindows::NControl::CModalDialog { - UString _prevFileName; - UString _prevTitleName; + UString _titleFileName; + UString _filePath; + UString _status; + bool _isDir; - UString backgroundString; - UString backgroundedString; - UString foregroundString; - UString pauseString; - UString continueString; - UString pausedString; + UString _background_String; + UString _backgrounded_String; + UString _foreground_String; + UString _pause_String; + UString _continue_String; + UString _paused_String; - int buttonSizeX; - int buttonSizeY; + int _buttonSizeX; + int _buttonSizeY; UINT_PTR _timer; UString _title; - CU64ToI32Converter _converter; - UInt64 _previousPos; - UInt64 _range; + + class CU64ToI32Converter + { + unsigned _numShiftBits; + UInt64 _range; + public: + CU64ToI32Converter(): _numShiftBits(0), _range(1) {} + void Init(UInt64 range) + { + _range = range; + // Windows CE doesn't like big number for ProgressBar. + for (_numShiftBits = 0; range >= ((UInt32)1 << 15); _numShiftBits++) + range >>= 1; + } + int Count(UInt64 val) + { + int res = (int)(val >> _numShiftBits); + if (val == _range) + res++; + return res; + } + }; + + CU64ToI32Converter _progressConv; + UInt64 _progressBar_Pos; + UInt64 _progressBar_Range; + NWindows::NControl::CProgressBar m_ProgressBar; NWindows::NControl::CListView _messageList; + + int _numMessages; CMyComPtr _taskbarList; HWND _hwndForTaskbar; - UInt32 _prevPercentValue; UInt32 _prevTime; - UInt32 _elapsedTime; - UInt32 _prevElapsedSec; + UInt64 _elapsedTime; + + UInt64 _prevPercentValue; + UInt64 _prevElapsedSec; UInt64 _prevRemainingSec; - ESpeedMode _prevMode; + + UInt64 _totalBytes_Prev; + UInt64 _processed_Prev; + UInt64 _packed_Prev; + UInt64 _ratio_Prev; + UString _filesStr_Prev; + + unsigned _prevSpeed_MoveBits; UInt64 _prevSpeed; bool _foreground; - int _numReduceSymbols; + unsigned _numReduceSymbols; bool _wasCreated; bool _needClose; - UInt32 _numPostedMessages; + unsigned _numPostedMessages; UInt32 _numAutoSizeMessages; bool _errorsWereDisplayed; @@ -264,8 +199,8 @@ class CProgressDialog: public NWindows::NControl::CModalDialog void UpdateStatInfo(bool showAll); bool OnTimer(WPARAM timerID, LPARAM callback); - void SetRange(UInt64 range); - void SetPos(UInt64 pos); + void SetProgressRange(UInt64 range); + void SetProgressPos(UInt64 pos); virtual bool OnInit(); virtual bool OnSize(WPARAM wParam, int xSize, int ySize); virtual void OnCancel(); @@ -281,13 +216,14 @@ class CProgressDialog: public NWindows::NControl::CModalDialog void OnPauseButton(); void OnPriorityButton(); bool OnButtonClicked(int buttonID, HWND buttonHWND); + bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); void SetTitleText(); - void ShowSize(int id, UInt64 value); + void ShowSize(int id, UInt64 val, UInt64 &prev); void UpdateMessagesDialog(); - void AddMessageDirect(LPCWSTR message); + void AddMessageDirect(LPCWSTR message, bool needNumber); void AddMessage(LPCWSTR message); bool OnExternalCloseMessage(); @@ -318,12 +254,8 @@ public: _dialogCreatedEvent.Lock(); } - INT_PTR Create(const UString &title, NWindows::CThread &thread, HWND wndParent = 0); - - virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); - void ProcessWasFinished(); }; @@ -341,9 +273,7 @@ class CProgressThreadVirt FString ErrorPath1; FString ErrorPath2; protected: - UString ErrorMessage; - UString OkMessage; - UString OkMessageTitle; + CProgressFinalMessage FinalMessage; // error if any of HRESULT, ErrorMessage, ErrorPath virtual HRESULT ProcessVirt() = 0; @@ -370,6 +300,9 @@ public: HRESULT Create(const UString &title, HWND parentWindow = 0); CProgressThreadVirt(): Result(E_FAIL), ThreadFinishedOK(false) {} + + CProgressMessageBoxPair &GetMessagePair(bool isError) { return isError ? FinalMessage.ErrorMessage : FinalMessage.OkMessage; } + }; UString HResultToMessage(HRESULT errorCode); diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2.rc b/CPP/7zip/UI/FileManager/ProgressDialog2.rc old mode 100755 new mode 100644 index 703dbb1f..4d0e0c7b --- a/CPP/7zip/UI/FileManager/ProgressDialog2.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog2.rc @@ -2,7 +2,7 @@ #include "../../GuiCommon.rc" #undef DIALOG_ID -#define DIALOG_ID IDD_DIALOG_PROGRESS +#define DIALOG_ID IDD_PROGRESS #define xc 360 #define k 11 #define z1s 16 @@ -19,7 +19,7 @@ #undef k #undef z1s -#define DIALOG_ID IDD_DIALOG_PROGRESS_2 +#define DIALOG_ID IDD_PROGRESS_2 #define m 4 #define k 8 #define z1s 12 @@ -34,8 +34,7 @@ STRINGTABLE DISCARDABLE { IDS_PROGRESS_PAUSED "Paused" IDS_PROGRESS_FOREGROUND "&Foreground" - IDS_PROGRESS_CONTINUE "&Continue" + IDS_CONTINUE "&Continue" IDS_PROGRESS_ASK_CANCEL "Are you sure you want to cancel?" IDS_CLOSE "&Close" - IDS_MESSAGES_DIALOG_MESSAGE_COLUMN "Message" } diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h old mode 100755 new mode 100644 index be5af607..b45d7b49 --- a/CPP/7zip/UI/FileManager/ProgressDialog2Res.h +++ b/CPP/7zip/UI/FileManager/ProgressDialog2Res.h @@ -1,45 +1,48 @@ -#define IDD_DIALOG_PROGRESS 500 -#define IDD_DIALOG_PROGRESS_2 600 - -#define IDC_BUTTON_PAUSE 50 -#define IDC_BUTTON_PROGRESS_PRIORITY 51 - -#define IDS_PROGRESS_PAUSED 700 -#define IDS_PROGRESS_FOREGROUND 701 -#define IDS_PROGRESS_CONTINUE 702 -#define IDS_PROGRESS_ASK_CANCEL 703 -#define IDS_CLOSE 704 -#define IDS_MESSAGES_DIALOG_MESSAGE_COLUMN 503 - -#define IDC_PROGRESS1 1000 -#define IDC_PROGRESS_ELAPSED 1002 -#define IDC_PROGRESS_ELAPSED_VALUE 1003 -#define IDC_PROGRESS_REMAINING 1004 -#define IDC_PROGRESS_REMAINING_VALUE 1005 -#define IDC_PROGRESS_SPEED 1006 -#define IDC_PROGRESS_SPEED_VALUE 1007 -#define IDC_PROGRESS_TOTAL 1008 -#define IDC_PROGRESS_TOTAL_VALUE 1009 -#define IDC_PROGRESS_FILE_NAME 1010 - -#define IDC_PROGRESS_FILES 1012 -#define IDC_PROGRESS_FILES_VALUE 1013 -#define IDC_PROGRESS_RATIO 1014 -#define IDC_PROGRESS_RATIO_VALUE 1015 -#define IDC_PROGRESS_PACKED 1016 -#define IDC_PROGRESS_PACKED_VALUE 1017 -#define IDC_PROGRESS_UNPACKED 1018 -#define IDC_PROGRESS_UNPACKED_VALUE 1019 - -#define IDC_PROGRESS_ERRORS 1030 -#define IDC_PROGRESS_ERRORS_VALUE 1031 -#define IDC_PROGRESS_LIST 1032 +#define IDD_PROGRESS 97 +#define IDD_PROGRESS_2 10097 + +#define IDS_CLOSE 408 +#define IDS_CONTINUE 411 + +#define IDB_PROGRESS_BACKGROUND 444 +#define IDS_PROGRESS_FOREGROUND 445 +#define IDB_PAUSE 446 +#define IDS_PROGRESS_PAUSED 447 +#define IDS_PROGRESS_ASK_CANCEL 448 + +#define IDT_PROGRESS_PACKED 1008 +#define IDT_PROGRESS_FILES 1032 + +#define IDT_PROGRESS_ELAPSED 3900 +#define IDT_PROGRESS_REMAINING 3901 +#define IDT_PROGRESS_TOTAL 3902 +#define IDT_PROGRESS_SPEED 3903 +#define IDT_PROGRESS_PROCESSED 3904 +#define IDT_PROGRESS_RATIO 3905 +#define IDT_PROGRESS_ERRORS 3906 + +#define IDC_PROGRESS1 100 +#define IDL_PROGRESS_MESSAGES 101 +#define IDT_PROGRESS_FILE_NAME 102 +#define IDT_PROGRESS_STATUS 103 + +#define IDT_PROGRESS_PACKED_VAL 110 +#define IDT_PROGRESS_FILES_VAL 111 + +#define IDT_PROGRESS_ELAPSED_VAL 120 +#define IDT_PROGRESS_REMAINING_VAL 121 +#define IDT_PROGRESS_TOTAL_VAL 122 +#define IDT_PROGRESS_SPEED_VAL 123 +#define IDT_PROGRESS_PROCESSED_VAL 124 +#define IDT_PROGRESS_RATIO_VAL 125 +#define IDT_PROGRESS_ERRORS_VAL 126 + #ifdef UNDER_CE -#define MY_PROGRESS_VALUE_UNITS 44 +#define MY_PROGRESS_VAL_UNITS 44 #else -#define MY_PROGRESS_VALUE_UNITS 76 +#define MY_PROGRESS_VAL_UNITS 76 #endif -#define MY_PROGRESS_LABEL_UNITS_MIN 60 +#define MY_PROGRESS_LABEL_UNITS_MIN 60 #define MY_PROGRESS_LABEL_UNITS_START 90 #define MY_PROGRESS_PAD_UNITS 4 diff --git a/CPP/7zip/UI/FileManager/ProgressDialog2a.rc b/CPP/7zip/UI/FileManager/ProgressDialog2a.rc old mode 100755 new mode 100644 index 8eba4148..e9713930 --- a/CPP/7zip/UI/FileManager/ProgressDialog2a.rc +++ b/CPP/7zip/UI/FileManager/ProgressDialog2a.rc @@ -2,9 +2,9 @@ #define bxs 80 #define x0s MY_PROGRESS_LABEL_UNITS_START -#define x1s MY_PROGRESS_VALUE_UNITS +#define x1s MY_PROGRESS_VAL_UNITS #define x2s MY_PROGRESS_LABEL_UNITS_START -#define x3s MY_PROGRESS_VALUE_UNITS +#define x3s MY_PROGRESS_VAL_UNITS #define x1 (m + x0s) #define x3 (xs - m - x3s) @@ -17,10 +17,9 @@ #undef y4 #undef z0 -#undef z0z #undef z1 #undef z2 -#undef z2 +#undef z3 #define y0 m #define y1 (y0 + k) @@ -28,7 +27,9 @@ #define y3 (y2 + k) #define y4 (y3 + k) -#define z2 (y4 + k + 1) +#define z3 (y4 + k + 1) + +#define z2 (z3 + k + 1) #define z2s 24 #define z1 (z2 + z2s) @@ -39,40 +40,41 @@ #define yc (z0 + z0s + bys) -DIALOG_ID MY_RESIZE_DIALOG +DIALOG_ID DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT CAPTION "Progress" { - PUSHBUTTON "&Background", IDC_BUTTON_PROGRESS_PRIORITY, bx3, by, bxs, bys - PUSHBUTTON "&Pause", IDC_BUTTON_PAUSE, bx2, by, bxs, bys - DEFPUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys - - LTEXT "Elapsed time:", IDC_PROGRESS_ELAPSED, m, y0, x0s, 8 - LTEXT "Remaining time:", IDC_PROGRESS_REMAINING, m, y1, x0s, 8 - LTEXT "Files:", IDC_PROGRESS_FILES, m, y2, x0s, 8 - LTEXT "Compression ratio:",IDC_PROGRESS_RATIO, m, y3, x0s, 8 - LTEXT "Errors:", IDC_PROGRESS_ERRORS, m, y4, x0s, 8 - - LTEXT "Total size:", IDC_PROGRESS_TOTAL, x2, y0, x2s, 8 - LTEXT "Speed:", IDC_PROGRESS_SPEED, x2, y1, x2s, 8 - LTEXT "Processed:", IDC_PROGRESS_UNPACKED, x2, y2, x2s, 8 - LTEXT "Compressed size:", IDC_PROGRESS_PACKED, x2, y3, x2s, 8 - - RTEXT "", IDC_PROGRESS_ELAPSED_VALUE, x1, y0, x1s, 8 - RTEXT "", IDC_PROGRESS_REMAINING_VALUE, x1, y1, x1s, 8 - RTEXT "", IDC_PROGRESS_FILES_VALUE, x1, y2, x1s, 8 - RTEXT "", IDC_PROGRESS_RATIO_VALUE, x1, y3, x1s, 8 - RTEXT "", IDC_PROGRESS_ERRORS_VALUE, x1, y4, x1s, 8 - - RTEXT "", IDC_PROGRESS_TOTAL_VALUE, x3, y0, x3s, 8 - RTEXT "", IDC_PROGRESS_SPEED_VALUE, x3, y1, x3s, 8 - RTEXT "", IDC_PROGRESS_UNPACKED_VALUE, x3, y2, x3s, 8 - RTEXT "", IDC_PROGRESS_PACKED_VALUE, x3, y3, x3s, 8 - - LTEXT "", IDC_PROGRESS_FILE_NAME, m, z2, xc, z2s, SS_NOPREFIX | SS_LEFTNOWORDWRAP - CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, m, z1, xc, z1s - - - CONTROL "List1", IDC_PROGRESS_LIST, "SysListView32", - LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, - m, z0, xc, z0s + DEFPUSHBUTTON "&Background", IDB_PROGRESS_BACKGROUND, bx3, by, bxs, bys + PUSHBUTTON "&Pause", IDB_PAUSE bx2, by, bxs, bys + PUSHBUTTON "Cancel", IDCANCEL, bx1, by, bxs, bys + + LTEXT "Elapsed time:", IDT_PROGRESS_ELAPSED, m, y0, x0s, 8 + LTEXT "Remaining time:", IDT_PROGRESS_REMAINING, m, y1, x0s, 8 + LTEXT "Files:", IDT_PROGRESS_FILES, m, y2, x0s, 8 + LTEXT "Compression ratio:", IDT_PROGRESS_RATIO, m, y3, x0s, 8 + LTEXT "Errors:", IDT_PROGRESS_ERRORS, m, y4, x0s, 8 + + LTEXT "Total size:", IDT_PROGRESS_TOTAL, x2, y0, x2s, 8 + LTEXT "Speed:", IDT_PROGRESS_SPEED, x2, y1, x2s, 8 + LTEXT "Processed:", IDT_PROGRESS_PROCESSED,x2, y2, x2s, 8 + LTEXT "Compressed size:" , IDT_PROGRESS_PACKED, x2, y3, x2s, 8 + + RTEXT "", IDT_PROGRESS_ELAPSED_VAL, x1, y0, x1s, MY_TEXT_NOPREFIX + RTEXT "", IDT_PROGRESS_REMAINING_VAL, x1, y1, x1s, MY_TEXT_NOPREFIX + RTEXT "", IDT_PROGRESS_FILES_VAL, x1, y2, x1s, MY_TEXT_NOPREFIX + RTEXT "", IDT_PROGRESS_RATIO_VAL, x1, y3, x1s, MY_TEXT_NOPREFIX + RTEXT "", IDT_PROGRESS_ERRORS_VAL, x1, y4, x1s, MY_TEXT_NOPREFIX + + RTEXT "", IDT_PROGRESS_TOTAL_VAL, x3, y0, x3s, MY_TEXT_NOPREFIX + RTEXT "", IDT_PROGRESS_SPEED_VAL, x3, y1, x3s, MY_TEXT_NOPREFIX + RTEXT "", IDT_PROGRESS_PROCESSED_VAL, x3, y2, x3s, MY_TEXT_NOPREFIX + RTEXT "", IDT_PROGRESS_PACKED_VAL, x3, y3, x3s, MY_TEXT_NOPREFIX + + LTEXT "", IDT_PROGRESS_STATUS, m, z3, xc, MY_TEXT_NOPREFIX + CONTROL "", IDT_PROGRESS_FILE_NAME, "Static", SS_NOPREFIX | SS_LEFTNOWORDWRAP, m, z2, xc, z2s + + CONTROL "Progress1", IDC_PROGRESS1, "msctls_progress32", PBS_SMOOTH | WS_BORDER, m, z1, xc, z1s + + CONTROL "List1", IDL_PROGRESS_MESSAGES, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + m, z0, xc, z0s } diff --git a/CPP/7zip/UI/FileManager/ProgressDialogRes.h b/CPP/7zip/UI/FileManager/ProgressDialogRes.h old mode 100755 new mode 100644 index 97e47228..cbf3beb2 --- a/CPP/7zip/UI/FileManager/ProgressDialogRes.h +++ b/CPP/7zip/UI/FileManager/ProgressDialogRes.h @@ -1,3 +1,3 @@ -#define IDD_DIALOG_PROGRESS 500 +#define IDD_PROGRESS 97 -#define IDC_PROGRESS1 1000 +#define IDC_PROGRESS1 100 diff --git a/CPP/7zip/UI/FileManager/PropertyName.cpp b/CPP/7zip/UI/FileManager/PropertyName.cpp old mode 100755 new mode 100644 index 098bc47d..838b6e3f --- a/CPP/7zip/UI/FileManager/PropertyName.cpp +++ b/CPP/7zip/UI/FileManager/PropertyName.cpp @@ -2,109 +2,22 @@ #include "StdAfx.h" -#include "Common/IntToString.h" - -#include "Windows/ResourceString.h" - -#include "../../PropID.h" +#include "../../../Common/IntToString.h" #include "LangUtils.h" #include "PropertyName.h" -#include "resource.h" -#include "PropertyNameRes.h" - -struct CPropertyIDNamePair -{ - PROPID PropID; - UINT ResourceID; - UInt32 LangID; -}; - -static CPropertyIDNamePair kPropertyIDNamePairs[] = -{ - { kpidPath, IDS_PROP_PATH, 0x02000203 }, - { kpidName, IDS_PROP_NAME, 0x02000204 }, - { kpidExtension, IDS_PROP_EXTENSION, 0x02000205 }, - { kpidIsDir, IDS_PROP_IS_FOLDER, 0x02000206}, - { kpidSize, IDS_PROP_SIZE, 0x02000207}, - { kpidPackSize, IDS_PROP_PACKED_SIZE, 0x02000208 }, - { kpidAttrib, IDS_PROP_ATTRIBUTES, 0x02000209 }, - { kpidCTime, IDS_PROP_CTIME, 0x0200020A }, - { kpidATime, IDS_PROP_ATIME, 0x0200020B }, - { kpidMTime, IDS_PROP_MTIME, 0x0200020C }, - { kpidSolid, IDS_PROP_SOLID, 0x0200020D }, - { kpidCommented, IDS_PROP_C0MMENTED, 0x0200020E }, - { kpidEncrypted, IDS_PROP_ENCRYPTED, 0x0200020F }, - { kpidSplitBefore, IDS_PROP_SPLIT_BEFORE, 0x02000210 }, - { kpidSplitAfter, IDS_PROP_SPLIT_AFTER, 0x02000211 }, - { kpidDictionarySize, IDS_PROP_DICTIONARY_SIZE, 0x02000212 }, - { kpidCRC, IDS_PROP_CRC, 0x02000213 }, - { kpidType, IDS_PROP_FILE_TYPE, 0x02000214}, - { kpidIsAnti, IDS_PROP_ANTI, 0x02000215 }, - { kpidMethod, IDS_PROP_METHOD, 0x02000216 }, - { kpidHostOS, IDS_PROP_HOST_OS, 0x02000217 }, - { kpidFileSystem, IDS_PROP_FILE_SYSTEM, 0x02000218}, - { kpidUser, IDS_PROP_USER, 0x02000219}, - { kpidGroup, IDS_PROP_GROUP, 0x0200021A}, - { kpidBlock, IDS_PROP_BLOCK, 0x0200021B }, - { kpidComment, IDS_PROP_COMMENT, 0x0200021C }, - { kpidPosition, IDS_PROP_POSITION, 0x0200021D }, - { kpidPrefix, IDS_PROP_PREFIX, 0x0200021E }, - { kpidNumSubDirs, IDS_PROP_FOLDERS, 0x0200021F }, - { kpidNumSubFiles, IDS_PROP_FILES, 0x02000220 }, - { kpidUnpackVer, IDS_PROP_VERSION, 0x02000221}, - { kpidVolume, IDS_PROP_VOLUME, 0x02000222}, - { kpidIsVolume, IDS_PROP_IS_VOLUME, 0x02000223}, - { kpidOffset, IDS_PROP_OFFSET, 0x02000224}, - { kpidLinks, IDS_PROP_LINKS, 0x02000225}, - { kpidNumBlocks, IDS_PROP_NUM_BLOCKS, 0x02000226}, - { kpidNumVolumes, IDS_PROP_NUM_VOLUMES, 0x02000227}, - - { kpidBit64, IDS_PROP_BIT64, 0x02000229}, - { kpidBigEndian, IDS_PROP_BIG_ENDIAN, 0x0200022A}, - { kpidCpu, IDS_PROP_CPU, 0x0200022B}, - { kpidPhySize, IDS_PROP_PHY_SIZE, 0x0200022C}, - { kpidHeadersSize, IDS_PROP_HEADERS_SIZE, 0x0200022D}, - { kpidChecksum, IDS_PROP_CHECKSUM, 0x0200022E}, - { kpidCharacts, IDS_PROP_CHARACTS, 0x0200022F}, - { kpidVa, IDS_PROP_VA, 0x02000230}, - { kpidId, IDS_PROP_ID, 0x02000231 }, - { kpidShortName, IDS_PROP_SHORT_NAME, 0x02000232 }, - { kpidCreatorApp, IDS_PROP_CREATOR_APP, 0x02000233 }, - { kpidSectorSize, IDS_PROP_SECTOR_SIZE, 0x02000234 }, - { kpidPosixAttrib, IDS_PROP_POSIX_ATTRIB, 0x02000235 }, - { kpidLink, IDS_PROP_LINK, 0x02000236 }, - { kpidError, IDS_PROP_ERROR, 0x02000605 }, - - { kpidTotalSize, IDS_PROP_TOTAL_SIZE, 0x03031100 }, - { kpidFreeSpace, IDS_PROP_FREE_SPACE, 0x03031101 }, - { kpidClusterSize, IDS_PROP_CLUSTER_SIZE, 0x03031102}, - { kpidVolumeName, IDS_PROP_VOLUME_NAME, 0x03031103 }, - - { kpidLocalName, IDS_PROP_LOCAL_NAME, 0x03031200 }, - { kpidProvider, IDS_PROP_PROVIDER, 0x03031201 } -}; - -int FindProperty(PROPID propID) -{ - for (int i = 0; i < sizeof(kPropertyIDNamePairs) / sizeof(kPropertyIDNamePairs[0]); i++) - if (kPropertyIDNamePairs[i].PropID == propID) - return i; - return -1; -} - UString GetNameOfProperty(PROPID propID, const wchar_t *name) { - int index = FindProperty(propID); - if (index < 0) + if (propID < 1000) { - if (name) - return name; - wchar_t s[16]; - ConvertUInt32ToString(propID, s); - return s; + UString s = LangString(1000 + propID); + if (!s.IsEmpty()) + return s; } - const CPropertyIDNamePair &pair = kPropertyIDNamePairs[index]; - return LangString(pair.ResourceID, pair.LangID); + if (name) + return name; + wchar_t temp[16]; + ConvertUInt32ToString(propID, temp); + return temp; } diff --git a/CPP/7zip/UI/FileManager/PropertyName.h b/CPP/7zip/UI/FileManager/PropertyName.h old mode 100755 new mode 100644 index 95e9dc9b..4f0d6dc1 --- a/CPP/7zip/UI/FileManager/PropertyName.h +++ b/CPP/7zip/UI/FileManager/PropertyName.h @@ -1,9 +1,9 @@ // PropertyName.h -#ifndef __PROPERTYNAME_H -#define __PROPERTYNAME_H +#ifndef __PROPERTY_NAME_H +#define __PROPERTY_NAME_H -#include "Common/MyString.h" +#include "../../../Common/MyString.h" UString GetNameOfProperty(PROPID propID, const wchar_t *name); diff --git a/CPP/7zip/UI/FileManager/PropertyName.rc b/CPP/7zip/UI/FileManager/PropertyName.rc old mode 100755 new mode 100644 index bdd6c8ed..43c4584f --- a/CPP/7zip/UI/FileManager/PropertyName.rc +++ b/CPP/7zip/UI/FileManager/PropertyName.rc @@ -4,57 +4,94 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US STRINGTABLE BEGIN - IDS_PROP_PATH "Path" - IDS_PROP_NAME "Name" - IDS_PROP_EXTENSION "Extension" - IDS_PROP_IS_FOLDER "Folder" - IDS_PROP_SIZE "Size" - IDS_PROP_PACKED_SIZE "Packed Size" - IDS_PROP_ATTRIBUTES "Attributes" - IDS_PROP_CTIME "Created" - IDS_PROP_ATIME "Accessed" - IDS_PROP_MTIME "Modified" - IDS_PROP_SOLID "Solid" - IDS_PROP_C0MMENTED "Commented" - IDS_PROP_ENCRYPTED "Encrypted" - IDS_PROP_DICTIONARY_SIZE "Dictionary Size" + IDS_PROP_PATH "Path" + IDS_PROP_NAME "Name" + IDS_PROP_EXTENSION "Extension" + IDS_PROP_IS_FOLDER "Folder" + IDS_PROP_SIZE "Size" + IDS_PROP_PACKED_SIZE "Packed Size" + IDS_PROP_ATTRIBUTES "Attributes" + IDS_PROP_CTIME "Created" + IDS_PROP_ATIME "Accessed" + IDS_PROP_MTIME "Modified" + IDS_PROP_SOLID "Solid" + IDS_PROP_C0MMENTED "Commented" + IDS_PROP_ENCRYPTED "Encrypted" IDS_PROP_SPLIT_BEFORE "Split Before" - IDS_PROP_SPLIT_AFTER "Split After" - IDS_PROP_CRC "CRC" - IDS_PROP_FILE_TYPE "Type" - IDS_PROP_ANTI "Anti" - IDS_PROP_METHOD "Method" - IDS_PROP_HOST_OS "Host OS" - IDS_PROP_FILE_SYSTEM "File System" - IDS_PROP_USER "User" - IDS_PROP_GROUP "Group" - IDS_PROP_BLOCK "Block" - IDS_PROP_COMMENT "Comment" - IDS_PROP_POSITION "Position" - IDS_PROP_PREFIX "Path Prefix" - IDS_PROP_FOLDERS "Folders" - IDS_PROP_FILES "Files" - IDS_PROP_VERSION "Version" - IDS_PROP_VOLUME "Volume" - IDS_PROP_IS_VOLUME "Multivolume" - IDS_PROP_OFFSET "Offset" - IDS_PROP_LINKS "Links" - IDS_PROP_NUM_BLOCKS "Blocks" - IDS_PROP_NUM_VOLUMES "Volumes" + IDS_PROP_SPLIT_AFTER "Split After" + IDS_PROP_DICTIONARY_SIZE "Dictionary" + IDS_PROP_CRC "CRC" + IDS_PROP_FILE_TYPE "Type" + IDS_PROP_ANTI "Anti" + IDS_PROP_METHOD "Method" + IDS_PROP_HOST_OS "Host OS" + IDS_PROP_FILE_SYSTEM "File System" + IDS_PROP_USER "User" + IDS_PROP_GROUP "Group" + IDS_PROP_BLOCK "Block" + IDS_PROP_COMMENT "Comment" + IDS_PROP_POSITION "Position" + IDS_PROP_PREFIX "Path Prefix" + IDS_PROP_FOLDERS "Folders" + IDS_PROP_FILES "Files" + IDS_PROP_VERSION "Version" + IDS_PROP_VOLUME "Volume" + IDS_PROP_IS_VOLUME "Multivolume" + IDS_PROP_OFFSET "Offset" + IDS_PROP_LINKS "Links" + IDS_PROP_NUM_BLOCKS "Blocks" + IDS_PROP_NUM_VOLUMES "Volumes" - IDS_PROP_BIT64 "64-bit" - IDS_PROP_BIG_ENDIAN "Big-endian" - IDS_PROP_CPU "CPU" - IDS_PROP_PHY_SIZE "Physical Size" + IDS_PROP_BIT64 "64-bit" + IDS_PROP_BIG_ENDIAN "Big-endian" + IDS_PROP_CPU "CPU" + IDS_PROP_PHY_SIZE "Physical Size" IDS_PROP_HEADERS_SIZE "Headers Size" - IDS_PROP_CHECKSUM "Checksum" - IDS_PROP_CHARACTS "Characteristics" - IDS_PROP_VA "Virtual Address" - IDS_PROP_ID "ID" - IDS_PROP_SHORT_NAME "Short Name" - IDS_PROP_CREATOR_APP "Creator Application" - IDS_PROP_SECTOR_SIZE "Sector Size" + IDS_PROP_CHECKSUM "Checksum" + IDS_PROP_CHARACTS "Characteristics" + IDS_PROP_VA "Virtual Address" + IDS_PROP_ID "ID" + IDS_PROP_SHORT_NAME "Short Name" + IDS_PROP_CREATOR_APP "Creator Application" + IDS_PROP_SECTOR_SIZE "Sector Size" IDS_PROP_POSIX_ATTRIB "Mode" - IDS_PROP_LINK "Link" - IDS_PROP_ERROR "Error" + IDS_PROP_SYM_LINK "Symbolic Link" + IDS_PROP_ERROR "Error" + IDS_PROP_TOTAL_SIZE "Total Size" + IDS_PROP_FREE_SPACE "Free Space" + IDS_PROP_CLUSTER_SIZE "Cluster Size" + IDS_PROP_VOLUME_NAME "Label" + IDS_PROP_LOCAL_NAME "Local Name" + IDS_PROP_PROVIDER "Provider" + IDS_PROP_NT_SECURITY "NT Security" + IDS_PROP_ALT_STREAM "Alternate Stream" + IDS_PROP_AUX "Aux" + IDS_PROP_DELETED "Deleted" + IDS_PROP_IS_TREE "Is Tree" + IDS_PROP_SHA1 "SHA-1" + IDS_PROP_SHA256 "SHA-256" + IDS_PROP_ERROR_TYPE "Error Type" + IDS_PROP_NUM_ERRORS "Errors" + IDS_PROP_ERROR_FLAGS "Errors" + IDS_PROP_WARNING_FLAGS "Warnings" + IDS_PROP_WARNING "Warning" + IDS_PROP_NUM_STREAMS "Streams" + IDS_PROP_NUM_ALT_STREAMS "Alternate Streams" + IDS_PROP_ALT_STREAMS_SIZE "Alternate Streams Size" + IDS_PROP_VIRTUAL_SIZE "Virtual Size" + IDS_PROP_UNPACK_SIZE "Unpack Size" + IDS_PROP_TOTAL_PHY_SIZE "Total Physical Size" + IDS_PROP_VOLUME_INDEX "Volume Index" + IDS_PROP_SUBTYPE "SubType" + IDS_PROP_SHORT_COMMENT "Short Comment" + IDS_PROP_CODE_PAGE "Code Page" + IDS_PROP_IS_NOT_ARC_TYPE "Is not archive type" + IDS_PROP_PHY_SIZE_CANT_BE_DETECTED "Physical Size can't be detected" + IDS_PROP_ZEROS_TAIL_IS_ALLOWED "Zeros Tail Is Allowed" + IDS_PROP_TAIL_SIZE "Tail Size" + IDS_PROP_EMB_STUB_SIZE "Embedded Stub Size" + IDS_PROP_NT_REPARSE "Link" + IDS_PROP_HARD_LINK "Hard Link" + IDS_PROP_INODE "iNode" + IDS_PROP_STREAM_ID "Stream ID" END diff --git a/CPP/7zip/UI/FileManager/PropertyNameRes.h b/CPP/7zip/UI/FileManager/PropertyNameRes.h old mode 100755 new mode 100644 index 9cc9f7c5..199aa6da --- a/CPP/7zip/UI/FileManager/PropertyNameRes.h +++ b/CPP/7zip/UI/FileManager/PropertyNameRes.h @@ -1,53 +1,92 @@ -#define IDS_PROP_PATH 3 -#define IDS_PROP_NAME 4 -#define IDS_PROP_EXTENSION 5 -#define IDS_PROP_IS_FOLDER 6 -#define IDS_PROP_SIZE 7 -#define IDS_PROP_PACKED_SIZE 8 -#define IDS_PROP_ATTRIBUTES 9 -#define IDS_PROP_CTIME 10 -#define IDS_PROP_ATIME 11 -#define IDS_PROP_MTIME 12 -#define IDS_PROP_SOLID 13 -#define IDS_PROP_C0MMENTED 14 -#define IDS_PROP_ENCRYPTED 15 -#define IDS_PROP_DICTIONARY_SIZE 16 -#define IDS_PROP_SPLIT_BEFORE 17 -#define IDS_PROP_SPLIT_AFTER 18 -#define IDS_PROP_CRC 19 -#define IDS_PROP_FILE_TYPE 20 -#define IDS_PROP_ANTI 21 -#define IDS_PROP_METHOD 22 -#define IDS_PROP_HOST_OS 23 -#define IDS_PROP_FILE_SYSTEM 24 -#define IDS_PROP_USER 25 -#define IDS_PROP_GROUP 26 -#define IDS_PROP_BLOCK 27 -#define IDS_PROP_COMMENT 28 -#define IDS_PROP_POSITION 29 -#define IDS_PROP_PREFIX 30 -#define IDS_PROP_FOLDERS 31 -#define IDS_PROP_FILES 32 -#define IDS_PROP_VERSION 33 -#define IDS_PROP_VOLUME 34 -#define IDS_PROP_IS_VOLUME 35 -#define IDS_PROP_OFFSET 36 -#define IDS_PROP_LINKS 37 -#define IDS_PROP_NUM_BLOCKS 38 -#define IDS_PROP_NUM_VOLUMES 39 -#define IDS_PROP_BIT64 41 -#define IDS_PROP_BIG_ENDIAN 42 -#define IDS_PROP_CPU 43 -#define IDS_PROP_PHY_SIZE 44 -#define IDS_PROP_HEADERS_SIZE 45 -#define IDS_PROP_CHECKSUM 46 -#define IDS_PROP_CHARACTS 47 -#define IDS_PROP_VA 48 -#define IDS_PROP_ID 49 -#define IDS_PROP_SHORT_NAME 50 -#define IDS_PROP_CREATOR_APP 51 -#define IDS_PROP_SECTOR_SIZE 52 -#define IDS_PROP_POSIX_ATTRIB 53 -#define IDS_PROP_LINK 54 -#define IDS_PROP_ERROR 55 + +#define IDS_PROP_PATH 1003 +#define IDS_PROP_NAME 1004 +#define IDS_PROP_EXTENSION 1005 +#define IDS_PROP_IS_FOLDER 1006 +#define IDS_PROP_SIZE 1007 +#define IDS_PROP_PACKED_SIZE 1008 +#define IDS_PROP_ATTRIBUTES 1009 +#define IDS_PROP_CTIME 1010 +#define IDS_PROP_ATIME 1011 +#define IDS_PROP_MTIME 1012 +#define IDS_PROP_SOLID 1013 +#define IDS_PROP_C0MMENTED 1014 +#define IDS_PROP_ENCRYPTED 1015 +#define IDS_PROP_SPLIT_BEFORE 1016 +#define IDS_PROP_SPLIT_AFTER 1017 +#define IDS_PROP_DICTIONARY_SIZE 1018 +#define IDS_PROP_CRC 1019 +#define IDS_PROP_FILE_TYPE 1020 +#define IDS_PROP_ANTI 1021 +#define IDS_PROP_METHOD 1022 +#define IDS_PROP_HOST_OS 1023 +#define IDS_PROP_FILE_SYSTEM 1024 +#define IDS_PROP_USER 1025 +#define IDS_PROP_GROUP 1026 +#define IDS_PROP_BLOCK 1027 +#define IDS_PROP_COMMENT 1028 +#define IDS_PROP_POSITION 1029 +#define IDS_PROP_PREFIX 1030 +#define IDS_PROP_FOLDERS 1031 +#define IDS_PROP_FILES 1032 +#define IDS_PROP_VERSION 1033 +#define IDS_PROP_VOLUME 1034 +#define IDS_PROP_IS_VOLUME 1035 +#define IDS_PROP_OFFSET 1036 +#define IDS_PROP_LINKS 1037 +#define IDS_PROP_NUM_BLOCKS 1038 +#define IDS_PROP_NUM_VOLUMES 1039 + +#define IDS_PROP_BIT64 1041 +#define IDS_PROP_BIG_ENDIAN 1042 +#define IDS_PROP_CPU 1043 +#define IDS_PROP_PHY_SIZE 1044 +#define IDS_PROP_HEADERS_SIZE 1045 +#define IDS_PROP_CHECKSUM 1046 +#define IDS_PROP_CHARACTS 1047 +#define IDS_PROP_VA 1048 +#define IDS_PROP_ID 1049 +#define IDS_PROP_SHORT_NAME 1050 +#define IDS_PROP_CREATOR_APP 1051 +#define IDS_PROP_SECTOR_SIZE 1052 +#define IDS_PROP_POSIX_ATTRIB 1053 +#define IDS_PROP_SYM_LINK 1054 +#define IDS_PROP_ERROR 1055 +#define IDS_PROP_TOTAL_SIZE 1056 +#define IDS_PROP_FREE_SPACE 1057 +#define IDS_PROP_CLUSTER_SIZE 1058 +#define IDS_PROP_VOLUME_NAME 1059 +#define IDS_PROP_LOCAL_NAME 1060 +#define IDS_PROP_PROVIDER 1061 +#define IDS_PROP_NT_SECURITY 1062 +#define IDS_PROP_ALT_STREAM 1063 +#define IDS_PROP_AUX 1064 +#define IDS_PROP_DELETED 1065 +#define IDS_PROP_IS_TREE 1066 +#define IDS_PROP_SHA1 1067 +#define IDS_PROP_SHA256 1068 +#define IDS_PROP_ERROR_TYPE 1069 +#define IDS_PROP_NUM_ERRORS 1070 +#define IDS_PROP_ERROR_FLAGS 1071 +#define IDS_PROP_WARNING_FLAGS 1072 +#define IDS_PROP_WARNING 1073 +#define IDS_PROP_NUM_STREAMS 1074 +#define IDS_PROP_NUM_ALT_STREAMS 1075 +#define IDS_PROP_ALT_STREAMS_SIZE 1076 +#define IDS_PROP_VIRTUAL_SIZE 1077 +#define IDS_PROP_UNPACK_SIZE 1078 +#define IDS_PROP_TOTAL_PHY_SIZE 1079 +#define IDS_PROP_VOLUME_INDEX 1080 +#define IDS_PROP_SUBTYPE 1081 +#define IDS_PROP_SHORT_COMMENT 1082 +#define IDS_PROP_CODE_PAGE 1083 +#define IDS_PROP_IS_NOT_ARC_TYPE 1084 +#define IDS_PROP_PHY_SIZE_CANT_BE_DETECTED 1085 +#define IDS_PROP_ZEROS_TAIL_IS_ALLOWED 1086 +#define IDS_PROP_TAIL_SIZE 1087 +#define IDS_PROP_EMB_STUB_SIZE 1088 +#define IDS_PROP_NT_REPARSE 1089 +#define IDS_PROP_HARD_LINK 1090 +#define IDS_PROP_INODE 1091 +#define IDS_PROP_STREAM_ID 1092 diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp old mode 100755 new mode 100644 index 487b6060..ee944350 --- a/CPP/7zip/UI/FileManager/RegistryAssociations.cpp +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.cpp @@ -2,11 +2,11 @@ #include "StdAfx.h" -#include "Common/IntToString.h" -#include "Common/StringConvert.h" -#include "Common/StringToInt.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/StringConvert.h" +#include "../../../Common/StringToInt.h" -#include "Windows/Registry.h" +#include "../../../Windows/Registry.h" #include "RegistryAssociations.h" @@ -69,11 +69,13 @@ bool CShellExtInfo::ReadFromRegistry(HKEY hkey, const CSysString &ext) if (pos >= 0) { const wchar_t *end; - Int64 index = ConvertStringToInt64((const wchar_t *)value + pos + 1, &end); + Int32 index = ConvertStringToInt32((const wchar_t *)value + pos + 1, &end); if (*end == 0) { - IconIndex = (int)index; - IconPath = value.Left(pos); + // 9.31: if there is no icon index, we use -1. Is it OK? + if (pos != (int)value.Len() - 1) + IconIndex = (int)index; + IconPath.SetFrom(value, pos); } } } @@ -85,7 +87,7 @@ bool CShellExtInfo::ReadFromRegistry(HKEY hkey, const CSysString &ext) bool CShellExtInfo::IsIt7Zip() const { UString s = GetUnicodeString(k7zipPrefix); - return (s.CompareNoCase(GetUnicodeString(ProgramKey.Left(s.Length()))) == 0); + return MyStringCompareNoCase_N(GetUnicodeString(ProgramKey), s, s.Len()) == 0; } LONG DeleteShellExtensionInfo(HKEY hkey, const CSysString &ext) @@ -143,7 +145,7 @@ LONG AddShellExtensionInfo(HKEY hkey, { iconPathFull += L','; wchar_t s[16]; - ConvertInt64ToString(iconIndex, s); + ConvertUInt32ToString((UInt32)iconIndex, s); iconPathFull += s; } iconKey.Create(programKey, kDefaultIconKeyName); diff --git a/CPP/7zip/UI/FileManager/RegistryAssociations.h b/CPP/7zip/UI/FileManager/RegistryAssociations.h old mode 100755 new mode 100644 index 0be8244e..975c9d5f --- a/CPP/7zip/UI/FileManager/RegistryAssociations.h +++ b/CPP/7zip/UI/FileManager/RegistryAssociations.h @@ -3,7 +3,7 @@ #ifndef __REGISTRY_ASSOCIATIONS_H #define __REGISTRY_ASSOCIATIONS_H -#include "Common/MyString.h" +#include "../../../Common/MyString.h" namespace NRegistryAssoc { diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp old mode 100755 new mode 100644 index 54254f1f..ad70db80 --- a/CPP/7zip/UI/FileManager/RegistryPlugins.cpp +++ b/CPP/7zip/UI/FileManager/RegistryPlugins.cpp @@ -2,9 +2,9 @@ #include "StdAfx.h" -#include "Windows/DLL.h" -#include "Windows/FileFind.h" -#include "Windows/PropVariant.h" +#include "../../../Windows/DLL.h" +#include "../../../Windows/FileFind.h" +#include "../../../Windows/PropVariant.h" #include "IFolder.h" #include "RegistryPlugins.h" @@ -118,7 +118,7 @@ void ReadPluginInfoList(CObjectVector &plugins) void ReadFileFolderPluginInfoList(CObjectVector &plugins) { ReadPluginInfoList(plugins); - for (int i = 0; i < plugins.Size();) + for (unsigned i = 0; i < plugins.Size();) if (plugins[i].Type != kPluginTypeFF) plugins.Delete(i); else diff --git a/CPP/7zip/UI/FileManager/RegistryPlugins.h b/CPP/7zip/UI/FileManager/RegistryPlugins.h old mode 100755 new mode 100644 index 20f2ec34..dfa6de54 --- a/CPP/7zip/UI/FileManager/RegistryPlugins.h +++ b/CPP/7zip/UI/FileManager/RegistryPlugins.h @@ -3,7 +3,7 @@ #ifndef __REGISTRY_PLUGINS_H #define __REGISTRY_PLUGINS_H -#include "Common/MyString.h" +#include "../../../Common/MyString.h" enum EPluginType { diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.cpp b/CPP/7zip/UI/FileManager/RegistryUtils.cpp old mode 100755 new mode 100644 index 6697169b..ffcb5555 --- a/CPP/7zip/UI/FileManager/RegistryUtils.cpp +++ b/CPP/7zip/UI/FileManager/RegistryUtils.cpp @@ -2,9 +2,9 @@ #include "StdAfx.h" -#include "Common/IntToString.h" +#include "../../../Common/IntToString.h" -#include "Windows/Registry.h" +#include "../../../Windows/Registry.h" #include "RegistryUtils.h" @@ -18,6 +18,7 @@ static const TCHAR *kCU_FMPath = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("F // static const TCHAR *kLM_Path = REG_PATH_7Z TEXT(STRING_PATH_SEPARATOR) TEXT("FM"); static const WCHAR *kLangValueName = L"Lang"; +static const WCHAR *kViewer = L"Viewer"; static const WCHAR *kEditor = L"Editor"; static const WCHAR *kDiff = L"Diff"; static const TCHAR *kShowDots = TEXT("ShowDots"); @@ -33,6 +34,7 @@ static const TCHAR *kSingleClick = TEXT("SingleClick"); // static const TCHAR *kUnderline = TEXT("Underline"); static const TCHAR *kFlatViewName = TEXT("FlatViewArc"); +// static const TCHAR *kShowDeletedFiles = TEXT("ShowDeleted"); static void SaveCuString(LPCTSTR keyPath, LPCWSTR valuePath, LPCWSTR value) { @@ -52,8 +54,8 @@ static void ReadCuString(LPCTSTR keyPath, LPCWSTR valuePath, UString &res) void SaveRegLang(const UString &path) { SaveCuString(kCUBasePath, kLangValueName, path); } void ReadRegLang(UString &path) { ReadCuString(kCUBasePath, kLangValueName, path); } -void SaveRegEditor(const UString &path) { SaveCuString(kCU_FMPath, kEditor, path); } -void ReadRegEditor(UString &path) { ReadCuString(kCU_FMPath, kEditor, path); } +void SaveRegEditor(bool useEditor, const UString &path) { SaveCuString(kCU_FMPath, useEditor ? kEditor : kViewer, path); } +void ReadRegEditor(bool useEditor, UString &path) { ReadCuString(kCU_FMPath, useEditor ? kEditor : kViewer, path); } void SaveRegDiff(const UString &path) { SaveCuString(kCU_FMPath, kDiff, path); } void ReadRegDiff(UString &path) { ReadCuString(kCU_FMPath, kDiff, path); } @@ -123,8 +125,8 @@ bool ReadShowDots() { return ReadOption(kShowDots, false); } void SaveShowRealFileIcons(bool show) { SaveOption(kShowRealFileIcons, show); } bool ReadShowRealFileIcons() { return ReadOption(kShowRealFileIcons, false); } -void SaveShowSystemMenu(bool show) { SaveOption(kShowSystemMenu, show); } -bool ReadShowSystemMenu(){ return ReadOption(kShowSystemMenu, false); } +void Save_ShowSystemMenu(bool show) { SaveOption(kShowSystemMenu, show); } +bool Read_ShowSystemMenu(){ return ReadOption(kShowSystemMenu, false); } void SaveFullRow(bool enable) { SaveOption(kFullRow, enable); } bool ReadFullRow() { return ReadOption(kFullRow, false); } @@ -158,3 +160,8 @@ static CSysString GetFlatViewName(UInt32 panelIndex) void SaveFlatView(UInt32 panelIndex, bool enable) { SaveOption(GetFlatViewName(panelIndex), enable); } bool ReadFlatView(UInt32 panelIndex) { return ReadOption(GetFlatViewName(panelIndex), false); } + +/* +void Save_ShowDeleted(bool enable) { SaveOption(kShowDeletedFiles, enable); } +bool Read_ShowDeleted() { return ReadOption(kShowDeletedFiles, false); } +*/ \ No newline at end of file diff --git a/CPP/7zip/UI/FileManager/RegistryUtils.h b/CPP/7zip/UI/FileManager/RegistryUtils.h old mode 100755 new mode 100644 index 3bf06617..678a3375 --- a/CPP/7zip/UI/FileManager/RegistryUtils.h +++ b/CPP/7zip/UI/FileManager/RegistryUtils.h @@ -3,14 +3,14 @@ #ifndef __REGISTRY_UTILS_H #define __REGISTRY_UTILS_H -#include "Common/MyString.h" -#include "Common/Types.h" +#include "../../../Common/MyTypes.h" +#include "../../../Common/MyString.h" void SaveRegLang(const UString &path); void ReadRegLang(UString &path); -void SaveRegEditor(const UString &path); -void ReadRegEditor(UString &path); +void SaveRegEditor(bool useEditor, const UString &path); +void ReadRegEditor(bool useEditor, UString &path); void SaveRegDiff(const UString &path); void ReadRegDiff(UString &path); @@ -21,8 +21,8 @@ bool ReadShowDots(); void SaveShowRealFileIcons(bool show); bool ReadShowRealFileIcons(); -void SaveShowSystemMenu(bool showSystemMenu); -bool ReadShowSystemMenu(); +void Save_ShowSystemMenu(bool showSystemMenu); +bool Read_ShowSystemMenu(); void SaveFullRow(bool enable); bool ReadFullRow(); @@ -50,4 +50,9 @@ bool ReadUnderline(); void SaveFlatView(UInt32 panelIndex, bool enable); bool ReadFlatView(UInt32 panelIndex); +/* +void Save_ShowDeleted(bool enable); +bool Read_ShowDeleted(); +*/ + #endif diff --git a/CPP/7zip/UI/FileManager/RootFolder.cpp b/CPP/7zip/UI/FileManager/RootFolder.cpp old mode 100755 new mode 100644 index a81f94c1..234c51dd --- a/CPP/7zip/UI/FileManager/RootFolder.cpp +++ b/CPP/7zip/UI/FileManager/RootFolder.cpp @@ -2,10 +2,11 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" +#include "../../../Common/StringConvert.h" -#include "Windows/DLL.h" -#include "Windows/PropVariant.h" +#include "../../../Windows/DLL.h" +#include "../../../Windows/FileName.h" +#include "../../../Windows/PropVariant.h" #include "../../PropID.h" @@ -22,9 +23,9 @@ using namespace NWindows; -static const STATPROPSTG kProps[] = +static const PROPID kProps[] = { - { NULL, kpidName, VT_BSTR} + kpidName }; UString RootFolder_GetName_Computer(int &iconIndex) @@ -34,19 +35,19 @@ UString RootFolder_GetName_Computer(int &iconIndex) #else iconIndex = GetIconIndexForCSIDL(CSIDL_DRIVES); #endif - return LangString(IDS_COMPUTER, 0x03020300); + return LangString(IDS_COMPUTER); } UString RootFolder_GetName_Network(int &iconIndex) { iconIndex = GetIconIndexForCSIDL(CSIDL_NETWORK); - return LangString(IDS_NETWORK, 0x03020301); + return LangString(IDS_NETWORK); } UString RootFolder_GetName_Documents(int &iconIndex) { iconIndex = GetIconIndexForCSIDL(CSIDL_PERSONAL); - return LangString(IDS_DOCUMENTS, 0x03020302); ; + return LangString(IDS_DOCUMENTS); } enum @@ -123,7 +124,7 @@ UString GetMyDocsPath() us = GetUnicodeString(s2); } #endif - if (us.Length() > 0 && us.Back() != WCHAR_PATH_SEPARATOR) + if (us.Len() > 0 && us.Back() != WCHAR_PATH_SEPARATOR) us += WCHAR_PATH_SEPARATOR; return us; } @@ -169,9 +170,14 @@ STDMETHODIMP CRootFolder::BindToFolder(UInt32 index, IFolderFolder **resultFolde return S_OK; } -static bool AreEqualNames(const UString &name1, const UString &name2) +static bool AreEqualNames(const UString &path, const wchar_t *name) { - return (name1 == name2 || name1 == (name2 + UString(WCHAR_PATH_SEPARATOR))); + unsigned len = MyStringLen(name); + if (len > path.Len() || len + 1 < path.Len()) + return false; + if (len + 1 == path.Len() && path[len] != WCHAR_PATH_SEPARATOR) + return false; + return path.IsPrefixedBy(name); } STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resultFolder) @@ -208,22 +214,28 @@ STDMETHODIMP CRootFolder::BindToFolder(const wchar_t *name, IFolderFolder **resu return S_OK; } - if (name2.Length () < 2) + if (name2.Len() < 2) return E_INVALIDARG; CMyComPtr subFolder; #ifndef UNDER_CE - if (name2.Left(4) == kVolPrefix) + if (name2.IsPrefixedBy(kVolPrefix)) { CFSDrives *folderSpec = new CFSDrives; subFolder = folderSpec; folderSpec->Init(true); } + else if (name2 == NFile::NName::kSuperPathPrefix) + { + CFSDrives *folderSpec = new CFSDrives; + subFolder = folderSpec; + folderSpec->Init(false, true); + } else #endif { - if (name2[name2.Length () - 1] != WCHAR_PATH_SEPARATOR) + if (name2[name2.Len() - 1] != WCHAR_PATH_SEPARATOR) name2 += WCHAR_PATH_SEPARATOR; NFsFolder::CFSFolder *fsFolderSpec = new NFsFolder::CFSFolder; subFolder = fsFolderSpec; diff --git a/CPP/7zip/UI/FileManager/RootFolder.h b/CPP/7zip/UI/FileManager/RootFolder.h old mode 100755 new mode 100644 index 21d74db8..e9ef2d8c --- a/CPP/7zip/UI/FileManager/RootFolder.h +++ b/CPP/7zip/UI/FileManager/RootFolder.h @@ -3,7 +3,7 @@ #ifndef __ROOT_FOLDER_H #define __ROOT_FOLDER_H -#include "Common/MyString.h" +#include "../../../Common/MyString.h" #include "IFolder.h" diff --git a/CPP/7zip/UI/FileManager/SettingsPage.cpp b/CPP/7zip/UI/FileManager/SettingsPage.cpp old mode 100755 new mode 100644 index 866b0b2d..7a51e1b7 --- a/CPP/7zip/UI/FileManager/SettingsPage.cpp +++ b/CPP/7zip/UI/FileManager/SettingsPage.cpp @@ -2,10 +2,10 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" +#include "../../../Common/StringConvert.h" #ifndef UNDER_CE -#include "Windows/MemoryLock.h" +#include "../../../Windows/MemoryLock.h" #endif #include "HelpUtils.h" @@ -17,17 +17,16 @@ using namespace NWindows; -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_SETTINGS_SHOW_DOTS, 0x03010401}, - { IDC_SETTINGS_SHOW_REAL_FILE_ICONS, 0x03010402}, - { IDC_SETTINGS_SHOW_SYSTEM_MENU, 0x03010410}, - { IDC_SETTINGS_FULL_ROW, 0x03010420}, - { IDC_SETTINGS_SHOW_GRID, 0x03010421}, - { IDC_SETTINGS_SINGLE_CLICK, 0x03010422}, - // { IDC_SETTINGS_UNDERLINE, 0x03010423} - { IDC_SETTINGS_ALTERNATIVE_SELECTION, 0x03010430}, - { IDC_SETTINGS_LARGE_PAGES, 0x03010440} + IDX_SETTINGS_SHOW_DOTS, + IDX_SETTINGS_SHOW_REAL_FILE_ICONS, + IDX_SETTINGS_SHOW_SYSTEM_MENU, + IDX_SETTINGS_FULL_ROW, + IDX_SETTINGS_SHOW_GRID, + IDX_SETTINGS_SINGLE_CLICK, + IDX_SETTINGS_ALTERNATIVE_SELECTION, + IDX_SETTINGS_LARGE_PAGES }; static LPCWSTR kEditTopic = L"FM/options.htm#settings"; @@ -36,21 +35,20 @@ extern bool IsLargePageSupported(); bool CSettingsPage::OnInit() { - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); - - CheckButton(IDC_SETTINGS_SHOW_DOTS, ReadShowDots()); - CheckButton(IDC_SETTINGS_SHOW_SYSTEM_MENU, ReadShowSystemMenu()); - CheckButton(IDC_SETTINGS_SHOW_REAL_FILE_ICONS, ReadShowRealFileIcons()); - - CheckButton(IDC_SETTINGS_FULL_ROW, ReadFullRow()); - CheckButton(IDC_SETTINGS_SHOW_GRID, ReadShowGrid()); - CheckButton(IDC_SETTINGS_ALTERNATIVE_SELECTION, ReadAlternativeSelection()); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); + + CheckButton(IDX_SETTINGS_SHOW_DOTS, ReadShowDots()); + CheckButton(IDX_SETTINGS_SHOW_SYSTEM_MENU, Read_ShowSystemMenu()); + CheckButton(IDX_SETTINGS_SHOW_REAL_FILE_ICONS, ReadShowRealFileIcons()); + CheckButton(IDX_SETTINGS_FULL_ROW, ReadFullRow()); + CheckButton(IDX_SETTINGS_SHOW_GRID, ReadShowGrid()); + CheckButton(IDX_SETTINGS_ALTERNATIVE_SELECTION, ReadAlternativeSelection()); if (IsLargePageSupported()) - CheckButton(IDC_SETTINGS_LARGE_PAGES, ReadLockMemoryEnable()); + CheckButton(IDX_SETTINGS_LARGE_PAGES, ReadLockMemoryEnable()); else - EnableItem(IDC_SETTINGS_LARGE_PAGES, false); - CheckButton(IDC_SETTINGS_SINGLE_CLICK, ReadSingleClick()); - // CheckButton(IDC_SETTINGS_UNDERLINE, ReadUnderline()); + EnableItem(IDX_SETTINGS_LARGE_PAGES, false); + CheckButton(IDX_SETTINGS_SINGLE_CLICK, ReadSingleClick()); + // CheckButton(IDX_SETTINGS_UNDERLINE, ReadUnderline()); // EnableSubItems(); @@ -60,30 +58,30 @@ bool CSettingsPage::OnInit() /* void CSettingsPage::EnableSubItems() { - EnableItem(IDC_SETTINGS_UNDERLINE, IsButtonCheckedBool(IDC_SETTINGS_SINGLE_CLICK)); + EnableItem(IDX_SETTINGS_UNDERLINE, IsButtonCheckedBool(IDX_SETTINGS_SINGLE_CLICK)); } */ LONG CSettingsPage::OnApply() { - SaveShowDots(IsButtonCheckedBool(IDC_SETTINGS_SHOW_DOTS)); - SaveShowSystemMenu(IsButtonCheckedBool(IDC_SETTINGS_SHOW_SYSTEM_MENU)); - SaveShowRealFileIcons(IsButtonCheckedBool(IDC_SETTINGS_SHOW_REAL_FILE_ICONS)); + SaveShowDots(IsButtonCheckedBool(IDX_SETTINGS_SHOW_DOTS)); + Save_ShowSystemMenu(IsButtonCheckedBool(IDX_SETTINGS_SHOW_SYSTEM_MENU)); + SaveShowRealFileIcons(IsButtonCheckedBool(IDX_SETTINGS_SHOW_REAL_FILE_ICONS)); - SaveFullRow(IsButtonCheckedBool(IDC_SETTINGS_FULL_ROW)); - SaveShowGrid(IsButtonCheckedBool(IDC_SETTINGS_SHOW_GRID)); - SaveAlternativeSelection(IsButtonCheckedBool(IDC_SETTINGS_ALTERNATIVE_SELECTION)); + SaveFullRow(IsButtonCheckedBool(IDX_SETTINGS_FULL_ROW)); + SaveShowGrid(IsButtonCheckedBool(IDX_SETTINGS_SHOW_GRID)); + SaveAlternativeSelection(IsButtonCheckedBool(IDX_SETTINGS_ALTERNATIVE_SELECTION)); #ifndef UNDER_CE if (IsLargePageSupported()) { - bool enable = IsButtonCheckedBool(IDC_SETTINGS_LARGE_PAGES); - NSecurity::EnableLockMemoryPrivilege(enable); + bool enable = IsButtonCheckedBool(IDX_SETTINGS_LARGE_PAGES); + NSecurity::EnablePrivilege_LockMemory(enable); SaveLockMemoryEnable(enable); } #endif - SaveSingleClick(IsButtonCheckedBool(IDC_SETTINGS_SINGLE_CLICK)); - // SaveUnderline(IsButtonCheckedBool(IDC_SETTINGS_UNDERLINE)); + SaveSingleClick(IsButtonCheckedBool(IDX_SETTINGS_SINGLE_CLICK)); + // SaveUnderline(IsButtonCheckedBool(IDX_SETTINGS_UNDERLINE)); return PSNRET_NOERROR; } @@ -97,18 +95,18 @@ bool CSettingsPage::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { - case IDC_SETTINGS_SINGLE_CLICK: + case IDX_SETTINGS_SINGLE_CLICK: /* EnableSubItems(); break; */ - case IDC_SETTINGS_SHOW_DOTS: - case IDC_SETTINGS_SHOW_SYSTEM_MENU: - case IDC_SETTINGS_SHOW_REAL_FILE_ICONS: - case IDC_SETTINGS_FULL_ROW: - case IDC_SETTINGS_SHOW_GRID: - case IDC_SETTINGS_ALTERNATIVE_SELECTION: - case IDC_SETTINGS_LARGE_PAGES: + case IDX_SETTINGS_SHOW_DOTS: + case IDX_SETTINGS_SHOW_SYSTEM_MENU: + case IDX_SETTINGS_SHOW_REAL_FILE_ICONS: + case IDX_SETTINGS_FULL_ROW: + case IDX_SETTINGS_SHOW_GRID: + case IDX_SETTINGS_ALTERNATIVE_SELECTION: + case IDX_SETTINGS_LARGE_PAGES: Changed(); return true; } diff --git a/CPP/7zip/UI/FileManager/SettingsPage.h b/CPP/7zip/UI/FileManager/SettingsPage.h old mode 100755 new mode 100644 index e5fe6e67..e7e5d73e --- a/CPP/7zip/UI/FileManager/SettingsPage.h +++ b/CPP/7zip/UI/FileManager/SettingsPage.h @@ -1,10 +1,10 @@ // SettingsPage.h -#ifndef __SETTINGSPAGE_H -#define __SETTINGSPAGE_H +#ifndef __SETTINGS_PAGE_H +#define __SETTINGS_PAGE_H -#include "Windows/Control/PropertyPage.h" -#include "Windows/Control/Edit.h" +#include "../../../Windows/Control/PropertyPage.h" +#include "../../../Windows/Control/Edit.h" class CSettingsPage: public NWindows::NControl::CPropertyPage { diff --git a/CPP/7zip/UI/FileManager/SettingsPage.rc b/CPP/7zip/UI/FileManager/SettingsPage.rc old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/SettingsPage2.rc b/CPP/7zip/UI/FileManager/SettingsPage2.rc old mode 100755 new mode 100644 index c920120e..66629612 --- a/CPP/7zip/UI/FileManager/SettingsPage2.rc +++ b/CPP/7zip/UI/FileManager/SettingsPage2.rc @@ -1,24 +1,11 @@ CAPTION "Settings" -BEGIN - CONTROL "Show "".."" item", IDC_SETTINGS_SHOW_DOTS, MY_CHECKBOX, - m, 8, xc, 10 - CONTROL "Show real file &icons", IDC_SETTINGS_SHOW_REAL_FILE_ICONS, MY_CHECKBOX, - m, 22, xc, 10 - CONTROL "Show system &menu", IDC_SETTINGS_SHOW_SYSTEM_MENU, MY_CHECKBOX, - m, 36, xc, 10 - CONTROL "&Full row select", IDC_SETTINGS_FULL_ROW, MY_CHECKBOX, - m, 50, xc, 10 - CONTROL "Show &grid lines", IDC_SETTINGS_SHOW_GRID, MY_CHECKBOX, - m, 64, xc, 10 - CONTROL "&Single-click to open an item", IDC_SETTINGS_SINGLE_CLICK, MY_CHECKBOX, - m, 78, xc, 10 - /* - CONTROL "&Underline current name", IDC_SETTINGS_UNDERLINE, "Button", BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP, - m + 12, 92, xc - 12, 10 - */ - - CONTROL "&Alternative selection mode", IDC_SETTINGS_ALTERNATIVE_SELECTION, MY_CHECKBOX, - m, 92, xc, 10 - CONTROL "Use &large memory pages", IDC_SETTINGS_LARGE_PAGES, MY_CHECKBOX, - m, 106, xc, 10 +BEGIN + CONTROL "Show "".."" item", IDX_SETTINGS_SHOW_DOTS, MY_CHECKBOX, m, 8, xc, 10 + CONTROL "Show real file &icons", IDX_SETTINGS_SHOW_REAL_FILE_ICONS, MY_CHECKBOX, m, 22, xc, 10 + CONTROL "Show system &menu", IDX_SETTINGS_SHOW_SYSTEM_MENU, MY_CHECKBOX, m, 36, xc, 10 + CONTROL "&Full row select", IDX_SETTINGS_FULL_ROW, MY_CHECKBOX, m, 50, xc, 10 + CONTROL "Show &grid lines", IDX_SETTINGS_SHOW_GRID, MY_CHECKBOX, m, 64, xc, 10 + CONTROL "&Single-click to open an item", IDX_SETTINGS_SINGLE_CLICK, MY_CHECKBOX, m, 78, xc, 10 + CONTROL "&Alternative selection mode", IDX_SETTINGS_ALTERNATIVE_SELECTION, MY_CHECKBOX, m, 92, xc, 10 + CONTROL "Use &large memory pages", IDX_SETTINGS_LARGE_PAGES, MY_CHECKBOX, m, 106, xc, 10 END diff --git a/CPP/7zip/UI/FileManager/SettingsPageRes.h b/CPP/7zip/UI/FileManager/SettingsPageRes.h old mode 100755 new mode 100644 index b6c7f5cc..71204597 --- a/CPP/7zip/UI/FileManager/SettingsPageRes.h +++ b/CPP/7zip/UI/FileManager/SettingsPageRes.h @@ -1,13 +1,11 @@ -#define IDD_SETTINGS 543 -#define IDD_SETTINGS_2 643 +#define IDD_SETTINGS 2500 +#define IDD_SETTINGS_2 12500 -#define IDC_SETTINGS_SHOW_DOTS 1000 -#define IDC_SETTINGS_SHOW_REAL_FILE_ICONS 1001 - -#define IDC_SETTINGS_SHOW_SYSTEM_MENU 1010 -#define IDC_SETTINGS_FULL_ROW 1011 -#define IDC_SETTINGS_SHOW_GRID 1013 -#define IDC_SETTINGS_SINGLE_CLICK 1014 -#define IDC_SETTINGS_UNDERLINE 1015 -#define IDC_SETTINGS_ALTERNATIVE_SELECTION 1016 -#define IDC_SETTINGS_LARGE_PAGES 1017 +#define IDX_SETTINGS_SHOW_DOTS 2501 +#define IDX_SETTINGS_SHOW_REAL_FILE_ICONS 2502 +#define IDX_SETTINGS_SHOW_SYSTEM_MENU 2503 +#define IDX_SETTINGS_FULL_ROW 2504 +#define IDX_SETTINGS_SHOW_GRID 2505 +#define IDX_SETTINGS_SINGLE_CLICK 2506 +#define IDX_SETTINGS_ALTERNATIVE_SELECTION 2507 +#define IDX_SETTINGS_LARGE_PAGES 2508 diff --git a/CPP/7zip/UI/FileManager/SplitDialog.cpp b/CPP/7zip/UI/FileManager/SplitDialog.cpp old mode 100755 new mode 100644 index 5dca8e48..d35d76c9 --- a/CPP/7zip/UI/FileManager/SplitDialog.cpp +++ b/CPP/7zip/UI/FileManager/SplitDialog.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#include "Windows/FileName.h" +#include "../../../Windows/FileName.h" #ifdef LANG #include "LangUtils.h" @@ -17,10 +17,10 @@ using namespace NWindows; #ifdef LANG -static CIDLangPair kIDLangPairs[] = +static const UInt32 kLangIDs[] = { - { IDC_STATIC_SPLIT_PATH, 0x03020501 }, - { IDC_STATIC_SPLIT_VOLUME, 0x02000D40 }, + IDT_SPLIT_PATH, + IDT_SPLIT_VOLUME }; #endif @@ -28,11 +28,11 @@ static CIDLangPair kIDLangPairs[] = bool CSplitDialog::OnInit() { #ifdef LANG - LangSetWindowText(HWND(*this), 0x03020500); - LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetWindowText(*this, IDD_SPLIT); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); #endif - _pathCombo.Attach(GetItem(IDC_COMBO_SPLIT_PATH)); - _volumeCombo.Attach(GetItem(IDC_COMBO_SPLIT_VOLUME)); + _pathCombo.Attach(GetItem(IDC_SPLIT_PATH)); + _volumeCombo.Attach(GetItem(IDC_SPLIT_VOLUME)); if (!FilePath.IsEmpty()) { @@ -62,10 +62,10 @@ bool CSplitDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) InvalidateRect(NULL); { - RECT rect; - GetClientRectOfItem(IDC_BUTTON_SPLIT_PATH, rect); - int bx = rect.right - rect.left; - MoveItem(IDC_BUTTON_SPLIT_PATH, xSize - mx - bx, rect.top, bx, rect.bottom - rect.top); + RECT r; + GetClientRectOfItem(IDB_SPLIT_PATH, r); + int bx = RECT_SIZE_X(r); + MoveItem(IDB_SPLIT_PATH, xSize - mx - bx, r.top, bx, RECT_SIZE_Y(r)); ChangeSubWindowSizeX(_pathCombo, xSize - mx - mx - bx - mx); } @@ -79,7 +79,7 @@ bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND) { switch(buttonID) { - case IDC_BUTTON_SPLIT_PATH: + case IDB_SPLIT_PATH: OnButtonSetPath(); return true; } @@ -91,10 +91,10 @@ void CSplitDialog::OnButtonSetPath() UString currentPath; _pathCombo.GetText(currentPath); // UString title = L"Specify a location for output folder"; - UString title = LangStringSpec(IDS_SET_FOLDER, 0x03020209); + UString title = LangString(IDS_SET_FOLDER); UString resultPath; - if (!MyBrowseForFolder(HWND(*this), title, currentPath, resultPath)) + if (!MyBrowseForFolder(*this, title, currentPath, resultPath)) return; NFile::NName::NormalizeDirPathPrefix(resultPath); _pathCombo.SetCurSel(-1); @@ -109,7 +109,7 @@ void CSplitDialog::OnOK() volumeString.Trim(); if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0) { - ::MessageBoxW(*this, LangString(IDS_INCORRECT_VOLUME_SIZE, 0x02000D41), L"7-Zip", 0); + ::MessageBoxW(*this, LangString(IDS_INCORRECT_VOLUME_SIZE), L"7-Zip", MB_ICONERROR); return; } CModalDialog::OnOK(); diff --git a/CPP/7zip/UI/FileManager/SplitDialog.h b/CPP/7zip/UI/FileManager/SplitDialog.h old mode 100755 new mode 100644 index 33fb64e7..00aae658 --- a/CPP/7zip/UI/FileManager/SplitDialog.h +++ b/CPP/7zip/UI/FileManager/SplitDialog.h @@ -3,8 +3,8 @@ #ifndef __SPLIT_DIALOG_H #define __SPLIT_DIALOG_H -#include "Windows/Control/Dialog.h" -#include "Windows/Control/ComboBox.h" +#include "../../../Windows/Control/Dialog.h" +#include "../../../Windows/Control/ComboBox.h" #include "SplitDialogRes.h" @@ -22,7 +22,7 @@ public: UString Path; CRecordVector VolumeSizes; INT_PTR Create(HWND parentWindow = 0) - { return CModalDialog::Create(IDD_DIALOG_SPLIT, parentWindow); } + { return CModalDialog::Create(IDD_SPLIT, parentWindow); } }; #endif diff --git a/CPP/7zip/UI/FileManager/SplitDialog.rc b/CPP/7zip/UI/FileManager/SplitDialog.rc old mode 100755 new mode 100644 index e977d651..5a026e8a --- a/CPP/7zip/UI/FileManager/SplitDialog.rc +++ b/CPP/7zip/UI/FileManager/SplitDialog.rc @@ -4,13 +4,13 @@ #define xc 288 #define yc 96 -IDD_DIALOG_SPLIT MY_RESIZE_DIALOG +IDD_SPLIT DIALOG 0, 0, xs, ys MY_MODAL_RESIZE_DIALOG_STYLE MY_FONT CAPTION "Split File" BEGIN - LTEXT "&Split to:", IDC_STATIC_SPLIT_PATH, m, m, xc, 8 - COMBOBOX IDC_COMBO_SPLIT_PATH, m, 20, xc - bxsDots - m, 64, MY_COMBO_WITH_EDIT - PUSHBUTTON "...", IDC_BUTTON_SPLIT_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP - LTEXT "Split to &volumes, bytes:", IDC_STATIC_SPLIT_VOLUME, m, 44, xc, 8 - COMBOBOX IDC_COMBO_SPLIT_VOLUME, m, 56, 96, 52, MY_COMBO_WITH_EDIT + LTEXT "&Split to:", IDT_SPLIT_PATH, m, m, xc, 8 + COMBOBOX IDC_SPLIT_PATH, m, 20, xc - bxsDots - m, 64, MY_COMBO_WITH_EDIT + PUSHBUTTON "...", IDB_SPLIT_PATH, xs - m - bxsDots, 18, bxsDots, bys, WS_GROUP + LTEXT "Split to &volumes, bytes:", IDT_SPLIT_VOLUME, m, 44, xc, 8 + COMBOBOX IDC_SPLIT_VOLUME, m, 56, 96, 52, MY_COMBO_WITH_EDIT OK_CANCEL END diff --git a/CPP/7zip/UI/FileManager/SplitDialogRes.h b/CPP/7zip/UI/FileManager/SplitDialogRes.h old mode 100755 new mode 100644 index a6f06d1c..50584a14 --- a/CPP/7zip/UI/FileManager/SplitDialogRes.h +++ b/CPP/7zip/UI/FileManager/SplitDialogRes.h @@ -1,7 +1,8 @@ -#define IDD_DIALOG_SPLIT 504 -#define IDC_STATIC_SPLIT_PATH 1000 -#define IDC_COMBO_SPLIT_PATH 1001 -#define IDC_BUTTON_SPLIT_PATH 1002 -#define IDC_STATIC_SPLIT_VOLUME 1010 -#define IDC_COMBO_SPLIT_VOLUME 1011 +#define IDD_SPLIT 7300 +#define IDT_SPLIT_PATH 7301 +#define IDT_SPLIT_VOLUME 7302 + +#define IDC_SPLIT_PATH 100 +#define IDB_SPLIT_PATH 101 +#define IDC_SPLIT_VOLUME 102 diff --git a/CPP/7zip/UI/FileManager/SplitUtils.cpp b/CPP/7zip/UI/FileManager/SplitUtils.cpp old mode 100755 new mode 100644 index 8bae0573..b0172a9f --- a/CPP/7zip/UI/FileManager/SplitUtils.cpp +++ b/CPP/7zip/UI/FileManager/SplitUtils.cpp @@ -2,85 +2,86 @@ #include "StdAfx.h" -#include "Common/StringToInt.h" +#include "../../../Common/StringToInt.h" #include "SplitUtils.h" -#include "StringUtils.h" bool ParseVolumeSizes(const UString &s, CRecordVector &values) { values.Clear(); - UStringVector destStrings; - SplitString(s, destStrings); bool prevIsNumber = false; - for (int i = 0; i < destStrings.Size(); i++) + for (unsigned i = 0; i < s.Len();) { - UString subString = destStrings[i]; - subString.MakeUpper(); - if (subString.IsEmpty()) - return false; - if (subString == L"-") + wchar_t c = s[i++]; + if (c == L' ') + continue; + if (c == L'-') return true; if (prevIsNumber) { - wchar_t c = subString[0]; - UInt64 &value = values.Back(); prevIsNumber = false; - switch(c) + unsigned numBits = 0; + switch (MyCharLower_Ascii(c)) + { + case 'b': continue; + case 'k': numBits = 10; break; + case 'm': numBits = 20; break; + case 'g': numBits = 30; break; + case 't': numBits = 40; break; + } + if (numBits != 0) { - case L'B': - continue; - case L'K': - value <<= 10; - continue; - case L'M': - value <<= 20; - continue; - case L'G': - value <<= 30; - continue; + UInt64 &val = values.Back(); + if (val >= ((UInt64)1 << (64 - numBits))) + return false; + val <<= numBits; + + for (; i < s.Len(); i++) + if (s[i] == L' ') + break; + continue; } } - const wchar_t *start = subString; + i--; + const wchar_t *start = s.Ptr(i); const wchar_t *end; - UInt64 value = ConvertStringToUInt64(start, &end); + UInt64 val = ConvertStringToUInt64(start, &end); if (start == end) return false; - if (value == 0) + if (val == 0) return false; - values.Add(value); + values.Add(val); prevIsNumber = true; - UString rem = subString.Mid((int)(end - start)); - if (!rem.IsEmpty()) - destStrings.Insert(i + 1, rem); + i += (unsigned)(end - start); } return true; } -void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo) +void AddVolumeItems(NWindows::NControl::CComboBox &combo) { - volumeCombo.AddString(TEXT("10M")); - volumeCombo.AddString(TEXT("650M - CD")); - volumeCombo.AddString(TEXT("700M - CD")); - volumeCombo.AddString(TEXT("4480M - DVD")); - volumeCombo.AddString(TEXT("1457664 - 3.5\" floppy")); + combo.AddString(TEXT("10M")); + combo.AddString(TEXT("650M - CD")); + combo.AddString(TEXT("700M - CD")); + combo.AddString(TEXT("4092M - FAT")); + combo.AddString(TEXT("4480M - DVD")); // 4489 MiB limit + combo.AddString(TEXT("8128M - DVD DL")); // 8147 MiB limit + combo.AddString(TEXT("23040M - BD")); // 23866 MiB limit + combo.AddString(TEXT("1457664 - 3.5\" floppy")); } -UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector &volSizes) +UInt64 GetNumberOfVolumes(UInt64 size, const CRecordVector &volSizes) { if (size == 0 || volSizes.Size() == 0) return 1; - UInt64 numVolumes = 0; - for (int i = 0; i < volSizes.Size(); i++) + FOR_VECTOR (i, volSizes) { UInt64 volSize = volSizes[i]; - numVolumes++; if (volSize >= size) - return numVolumes; + return i + 1; size -= volSize; } UInt64 volSize = volSizes.Back(); if (volSize == 0) return (UInt64)(Int64)-1; - return numVolumes + (size - 1) / volSize + 1; + return volSizes.Size() + (size - 1) / volSize + 1; } diff --git a/CPP/7zip/UI/FileManager/SplitUtils.h b/CPP/7zip/UI/FileManager/SplitUtils.h old mode 100755 new mode 100644 index 755c707c..641dfe6b --- a/CPP/7zip/UI/FileManager/SplitUtils.h +++ b/CPP/7zip/UI/FileManager/SplitUtils.h @@ -1,15 +1,15 @@ // SplitUtils.h -#ifndef __SPLITUTILS_H -#define __SPLITUTILS_H +#ifndef __SPLIT_UTILS_H +#define __SPLIT_UTILS_H -#include "Common/MyString.h" -#include "Common/Types.h" -#include "Windows/Control/ComboBox.h" +#include "../../../Common/MyTypes.h" +#include "../../../Common/MyString.h" + +#include "../../../Windows/Control/ComboBox.h" bool ParseVolumeSizes(const UString &s, CRecordVector &values); void AddVolumeItems(NWindows::NControl::CComboBox &volumeCombo); - -UInt64 GetNumberOfVolumes(UInt64 size, CRecordVector &volSizes); +UInt64 GetNumberOfVolumes(UInt64 size, const CRecordVector &volSizes); #endif diff --git a/CPP/7zip/UI/FileManager/StdAfx.cpp b/CPP/7zip/UI/FileManager/StdAfx.cpp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/StdAfx.h b/CPP/7zip/UI/FileManager/StdAfx.h old mode 100755 new mode 100644 index b09de592..85389112 --- a/CPP/7zip/UI/FileManager/StdAfx.h +++ b/CPP/7zip/UI/FileManager/StdAfx.h @@ -3,21 +3,17 @@ #ifndef __STDAFX_H #define __STDAFX_H -#define _WIN32_WINNT 0x0400 +/* we used 0x0400 for Windows NT supporting (MENUITEMINFOW) + But now menu problem is fixed. So it's OK to use 0x0500 (Windows 2000) */ -// it's for Windows NT supporting (MENUITEMINFOW) -#define WINVER 0x0400 +// #define _WIN32_WINNT 0x0400 +#define _WIN32_WINNT 0x0500 +#define WINVER _WIN32_WINNT + +#include "../../../Common/Common.h" -#include -#include #include #include -#include -#include #include -// #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -#include "Common/NewHandler.h" - #endif diff --git a/CPP/7zip/UI/FileManager/StringUtils.cpp b/CPP/7zip/UI/FileManager/StringUtils.cpp old mode 100755 new mode 100644 index bddaa971..fb38a735 --- a/CPP/7zip/UI/FileManager/StringUtils.cpp +++ b/CPP/7zip/UI/FileManager/StringUtils.cpp @@ -9,8 +9,8 @@ void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2) dest1.Empty(); dest2.Empty(); bool quoteMode = false; - int i; - for (i = 0; i < src.Length(); i++) + unsigned i; + for (i = 0; i < src.Len(); i++) { wchar_t c = src[i]; if (c == L'\"') @@ -26,43 +26,42 @@ void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2) else dest1 += c; } - dest2 = src.Mid(i); + dest2 = src.Ptr(i); } void SplitString(const UString &srcString, UStringVector &destStrings) { destStrings.Clear(); - UString string; - int len = srcString.Length(); + unsigned len = srcString.Len(); if (len == 0) return; - for (int i = 0; i < len; i++) + UString s; + for (unsigned i = 0; i < len; i++) { wchar_t c = srcString[i]; if (c == L' ') { - if (!string.IsEmpty()) + if (!s.IsEmpty()) { - destStrings.Add(string); - string.Empty(); + destStrings.Add(s); + s.Empty(); } } else - string += c; + s += c; } - if (!string.IsEmpty()) - destStrings.Add(string); + if (!s.IsEmpty()) + destStrings.Add(s); } UString JoinStrings(const UStringVector &srcStrings) { - UString destString; - for (int i = 0; i < srcStrings.Size(); i++) + UString s; + FOR_VECTOR (i, srcStrings) { if (i != 0) - destString += L' '; - destString += srcStrings[i]; + s += L' '; + s += srcStrings[i]; } - return destString; + return s; } - diff --git a/CPP/7zip/UI/FileManager/StringUtils.h b/CPP/7zip/UI/FileManager/StringUtils.h old mode 100755 new mode 100644 index 7f72b764..fc070de1 --- a/CPP/7zip/UI/FileManager/StringUtils.h +++ b/CPP/7zip/UI/FileManager/StringUtils.h @@ -1,9 +1,9 @@ // StringUtils.h -#ifndef __STRINGUTILS_H -#define __STRINGUTILS_H +#ifndef __STRING_UTILS_H +#define __STRING_UTILS_H -#include "Common/MyString.h" +#include "../../../Common/MyString.h" void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2); diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.cpp b/CPP/7zip/UI/FileManager/SysIconUtils.cpp old mode 100755 new mode 100644 index e537621e..2c35c191 --- a/CPP/7zip/UI/FileManager/SysIconUtils.cpp +++ b/CPP/7zip/UI/FileManager/SysIconUtils.cpp @@ -3,9 +3,11 @@ #include "StdAfx.h" #ifndef _UNICODE -#include "Common/StringConvert.h" +#include "../../../Common/StringConvert.h" #endif +#include "../../../Windows/FileDir.h" + #include "SysIconUtils.h" #ifndef _UNICODE @@ -51,13 +53,13 @@ struct CSHGetFileInfoInit static DWORD_PTR MySHGetFileInfoW(LPCWSTR pszPath, DWORD attrib, SHFILEINFOW *psfi, UINT cbFileInfo, UINT uFlags) { #ifdef _UNICODE - return SHGetFileInfo( + return SHGetFileInfo #else if (g_SHGetFileInfoInit.shGetFileInfoW == 0) return 0; - return g_SHGetFileInfoInit.shGetFileInfoW( + return g_SHGetFileInfoInit.shGetFileInfoW #endif - pszPath, attrib, psfi, cbFileInfo, uFlags); + (pszPath, attrib, psfi, cbFileInfo, uFlags); } DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex) @@ -82,7 +84,8 @@ DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex) } } -DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex, UString &typeName) +/* +DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex, UString *typeName) { #ifndef _UNICODE if (!g_IsNT) @@ -91,7 +94,8 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex shellInfo.szTypeName[0] = 0; DWORD_PTR res = ::SHGetFileInfoA(GetSystemString(fileName), FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); - typeName = GetUnicodeString(shellInfo.szTypeName); + if (typeName) + *typeName = GetUnicodeString(shellInfo.szTypeName); iconIndex = shellInfo.iIcon; return res; } @@ -102,52 +106,148 @@ DWORD_PTR GetRealIconIndex(const UString &fileName, DWORD attrib, int &iconIndex shellInfo.szTypeName[0] = 0; DWORD_PTR res = ::MySHGetFileInfoW(fileName, FILE_ATTRIBUTE_NORMAL | attrib, &shellInfo, sizeof(shellInfo), SHGFI_USEFILEATTRIBUTES | SHGFI_SYSICONINDEX | SHGFI_TYPENAME); - typeName = shellInfo.szTypeName; + if (typeName) + *typeName = shellInfo.szTypeName; iconIndex = shellInfo.iIcon; return res; } } +*/ -int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName, UString &typeName) +static int FindInSorted_Attrib(const CRecordVector &vect, DWORD attrib, int &insertPos) { - int dotPos = fileName.ReverseFind(L'.'); + unsigned left = 0, right = vect.Size(); + while (left != right) + { + unsigned mid = (left + right) / 2; + DWORD midAttrib = vect[mid].Attrib; + if (attrib == midAttrib) + return mid; + if (attrib < midAttrib) + right = mid; + else + left = mid + 1; + } + insertPos = left; + return -1; +} + +static int FindInSorted_Ext(const CObjectVector &vect, const wchar_t *ext, int &insertPos) +{ + unsigned left = 0, right = vect.Size(); + while (left != right) + { + unsigned mid = (left + right) / 2; + int compare = MyStringCompareNoCase(ext, vect[mid].Ext); + if (compare == 0) + return mid; + if (compare < 0) + right = mid; + else + left = mid + 1; + } + insertPos = left; + return -1; +} + +int CExtToIconMap::GetIconIndex(DWORD attrib, const wchar_t *fileName /*, UString *typeName */) +{ + int dotPos = -1; + unsigned i; + for (i = 0;; i++) + { + wchar_t c = fileName[i]; + if (c == 0) + break; + if (c == '.') + dotPos = i; + } + + /* + if (MyStringCompareNoCase(fileName, L"$Recycle.Bin") == 0) + { + char s[256]; + sprintf(s, "SPEC i = %3d, attr = %7x", _attribMap.Size(), attrib); + OutputDebugStringA(s); + OutputDebugStringW(fileName); + } + */ + if ((attrib & FILE_ATTRIBUTE_DIRECTORY) != 0 || dotPos < 0) { - CAttribIconPair pair; - pair.Attrib = attrib; - int index = _attribMap.FindInSorted(pair); + int insertPos = 0; + int index = FindInSorted_Attrib(_attribMap, attrib, insertPos); if (index >= 0) { - typeName = _attribMap[index].TypeName; + // if (typeName) *typeName = _attribMap[index].TypeName; return _attribMap[index].IconIndex; } + CAttribIconPair pair; GetRealIconIndex( #ifdef UNDER_CE - L"\\" + FTEXT("\\") #endif - L"__File__" - , attrib, pair.IconIndex, pair.TypeName); - _attribMap.AddToSorted(pair); - typeName = pair.TypeName; + FTEXT("__DIR__") + , attrib, pair.IconIndex + // , pair.TypeName + ); + + /* + char s[256]; + sprintf(s, "i = %3d, attr = %7x", _attribMap.Size(), attrib); + OutputDebugStringA(s); + */ + + pair.Attrib = attrib; + _attribMap.Insert(insertPos, pair); + // if (typeName) *typeName = pair.TypeName; return pair.IconIndex; } - CExtIconPair pair; - pair.Ext = fileName.Mid(dotPos + 1); - int index = _extMap.FindInSorted(pair); + const wchar_t *ext = fileName + dotPos + 1; + int insertPos = 0; + int index = FindInSorted_Ext(_extMap, ext, insertPos); if (index >= 0) { - typeName = _extMap[index].TypeName; - return _extMap[index].IconIndex; + const CExtIconPair &pa = _extMap[index]; + // if (typeName) *typeName = pa.TypeName; + return pa.IconIndex; + } + + for (i = 0;; i++) + { + wchar_t c = ext[i]; + if (c == 0) + break; + if (c < L'0' || c > L'9') + break; + } + if (i != 0 && ext[i] == 0) + { + // GetRealIconIndex is too slow for big number of split extensions: .001, .002, .003 + if (!SplitIconIndex_Defined) + { + GetRealIconIndex( + #ifdef UNDER_CE + FTEXT("\\") + #endif + FTEXT("__FILE__.001"), 0, SplitIconIndex); + SplitIconIndex_Defined = true; + } + return SplitIconIndex; } - GetRealIconIndex(fileName.Mid(dotPos), attrib, pair.IconIndex, pair.TypeName); - _extMap.AddToSorted(pair); - typeName = pair.TypeName; + + CExtIconPair pair; + pair.Ext = ext; + GetRealIconIndex(us2fs(fileName + dotPos), attrib, pair.IconIndex); + _extMap.Insert(insertPos, pair); + // if (typeName) *typeName = pair.TypeName; return pair.IconIndex; } +/* int CExtToIconMap::GetIconIndex(DWORD attrib, const UString &fileName) { - UString typeName; - return GetIconIndex(attrib, fileName, typeName); + return GetIconIndex(attrib, fileName, NULL); } +*/ \ No newline at end of file diff --git a/CPP/7zip/UI/FileManager/SysIconUtils.h b/CPP/7zip/UI/FileManager/SysIconUtils.h old mode 100755 new mode 100644 index 129de781..20199acb --- a/CPP/7zip/UI/FileManager/SysIconUtils.h +++ b/CPP/7zip/UI/FileManager/SysIconUtils.h @@ -3,40 +3,44 @@ #ifndef __SYS_ICON_UTILS_H #define __SYS_ICON_UTILS_H -#include "Common/MyString.h" +#include "../../../Common/MyString.h" struct CExtIconPair { UString Ext; int IconIndex; - UString TypeName; + // UString TypeName; + + // int Compare(const CExtIconPair &a) const { return MyStringCompareNoCase(Ext, a.Ext); } }; struct CAttribIconPair { DWORD Attrib; int IconIndex; - UString TypeName; -}; + // UString TypeName; -inline bool operator==(const CExtIconPair &a1, const CExtIconPair &a2) { return a1.Ext == a2.Ext; } -inline bool operator< (const CExtIconPair &a1, const CExtIconPair &a2) { return a1.Ext < a2.Ext; } - -inline bool operator==(const CAttribIconPair &a1, const CAttribIconPair &a2) { return a1.Attrib == a2.Attrib; } -inline bool operator< (const CAttribIconPair &a1, const CAttribIconPair &a2) { return a1.Attrib < a2.Attrib; } + // int Compare(const CAttribIconPair &a) const { return Ext.Compare(a.Ext); } +}; class CExtToIconMap { - CObjectVector _extMap; - CObjectVector _attribMap; public: + CRecordVector _attribMap; + CObjectVector _extMap; + int SplitIconIndex; + int SplitIconIndex_Defined; + + CExtToIconMap(): SplitIconIndex_Defined(false) {} + void Clear() { + SplitIconIndex_Defined = false; _extMap.Clear(); _attribMap.Clear(); } - int GetIconIndex(DWORD attrib, const UString &fileName, UString &typeName); - int GetIconIndex(DWORD attrib, const UString &fileName); + int GetIconIndex(DWORD attrib, const wchar_t *fileName /* , UString *typeName */); + // int GetIconIndex(DWORD attrib, const UString &fileName); }; DWORD_PTR GetRealIconIndex(CFSTR path, DWORD attrib, int &iconIndex); diff --git a/CPP/7zip/UI/FileManager/SystemPage.cpp b/CPP/7zip/UI/FileManager/SystemPage.cpp old mode 100755 new mode 100644 index 359656ea..e4ac706d --- a/CPP/7zip/UI/FileManager/SystemPage.cpp +++ b/CPP/7zip/UI/FileManager/SystemPage.cpp @@ -2,10 +2,10 @@ #include "StdAfx.h" -#include "Common/StringConvert.h" +#include "../../../Common/StringConvert.h" -#include "Windows/DLL.h" -#include "Windows/Error.h" +#include "../../../Windows/DLL.h" +#include "../../../Windows/ErrorMsg.h" #include "HelpUtils.h" #include "IFolder.h" @@ -14,10 +14,11 @@ #include "SystemPage.h" #include "SystemPageRes.h" -static const CIDLangPair kIDLangPairs[] = +using namespace NWindows; + +static const UInt32 kLangIDs[] = { - { IDC_SYSTEM_STATIC_ASSOCIATE, 0x03010302} - // { IDC_SYSTEM_SELECT_ALL, 0x03000330} + IDT_SYSTEM_ASSOCIATE }; static LPCWSTR kSystemTopic = L"FM/options.htm#system"; @@ -80,7 +81,7 @@ void CSystemPage::ChangeState(int group, const CIntVector &indices) bool thereAreClearItems = false; int counters[3] = { 0, 0, 0 }; - int i; + unsigned i; for (i = 0; i < indices.Size(); i++) { const CModifiedExtInfo &mi = _items[GetRealIndex(indices[i])].Pair[group]; @@ -125,9 +126,9 @@ void CSystemPage::ChangeState(int group, const CIntVector &indices) bool CSystemPage::OnInit() { - LangSetDlgItemsText((HWND)*this, kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); - _listView.Attach(GetItem(IDC_SYSTEM_LIST_ASSOCIATE)); + _listView.Attach(GetItem(IDL_SYSTEM_ASSOCIATE)); _listView.SetUnicodeFormat(); DWORD newFlags = LVS_EX_FULLROWSELECT; _listView.SetExtendedListViewStyle(newFlags, newFlags); @@ -137,7 +138,7 @@ bool CSystemPage::OnInit() _listView.SetImageList(_imageList, LVSIL_SMALL); - _listView.InsertColumn(0, LangString(IDS_PROP_FILE_TYPE, 0x02000214), 72); + _listView.InsertColumn(0, LangString(IDS_PROP_FILE_TYPE), 72); CSysString s; @@ -172,7 +173,7 @@ bool CSystemPage::OnInit() _extDB.Read(); _items.Clear(); - for (int i = 0; i < _extDB.Exts.Size(); i++) + FOR_VECTOR (i, _extDB.Exts) { const CExtPlugins &extInfo = _extDB.Exts[i]; @@ -215,7 +216,7 @@ bool CSystemPage::OnInit() static UString GetProgramCommand() { - return L"\"" + fs2us(NWindows::NDLL::GetModuleDirPrefix()) + L"7zFM.exe\" \"%1\""; + return L"\"" + fs2us(NDLL::GetModuleDirPrefix()) + L"7zFM.exe\" \"%1\""; } LONG CSystemPage::OnApply() @@ -224,7 +225,7 @@ LONG CSystemPage::OnApply() LONG res = 0; - for (int listIndex = 0; listIndex < _extDB.Exts.Size(); listIndex++) + FOR_VECTOR (listIndex, _extDB.Exts) { int realIndex = GetRealIndex(listIndex); const CExtPlugins &extInfo = _extDB.Exts[realIndex]; @@ -260,7 +261,7 @@ LONG CSystemPage::OnApply() WasChanged = true; #endif if (res != 0) - MessageBoxW(*this, NWindows::NError::MyFormatMessageW(res), L"7-Zip", MB_ICONERROR); + MessageBoxW(*this, NError::MyFormatMessage(res), L"7-Zip", MB_ICONERROR); return PSNRET_NOERROR; } @@ -278,9 +279,9 @@ bool CSystemPage::OnButtonClicked(int buttonID, HWND buttonHWND) _listView.SelectAll(); return true; */ - case IDC_SYSTEM_BUTTON_CURRENT: - case IDC_SYSTEM_BUTTON_ALL: - ChangeState(buttonID == IDC_SYSTEM_BUTTON_CURRENT ? 0 : 1); + case IDB_SYSTEM_CURRENT: + case IDB_SYSTEM_ALL: + ChangeState(buttonID == IDB_SYSTEM_CURRENT ? 0 : 1); return true; } return CPropertyPage::OnButtonClicked(buttonID, buttonHWND); @@ -346,15 +347,15 @@ void CSystemPage::ChangeState(int group) while ((itemIndex = _listView.GetNextSelectedItem(itemIndex)) != -1) indices.Add(itemIndex); if (indices.IsEmpty()) - for (int i = 0; i < _items.Size(); i++) + FOR_VECTOR (i, _items) indices.Add(i); ChangeState(group, indices); } bool CSystemPage::OnListKeyDown(LPNMLVKEYDOWN keyDownInfo) { - bool ctrl = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - bool alt = (::GetKeyState(VK_MENU) & 0x8000) != 0; + bool ctrl = IsKeyDown(VK_CONTROL); + bool alt = IsKeyDown(VK_MENU); if (alt) return false; diff --git a/CPP/7zip/UI/FileManager/SystemPage.h b/CPP/7zip/UI/FileManager/SystemPage.h old mode 100755 new mode 100644 index a4b4ab92..0bf6aae7 --- a/CPP/7zip/UI/FileManager/SystemPage.h +++ b/CPP/7zip/UI/FileManager/SystemPage.h @@ -3,9 +3,9 @@ #ifndef __SYSTEM_PAGE_H #define __SYSTEM_PAGE_H -#include "Windows/Control/ImageList.h" -#include "Windows/Control/ListView.h" -#include "Windows/Control/PropertyPage.h" +#include "../../../Windows/Control/ImageList.h" +#include "../../../Windows/Control/ListView.h" +#include "../../../Windows/Control/PropertyPage.h" #include "FilePlugins.h" #include "RegistryAssociations.h" @@ -40,7 +40,7 @@ struct CModifiedExtInfo: public NRegistryAssoc::CShellExtInfo Other = true; if (IsIt7Zip()) { - Other7Zip = (iconPath.CompareNoCase(IconPath) != 0); + Other7Zip = !iconPath.IsEqualToNoCase(IconPath); if (!Other7Zip) { State = kExtState_7Zip; @@ -88,7 +88,11 @@ class CSystemPage: public NWindows::NControl::CPropertyPage NWindows::NControl::CImageList _imageList; NWindows::NControl::CListView _listView; - const HKEY GetHKey(int group) const + const HKEY GetHKey(int + #if NUM_EXT_GROUPS != 1 + group + #endif + ) const { #if NUM_EXT_GROUPS == 1 return HKEY_CLASSES_ROOT; diff --git a/CPP/7zip/UI/FileManager/SystemPage.rc b/CPP/7zip/UI/FileManager/SystemPage.rc old mode 100755 new mode 100644 index 49581c9b..42e72cf1 --- a/CPP/7zip/UI/FileManager/SystemPage.rc +++ b/CPP/7zip/UI/FileManager/SystemPage.rc @@ -4,16 +4,15 @@ #define xc 200 #define yc 250 -IDD_SYSTEM MY_PAGE +IDD_SYSTEM DIALOG 0, 0, xs, ys MY_PAGE_STYLE MY_FONT CAPTION "System" BEGIN - LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8 - PUSHBUTTON "+", IDC_SYSTEM_BUTTON_CURRENT, 72, m + 12, 40, bys - PUSHBUTTON "+", IDC_SYSTEM_BUTTON_ALL, 140, m + 12, 40, bys - CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", - LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, - m, m + 32, xc, (yc - m - 32 - 1) -; PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, m + 12, 60, bys + LTEXT "Associate 7-Zip with:", IDT_SYSTEM_ASSOCIATE, m, m, xc, 8 + PUSHBUTTON "+", IDB_SYSTEM_CURRENT, 72, m + 12, 40, bys + PUSHBUTTON "+", IDB_SYSTEM_ALL, 140, m + 12, 40, bys + CONTROL "List1", IDL_SYSTEM_ASSOCIATE, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + m, m + 32, xc, (yc - m - 32 - 1) END #ifdef UNDER_CE @@ -26,21 +25,14 @@ END #define xc (SMALL_PAGE_SIZE_X + 8) #define yc (128 + 8) -IDD_SYSTEM_2 MY_PAGE +IDD_SYSTEM_2 DIALOG 0, 0, xs, ys MY_PAGE_STYLE MY_FONT CAPTION "System" BEGIN - LTEXT "Associate 7-Zip with:", IDC_SYSTEM_STATIC_ASSOCIATE, m, m, xc, 8 - PUSHBUTTON "+", IDC_SYSTEM_BUTTON_CURRENT, 60, m + 12, 40, bys - CONTROL "List1", IDC_SYSTEM_LIST_ASSOCIATE, "SysListView32", - LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, - m, m + 32, xc, (yc - m - 32 - 1 - 8) -; PUSHBUTTON "Select all", IDC_SYSTEM_SELECT_ALL, m, m + 12, 60, bys + LTEXT "Associate 7-Zip with:", IDT_SYSTEM_ASSOCIATE, m, m, xc, 8 + PUSHBUTTON "+", IDB_SYSTEM_CURRENT, 60, m + 12, 40, bys + CONTROL "List1", IDL_SYSTEM_ASSOCIATE, "SysListView32", + LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SHAREIMAGELISTS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP, + m, m + 32, xc, (yc - m - 32 - 1 - 8) END #endif - - -STRINGTABLE -BEGIN - IDS_PLUGIN "Plugin" -END diff --git a/CPP/7zip/UI/FileManager/SystemPageRes.h b/CPP/7zip/UI/FileManager/SystemPageRes.h old mode 100755 new mode 100644 index 133996e7..edc576f7 --- a/CPP/7zip/UI/FileManager/SystemPageRes.h +++ b/CPP/7zip/UI/FileManager/SystemPageRes.h @@ -1,10 +1,8 @@ -#define IDD_SYSTEM 540 -#define IDD_SYSTEM_2 640 -#define IDS_PLUGIN 990 -// #define IDC_SYSTEM_INTEGRATE_TO_CONTEXT_MENU 1010 -#define IDC_SYSTEM_STATIC_ASSOCIATE 1020 -#define IDC_SYSTEM_LIST_ASSOCIATE 1021 -// #define IDC_SYSTEM_LIST_PLUGINS 1022 -// #define IDC_SYSTEM_SELECT_ALL 1023 -#define IDC_SYSTEM_BUTTON_CURRENT 1024 -#define IDC_SYSTEM_BUTTON_ALL 1025 +#define IDD_SYSTEM 2200 +#define IDD_SYSTEM_2 12200 + +#define IDT_SYSTEM_ASSOCIATE 2201 + +#define IDL_SYSTEM_ASSOCIATE 100 +#define IDB_SYSTEM_CURRENT 101 +#define IDB_SYSTEM_ALL 102 diff --git a/CPP/7zip/UI/FileManager/Test.bmp b/CPP/7zip/UI/FileManager/Test.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/Test2.bmp b/CPP/7zip/UI/FileManager/Test2.bmp old mode 100755 new mode 100644 diff --git a/CPP/7zip/UI/FileManager/TextPairs.cpp b/CPP/7zip/UI/FileManager/TextPairs.cpp old mode 100755 new mode 100644 index cc57c0d5..354b479f --- a/CPP/7zip/UI/FileManager/TextPairs.cpp +++ b/CPP/7zip/UI/FileManager/TextPairs.cpp @@ -16,10 +16,10 @@ static bool IsSeparatorChar(wchar_t c) static void RemoveCr(UString &s) { - s.Replace(L"\x0D", L""); + s.RemoveChar(L'\x0D'); } -static UString GetIDString(const wchar_t *srcString, int &finishPos) +static UString GetIDString(const wchar_t *srcString, unsigned &finishPos) { UString result; bool quotes = false; @@ -43,7 +43,7 @@ static UString GetIDString(const wchar_t *srcString, int &finishPos) return result; } -static UString GetValueString(const wchar_t *srcString, int &finishPos) +static UString GetValueString(const wchar_t *srcString, unsigned &finishPos) { UString result; for (finishPos = 0;;) @@ -64,16 +64,16 @@ static UString GetValueString(const wchar_t *srcString, int &finishPos) static bool GetTextPairs(const UString &srcString, CObjectVector &pairs) { pairs.Clear(); - int pos = 0; + unsigned pos = 0; - if (srcString.Length() > 0) + if (srcString.Len() > 0) { if (srcString[0] == kBOM) pos++; } - while (pos < srcString.Length()) + while (pos < srcString.Len()) { - int finishPos; + unsigned finishPos; UString id = GetIDString((const wchar_t *)srcString + pos, finishPos); pos += finishPos; if (id.IsEmpty()) @@ -92,7 +92,8 @@ static bool GetTextPairs(const UString &srcString, CObjectVector &pai } static int ComparePairIDs(const UString &s1, const UString &s2) - { return s1.CompareNoCase(s2); } + { return MyStringCompareNoCase(s1, s2); } + static int ComparePairItems(const CTextPair &p1, const CTextPair &p2) { return ComparePairIDs(p1.ID, p2.ID); } @@ -101,7 +102,7 @@ static int ComparePairItems(void *const *a1, void *const *a2, void * /* param */ void CPairsStorage::Sort() { Pairs.Sort(ComparePairItems, 0); } -int CPairsStorage::FindID(const UString &id, int &insertPos) +int CPairsStorage::FindID(const UString &id, int &insertPos) const { int left = 0, right = Pairs.Size(); while (left != right) @@ -119,7 +120,7 @@ int CPairsStorage::FindID(const UString &id, int &insertPos) return -1; } -int CPairsStorage::FindID(const UString &id) +int CPairsStorage::FindID(const UString &id) const { int pos; return FindID(id, pos); @@ -142,7 +143,7 @@ void CPairsStorage::DeletePair(const UString &id) Pairs.Delete(pos); } -bool CPairsStorage::GetValue(const UString &id, UString &value) +bool CPairsStorage::GetValue(const UString &id, UString &value) const { value.Empty(); int pos = FindID(id); @@ -152,7 +153,7 @@ bool CPairsStorage::GetValue(const UString &id, UString &value) return true; } -UString CPairsStorage::GetValue(const UString &id) +UString CPairsStorage::GetValue(const UString &id) const { int pos = FindID(id); if (pos < 0) @@ -170,9 +171,9 @@ bool CPairsStorage::ReadFromString(const UString &text) return result; } -void CPairsStorage::SaveToString(UString &text) +void CPairsStorage::SaveToString(UString &text) const { - for (int i = 0; i < Pairs.Size(); i++) + FOR_VECTOR (i, Pairs) { const CTextPair &pair = Pairs[i]; bool multiWord = (pair.ID.Find(L' ') >= 0); diff --git a/CPP/7zip/UI/FileManager/TextPairs.h b/CPP/7zip/UI/FileManager/TextPairs.h old mode 100755 new mode 100644 index 2670e030..d27cd97c --- a/CPP/7zip/UI/FileManager/TextPairs.h +++ b/CPP/7zip/UI/FileManager/TextPairs.h @@ -3,7 +3,7 @@ #ifndef __FM_TEXT_PAIRS_H #define __FM_TEXT_PAIRS_H -#include "Common/MyString.h" +#include "../../../Common/MyString.h" struct CTextPair { @@ -14,16 +14,17 @@ struct CTextPair class CPairsStorage { CObjectVector Pairs; - int FindID(const UString &id, int &insertPos); - int FindID(const UString &id); + + int FindID(const UString &id, int &insertPos) const; + int FindID(const UString &id) const; void Sort(); public: void Clear() { Pairs.Clear(); }; bool ReadFromString(const UString &text); - void SaveToString(UString &text); + void SaveToString(UString &text) const; - bool GetValue(const UString &id, UString &value); - UString GetValue(const UString &id); + bool GetValue(const UString &id, UString &value) const; + UString GetValue(const UString &id) const; void AddPair(const CTextPair &pair); void DeletePair(const UString &id); }; diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp old mode 100755 new mode 100644 index 43dfa4dc..4141f01d --- a/CPP/7zip/UI/FileManager/UpdateCallback100.cpp +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.cpp @@ -7,51 +7,48 @@ STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles) { - ProgressDialog->Sync.SetNumFilesTotal(numFiles); + ProgressDialog->Sync.Set_NumFilesTotal(numFiles); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size) { - ProgressDialog->Sync.SetProgress(size, 0); + ProgressDialog->Sync.Set_NumBytesTotal(size); return S_OK; } -STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completeValue) +STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 *completed) { - RINOK(ProgressDialog->Sync.ProcessStopAndPause()); - if (completeValue != NULL) - ProgressDialog->Sync.SetPos(*completeValue); - return S_OK; + return ProgressDialog->Sync.Set_NumBytesCur(completed); } STDMETHODIMP CUpdateCallback100Imp::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) { - ProgressDialog->Sync.SetRatioInfo(inSize, outSize); + ProgressDialog->Sync.Set_Ratio(inSize, outSize); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::CompressOperation(const wchar_t *name) { - ProgressDialog->Sync.SetCurrentFileName(name); + ProgressDialog->Sync.Set_FilePath(name); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::DeleteOperation(const wchar_t *name) { - ProgressDialog->Sync.SetCurrentFileName(name); + ProgressDialog->Sync.Set_FilePath(name); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::OperationResult(Int32 /* operationResult */) { - ProgressDialog->Sync.SetNumFilesCur(++_numFiles); + ProgressDialog->Sync.Set_NumFilesCur(++_numFiles); return S_OK; } STDMETHODIMP CUpdateCallback100Imp::UpdateErrorMessage(const wchar_t *message) { - ProgressDialog->Sync.AddErrorMessage(message); + ProgressDialog->Sync.AddError_Message(message); return S_OK; } @@ -71,7 +68,7 @@ STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const U STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) { - return ProgressDialog->Sync.ProcessStopAndPause(); + return ProgressDialog->Sync.CheckStop(); } STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) @@ -81,7 +78,7 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) { CPasswordDialog dialog; ProgressDialog->WaitCreating(); - if (dialog.Create(*ProgressDialog) == IDCANCEL) + if (dialog.Create(*ProgressDialog) != IDOK) return E_ABORT; _password = dialog.Password; _passwordIsDefined = true; diff --git a/CPP/7zip/UI/FileManager/UpdateCallback100.h b/CPP/7zip/UI/FileManager/UpdateCallback100.h old mode 100755 new mode 100644 index aa13320f..944453a1 --- a/CPP/7zip/UI/FileManager/UpdateCallback100.h +++ b/CPP/7zip/UI/FileManager/UpdateCallback100.h @@ -3,7 +3,7 @@ #ifndef __UPDATE_CALLBACK100_H #define __UPDATE_CALLBACK100_H -#include "Common/MyCom.h" +#include "../../../Common/MyCom.h" #include "../../IPassword.h" diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp old mode 100755 new mode 100644 index f11f68d6..9688a4a5 --- a/CPP/7zip/UI/FileManager/ViewSettings.cpp +++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp @@ -1,13 +1,16 @@ -// ViewSettings.h +// ViewSettings.cpp #include "StdAfx.h" + +#include "../../../../C/CpuArch.h" -#include "Common/IntToString.h" -#include "Common/StringConvert.h" +#include "../../../Common/IntToString.h" +#include "../../../Common/StringConvert.h" + +#include "../../../Windows/Registry.h" +#include "../../../Windows/Synchronization.h" #include "ViewSettings.h" -#include "Windows/Registry.h" -#include "Windows/Synchronization.h" using namespace NWindows; using namespace NRegistry; @@ -27,163 +30,95 @@ static const TCHAR *kFolderHistoryValueName = TEXT("FolderHistory"); static const TCHAR *kFastFoldersValueName = TEXT("FolderShortcuts"); static const TCHAR *kCopyHistoryValueName = TEXT("CopyHistory"); -/* -class CColumnInfoSpec -{ - UInt32 PropID; - Byte IsVisible; - UInt32 Width; -}; +static NSynchronization::CCriticalSection g_CS; + +#define Set32(p, v) SetUi32(((Byte *)p), v) +#define SetBool(p, v) Set32(p, ((v) ? 1 : 0)) +#define Get32(p, dest) dest = GetUi32((const Byte *)p) +#define GetBool(p, dest) dest = (GetUi32(p) != 0); + +/* struct CColumnHeader { UInt32 Version; UInt32 SortID; - Byte Ascending; + UInt32 Ascending; // bool }; */ -static const UInt32 kColumnInfoSpecHeader = 12; -static const UInt32 kColumnHeaderSize = 12; - -static const UInt32 kColumnInfoVersion = 1; - -static NSynchronization::CCriticalSection g_CS; - -class CTempOutBufferSpec -{ - CByteBuffer Buffer; - UInt32 Size; - UInt32 Pos; -public: - operator const Byte *() const { return (const Byte *)Buffer; } - void Init(UInt32 dataSize) - { - Buffer.SetCapacity(dataSize); - Size = dataSize; - Pos = 0; - } - void WriteByte(Byte value) - { - if (Pos >= Size) - throw "overflow"; - ((Byte *)Buffer)[Pos++] = value; - } - void WriteUInt32(UInt32 value) - { - for (int i = 0; i < 4; i++) - { - WriteByte((Byte)value); - value >>= 8; - } - } - void WriteBool(bool value) - { - WriteUInt32(value ? 1 : 0); - } -}; +static const UInt32 kListViewHeaderSize = 3 * 4; +static const UInt32 kColumnInfoSize = 3 * 4; +static const UInt32 kListViewVersion = 1; -class CTempInBufferSpec +void CListViewInfo::Save(const UString &id) const { -public: - Byte *Buffer; - UInt32 Size; - UInt32 Pos; - Byte ReadByte() - { - if (Pos >= Size) - throw "overflow"; - return Buffer[Pos++]; - } - UInt32 ReadUInt32() - { - UInt32 value = 0; - for (int i = 0; i < 4; i++) - value |= (((UInt32)ReadByte()) << (8 * i)); - return value; - } - bool ReadBool() - { - return (ReadUInt32() != 0); - } -}; + const UInt32 dataSize = kListViewHeaderSize + kColumnInfoSize * Columns.Size(); + CByteArr buf(dataSize); -void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo) -{ - const CObjectVector &columns = viewInfo.Columns; - CTempOutBufferSpec buffer; - UInt32 dataSize = kColumnHeaderSize + kColumnInfoSpecHeader * columns.Size(); - buffer.Init(dataSize); - - buffer.WriteUInt32(kColumnInfoVersion); - buffer.WriteUInt32(viewInfo.SortID); - buffer.WriteBool(viewInfo.Ascending); - for(int i = 0; i < columns.Size(); i++) + Set32(buf, kListViewVersion); + Set32(buf + 4, SortID); + SetBool(buf + 8, Ascending); + FOR_VECTOR (i, Columns) { - const CColumnInfo &column = columns[i]; - buffer.WriteUInt32(column.PropID); - buffer.WriteBool(column.IsVisible); - buffer.WriteUInt32(column.Width); + const CColumnInfo &column = Columns[i]; + Byte *p = buf + kListViewHeaderSize + i * kColumnInfoSize; + Set32(p, column.PropID); + SetBool(p + 4, column.IsVisible); + Set32(p + 8, column.Width); } { NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; key.Create(HKEY_CURRENT_USER, kCulumnsKeyName); - key.SetValue(GetSystemString(id), (const Byte *)buffer, dataSize); + key.SetValue(GetSystemString(id), (const Byte *)buf, dataSize); } } -void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo) +void CListViewInfo::Read(const UString &id) { - viewInfo.Clear(); - CObjectVector &columns = viewInfo.Columns; - CByteBuffer buffer; + Clear(); + CByteBuffer buf; UInt32 size; { NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; if (key.Open(HKEY_CURRENT_USER, kCulumnsKeyName, KEY_READ) != ERROR_SUCCESS) return; - if (key.QueryValue(GetSystemString(id), buffer, size) != ERROR_SUCCESS) + if (key.QueryValue(GetSystemString(id), buf, size) != ERROR_SUCCESS) return; } - if (size < kColumnHeaderSize) + if (size < kListViewHeaderSize) return; - CTempInBufferSpec inBuffer; - inBuffer.Size = size; - inBuffer.Buffer = (Byte *)buffer; - inBuffer.Pos = 0; - - - UInt32 version = inBuffer.ReadUInt32(); - if (version != kColumnInfoVersion) + UInt32 version; + Get32(buf, version); + if (version != kListViewVersion) return; - viewInfo.SortID = inBuffer.ReadUInt32(); - viewInfo.Ascending = inBuffer.ReadBool(); + Get32(buf + 4, SortID); + GetBool(buf + 8, Ascending); - size -= kColumnHeaderSize; - if (size % kColumnInfoSpecHeader != 0) + size -= kListViewHeaderSize; + if (size % kColumnInfoSize != 0) return; - int numItems = size / kColumnInfoSpecHeader; - columns.Reserve(numItems); - for(int i = 0; i < numItems; i++) + unsigned numItems = size / kColumnInfoSize; + Columns.ClearAndReserve(numItems); + for (unsigned i = 0; i < numItems; i++) { - CColumnInfo columnInfo; - columnInfo.PropID = inBuffer.ReadUInt32(); - columnInfo.IsVisible = inBuffer.ReadBool(); - columnInfo.Width = inBuffer.ReadUInt32(); - columns.Add(columnInfo); + CColumnInfo column; + const Byte *p = buf + kListViewHeaderSize + i * kColumnInfoSize; + Get32(p, column.PropID); + GetBool(p + 4, column.IsVisible); + Get32(p + 8, column.Width); + Columns.AddInReserved(column); } } -static const UInt32 kWindowPositionHeaderSize = 5 * 4; -static const UInt32 kPanelsInfoHeaderSize = 3 * 4; /* struct CWindowPosition { RECT Rect; - UInt32 Maximized; + UInt32 Maximized; // bool }; struct CPanelsInfo @@ -194,114 +129,125 @@ struct CPanelsInfo }; */ -void SaveWindowSize(const RECT &rect, bool maximized) +static const UInt32 kWindowPositionHeaderSize = 5 * 4; +static const UInt32 kPanelsInfoHeaderSize = 3 * 4; + +void CWindowInfo::Save() const { - CSysString keyName = kCUBasePath; NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - key.Create(HKEY_CURRENT_USER, keyName); - // CWindowPosition position; - CTempOutBufferSpec buffer; - buffer.Init(kWindowPositionHeaderSize); - buffer.WriteUInt32(rect.left); - buffer.WriteUInt32(rect.top); - buffer.WriteUInt32(rect.right); - buffer.WriteUInt32(rect.bottom); - buffer.WriteBool(maximized); - key.SetValue(kPositionValueName, (const Byte *)buffer, kWindowPositionHeaderSize); + key.Create(HKEY_CURRENT_USER, kCUBasePath); + { + Byte buf[kWindowPositionHeaderSize]; + Set32(buf, rect.left); + Set32(buf + 4, rect.top); + Set32(buf + 8, rect.right); + Set32(buf + 12, rect.bottom); + SetBool(buf + 16, maximized); + key.SetValue(kPositionValueName, buf, kWindowPositionHeaderSize); + } + { + Byte buf[kPanelsInfoHeaderSize]; + Set32(buf, numPanels); + Set32(buf + 4, currentPanel); + Set32(buf + 8, splitterPos); + key.SetValue(kPanelsInfoValueName, buf, kPanelsInfoHeaderSize); + } } -bool ReadWindowSize(RECT &rect, bool &maximized) +static bool QueryBuf(CKey &key, LPCTSTR name, CByteBuffer &buf, UInt32 dataSize) { - CSysString keyName = kCUBasePath; - NSynchronization::CCriticalSectionLock lock(g_CS); - CKey key; - if (key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) - return false; - CByteBuffer buffer; UInt32 size; - if (key.QueryValue(kPositionValueName, buffer, size) != ERROR_SUCCESS) - return false; - if (size != kWindowPositionHeaderSize) - return false; - CTempInBufferSpec inBuffer; - inBuffer.Size = size; - inBuffer.Buffer = (Byte *)buffer; - inBuffer.Pos = 0; - rect.left = inBuffer.ReadUInt32(); - rect.top = inBuffer.ReadUInt32(); - rect.right = inBuffer.ReadUInt32(); - rect.bottom = inBuffer.ReadUInt32(); - maximized = inBuffer.ReadBool(); - return true; + return key.QueryValue(name, buf, size) == ERROR_SUCCESS && size == dataSize; } -void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos) +void CWindowInfo::Read(bool &windowPosDefined, bool &panelInfoDefined) { - CSysString keyName = kCUBasePath; + windowPosDefined = false; + panelInfoDefined = false; NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - key.Create(HKEY_CURRENT_USER, keyName); - - CTempOutBufferSpec buffer; - buffer.Init(kPanelsInfoHeaderSize); - buffer.WriteUInt32(numPanels); - buffer.WriteUInt32(currentPanel); - buffer.WriteUInt32(splitterPos); - key.SetValue(kPanelsInfoValueName, (const Byte *)buffer, kPanelsInfoHeaderSize); + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) + return; + CByteBuffer buf; + if (QueryBuf(key, kPositionValueName, buf, kWindowPositionHeaderSize)) + { + Get32(buf, rect.left); + Get32(buf + 4, rect.top); + Get32(buf + 8, rect.right); + Get32(buf + 12, rect.bottom); + GetBool(buf + 16, maximized); + windowPosDefined = true; + } + if (QueryBuf(key, kPanelsInfoValueName, buf, kPanelsInfoHeaderSize)) + { + Get32(buf, numPanels); + Get32(buf + 4, currentPanel); + Get32(buf + 8, splitterPos); + panelInfoDefined = true; + } + return; +} + + +void SaveUi32Val(const TCHAR *name, UInt32 value) +{ + CKey key; + key.Create(HKEY_CURRENT_USER, kCUBasePath); + key.SetValue(name, value); } -bool ReadPanelsInfo(UInt32 &numPanels, UInt32 ¤tPanel, UInt32 &splitterPos) +bool ReadUi32Val(const TCHAR *name, UInt32 &value) { - CSysString keyName = kCUBasePath; - NSynchronization::CCriticalSectionLock lock(g_CS); CKey key; - if (key.Open(HKEY_CURRENT_USER, keyName, KEY_READ) != ERROR_SUCCESS) - return false; - CByteBuffer buffer; - UInt32 size; - if (key.QueryValue(kPanelsInfoValueName, buffer, size) != ERROR_SUCCESS) - return false; - if (size != kPanelsInfoHeaderSize) + if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) return false; - CTempInBufferSpec inBuffer; - inBuffer.Size = size; - inBuffer.Buffer = (Byte *)buffer; - inBuffer.Pos = 0; - numPanels = inBuffer.ReadUInt32(); - currentPanel = inBuffer.ReadUInt32(); - splitterPos = inBuffer.ReadUInt32(); - return true; + return key.QueryValue(name, value) == ERROR_SUCCESS; } void SaveToolbarsMask(UInt32 toolbarMask) { - CKey key; - key.Create(HKEY_CURRENT_USER, kCUBasePath); - key.SetValue(kToolbars, toolbarMask); + SaveUi32Val(kToolbars, toolbarMask); } static const UInt32 kDefaultToolbarMask = ((UInt32)1 << 31) | 8 | 4 | 1; UInt32 ReadToolbarsMask() { - CKey key; - if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) - return kDefaultToolbarMask; UInt32 mask; - if (key.QueryValue(kToolbars, mask) != ERROR_SUCCESS) + if (!ReadUi32Val(kToolbars, mask)) return kDefaultToolbarMask; return mask; } -static UString GetPanelPathName(UInt32 panelIndex) +void CListMode::Save() const { - WCHAR panelString[16]; - ConvertUInt32ToString(panelIndex, panelString); - return UString(kPanelPathValueName) + panelString; + UInt32 t = 0; + for (int i = 0; i < 2; i++) + t |= ((Panels[i]) & 0xFF) << (i * 8); + SaveUi32Val(kListMode, t); +} + +void CListMode::Read() +{ + Init(); + UInt32 t; + if (!ReadUi32Val(kListMode, t)) + return; + for (int i = 0; i < 2; i++) + { + Panels[i] = (t & 0xFF); + t >>= 8; + } } +static UString GetPanelPathName(UInt32 panelIndex) +{ + WCHAR s[16]; + ConvertUInt32ToString(panelIndex, s); + return (UString)kPanelPathValueName + s; +} void SavePanelPath(UInt32 panel, const UString &path) { @@ -320,32 +266,6 @@ bool ReadPanelPath(UInt32 panel, UString &path) return (key.QueryValue(GetPanelPathName(panel), path) == ERROR_SUCCESS); } -void SaveListMode(const CListMode &listMode) -{ - CKey key; - key.Create(HKEY_CURRENT_USER, kCUBasePath); - UInt32 t = 0; - for (int i = 0; i < 2; i++) - t |= ((listMode.Panels[i]) & 0xFF) << (i * 8); - key.SetValue(kListMode, t); -} - -void ReadListMode(CListMode &listMode) -{ - CKey key; - listMode.Init(); - if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) - return; - UInt32 t; - if (key.QueryValue(kListMode, t) != ERROR_SUCCESS) - return; - for (int i = 0; i < 2; i++) - { - listMode.Panels[i] = (t & 0xFF); - t >>= 8; - } -} - static void SaveStringList(LPCTSTR valueName, const UStringVector &folders) { @@ -381,8 +301,8 @@ void ReadCopyHistory(UStringVector &folders) void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s) { - for (int i = 0; i < list.Size();) - if (s.CompareNoCase(list[i]) == 0) + for (unsigned i = 0; i < list.Size();) + if (s.IsEqualToNoCase(list[i])) list.Delete(i); else i++; diff --git a/CPP/7zip/UI/FileManager/ViewSettings.h b/CPP/7zip/UI/FileManager/ViewSettings.h old mode 100755 new mode 100644 index b0510813..dbb98dc6 --- a/CPP/7zip/UI/FileManager/ViewSettings.h +++ b/CPP/7zip/UI/FileManager/ViewSettings.h @@ -3,30 +3,24 @@ #ifndef __VIEW_SETTINGS_H #define __VIEW_SETTINGS_H -#include "Common/MyString.h" -#include "Common/Types.h" +#include "../../../Common/MyTypes.h" +#include "../../../Common/MyString.h" struct CColumnInfo { PROPID PropID; bool IsVisible; UInt32 Width; -}; - -inline bool operator==(const CColumnInfo &a1, const CColumnInfo &a2) -{ - return (a1.PropID == a2.PropID) && - (a1.IsVisible == a2.IsVisible) && (a1.Width == a2.Width); -} -inline bool operator!=(const CColumnInfo &a1, const CColumnInfo &a2) -{ - return !(a1 == a2); -} + bool IsEqual(const CColumnInfo &a) const + { + return PropID == a.PropID && IsVisible == a.IsVisible && Width == a.Width; + } +}; struct CListViewInfo { - CObjectVector Columns; + CRecordVector Columns; PROPID SortID; bool Ascending; @@ -37,52 +31,67 @@ struct CListViewInfo Columns.Clear(); } + /* int FindColumnWithID(PROPID propID) const { - for (int i = 0; i < Columns.Size(); i++) + FOR_VECTOR (i, Columns) if (Columns[i].PropID == propID) return i; return -1; } + */ bool IsEqual(const CListViewInfo &info) const { if (Columns.Size() != info.Columns.Size() || - // SortIndex != info.SortIndex || SortID != info.SortID || Ascending != info.Ascending) return false; - for (int i = 0; i < Columns.Size(); i++) - if (Columns[i] != info.Columns[i]) + FOR_VECTOR (i, Columns) + if (!Columns[i].IsEqual(info.Columns[i])) return false; return true; } + + void Save(const UString &id) const; + void Read(const UString &id); }; -void SaveListViewInfo(const UString &id, const CListViewInfo &viewInfo); -void ReadListViewInfo(const UString &id, CListViewInfo &viewInfo); -void SaveWindowSize(const RECT &rect, bool maximized); -bool ReadWindowSize(RECT &rect, bool &maximized); +struct CWindowInfo +{ + RECT rect; + bool maximized; + + UInt32 numPanels; + UInt32 currentPanel; + UInt32 splitterPos; -void SavePanelsInfo(UInt32 numPanels, UInt32 currentPanel, UInt32 splitterPos); -bool ReadPanelsInfo(UInt32 &numPanels, UInt32 ¤tPanel, UInt32 &splitterPos); + void Save() const; + void Read(bool &windowPosDefined, bool &panelInfoDefined); +}; void SaveToolbarsMask(UInt32 toolbarMask); UInt32 ReadToolbarsMask(); -void SavePanelPath(UInt32 panel, const UString &path); -bool ReadPanelPath(UInt32 panel, UString &path); +const UInt32 kListMode_Report = 3; struct CListMode { UInt32 Panels[2]; - void Init() { Panels[0] = Panels[1] = 3; } + + void Init() { Panels[0] = Panels[1] = kListMode_Report; } CListMode() { Init(); } + + void Save() const ; + void Read(); }; -void SaveListMode(const CListMode &listMode); -void ReadListMode(CListMode &listMode); + + +void SavePanelPath(UInt32 panel, const UString &path); +bool ReadPanelPath(UInt32 panel, UString &path); + void SaveFolderHistory(const UStringVector &folders); void ReadFolderHistory(UStringVector &folders); diff --git a/CPP/7zip/UI/FileManager/makefile b/CPP/7zip/UI/FileManager/makefile old mode 100755 new mode 100644 index eeca66f9..96ae902f --- a/CPP/7zip/UI/FileManager/makefile +++ b/CPP/7zip/UI/FileManager/makefile @@ -1,5 +1,5 @@ PROG = 7zFM.exe -CFLAGS = $(CFLAGS) -I ../../../ \ +CFLAGS = $(CFLAGS) \ -DLANG \ -DNEW_FOLDER_INTERFACE \ -DEXTERNAL_CODECS \ @@ -11,67 +11,9 @@ LIBS = $(LIBS) comctl32.lib htmlhelp.lib comdlg32.lib Mpr.lib Gdi32.lib CFLAGS = $(CFLAGS) -DWIN_LONG_PATH -DSUPPORT_DEVICE_FILE !ENDIF -FM_OBJS = \ - $O\App.obj \ - $O\BrowseDialog.obj \ - $O\ClassDefs.obj \ - $O\EnumFormatEtc.obj \ - $O\ExtractCallback.obj \ - $O\FileFolderPluginOpen.obj \ - $O\FilePlugins.obj \ - $O\FM.obj \ - $O\FoldersPage.obj \ - $O\FormatUtils.obj \ - $O\FSFolder.obj \ - $O\FSFolderCopy.obj \ - $O\HelpUtils.obj \ - $O\LangUtils.obj \ - $O\MenuPage.obj \ - $O\MyLoadMenu.obj \ - $O\OpenCallback.obj \ - $O\OptionsDialog.obj \ - $O\Panel.obj \ - $O\PanelCopy.obj \ - $O\PanelCrc.obj \ - $O\PanelDrag.obj \ - $O\PanelFolderChange.obj \ - $O\PanelItemOpen.obj \ - $O\PanelItems.obj \ - $O\PanelKey.obj \ - $O\PanelListNotify.obj \ - $O\PanelMenu.obj \ - $O\PanelOperations.obj \ - $O\PanelSelect.obj \ - $O\PanelSort.obj \ - $O\PanelSplitFile.obj \ - $O\ProgramLocation.obj \ - $O\PropertyName.obj \ - $O\RegistryAssociations.obj \ - $O\RegistryPlugins.obj \ - $O\RegistryUtils.obj \ - $O\RootFolder.obj \ - $O\SplitUtils.obj \ - $O\StringUtils.obj \ - $O\SysIconUtils.obj \ - $O\TextPairs.obj \ - $O\UpdateCallback100.obj \ - $O\ViewSettings.obj \ - $O\AboutDialog.obj \ - $O\ComboDialog.obj \ - $O\CopyDialog.obj \ - $O\EditPage.obj \ - $O\LangPage.obj \ - $O\ListViewDialog.obj \ - $O\MessagesDialog.obj \ - $O\OverwriteDialog.obj \ - $O\PasswordDialog.obj \ - $O\ProgressDialog2.obj \ - $O\SettingsPage.obj \ - $O\SplitDialog.obj \ - $O\SystemPage.obj \ +!include "FM.mak" COMMON_OBJS = \ - $O\CRC.obj \ $O\IntToString.obj \ $O\Lang.obj \ $O\MyString.obj \ @@ -80,45 +22,33 @@ COMMON_OBJS = \ $O\Random.obj \ $O\StringConvert.obj \ $O\StringToInt.obj \ - $O\TextConfig.obj \ $O\UTFConvert.obj \ $O\Wildcard.obj \ -WIN_OBJS = \ +WIN_OBJS = $(WIN_OBJS) \ $O\Clipboard.obj \ $O\CommonDialog.obj \ $O\DLL.obj \ - $O\Error.obj \ + $O\ErrorMsg.obj \ $O\FileDir.obj \ $O\FileFind.obj \ $O\FileIO.obj \ + $O\FileLink.obj \ $O\FileName.obj \ - $O\Memory.obj \ + $O\MemoryGlobal.obj \ $O\MemoryLock.obj \ $O\Menu.obj \ - $O\Process.obj \ + $O\ProcessUtils.obj \ $O\PropVariant.obj \ - $O\PropVariantConversions.obj \ + $O\PropVariantConv.obj \ $O\Registry.obj \ $O\ResourceString.obj \ $O\Shell.obj \ $O\Synchronization.obj \ - $O\Time.obj \ + $O\System.obj \ + $O\TimeUtils.obj \ $O\Window.obj \ -!IFNDEF UNDER_CE - -FM_OBJS = $(FM_OBJS) \ - $O\FSDrives.obj \ - $O\NetFolder.obj \ - -WIN_OBJS = $(WIN_OBJS) \ - $O\FileSystem.obj \ - $O\Net.obj \ - $O\Security.obj \ - -!ENDIF - WIN_CTRL_OBJS = \ $O\ComboBox.obj \ @@ -128,14 +58,17 @@ WIN_CTRL_OBJS = \ $O\Window2.obj \ 7ZIP_COMMON_OBJS = \ + $O\CreateCoder.obj \ $O\FilePathAutoRename.obj \ $O\FileStreams.obj \ + $O\FilterCoder.obj \ + $O\LimitedStreams.obj \ + $O\MethodProps.obj \ $O\ProgressUtils.obj \ + $O\PropId.obj \ $O\StreamObjects.obj \ $O\StreamUtils.obj \ - -AR_COMMON_OBJS = \ - $O\OutStreamWithCRC.obj \ + $O\UniqBlocks.obj \ UI_COMMON_OBJS = \ $O\ArchiveExtractCallback.obj \ @@ -145,9 +78,11 @@ UI_COMMON_OBJS = \ $O\DefaultName.obj \ $O\EnumDirItems.obj \ $O\ExtractingFilePath.obj \ + $O\HashCalc.obj \ $O\LoadCodecs.obj \ $O\OpenArchive.obj \ $O\PropIDUtils.obj \ + $O\SetProperties.obj \ $O\SortUtils.obj \ $O\UpdateAction.obj \ $O\UpdateCallback.obj \ @@ -160,64 +95,15 @@ EXPLORER_OBJS = \ $O\ContextMenu.obj \ $O\RegistryContextMenu.obj \ -AGENT_OBJS = \ - $O\Agent.obj \ - $O\AgentOut.obj \ - $O\AgentProxy.obj \ - $O\ArchiveFolder.obj \ - $O\ArchiveFolderOpen.obj \ - $O\ArchiveFolderOut.obj \ - $O\UpdateCallbackAgent.obj \ +GUI_OBJS = \ + $O\HashGUI.obj \ + +COMPRESS_OBJS = \ + $O\CopyCoder.obj \ C_OBJS = \ $O\Alloc.obj \ - $O\CpuArch.obj \ - $O\Sha256.obj \ $O\Sort.obj \ $O\Threads.obj \ -!include "../../Crc.mak" - -OBJS = \ - $O\StdAfx.obj \ - $(FM_OBJS)\ - $(COMMON_OBJS) \ - $(WIN_OBJS) \ - $(WIN_CTRL_OBJS) \ - $(7ZIP_COMMON_OBJS) \ - $(AR_COMMON_OBJS) \ - $(UI_COMMON_OBJS) \ - $(EXPLORER_OBJS) \ - $(AGENT_OBJS) \ - $O\CopyCoder.obj \ - $(C_OBJS) \ - $(ASM_OBJS) \ - $O\resource.res \ - -!include "../../../Build.mak" - -$(FM_OBJS): $(*B).cpp - $(COMPL) -$(COMMON_OBJS): ../../../Common/$(*B).cpp - $(COMPL) -$(WIN_OBJS): ../../../Windows/$(*B).cpp - $(COMPL) -$(WIN_CTRL_OBJS): ../../../Windows/Control/$(*B).cpp - $(COMPL) -$(7ZIP_COMMON_OBJS): ../../Common/$(*B).cpp - $(COMPL) -$(AR_COMMON_OBJS): ../../Archive/Common/$(*B).cpp - $(COMPL) -$(UI_COMMON_OBJS): ../Common/$(*B).cpp - $(COMPL) -$(AGENT_OBJS): ../Agent/$(*B).cpp - $(COMPL) -$(EXPLORER_OBJS): ../Explorer/$(*B).cpp - $(COMPL) - -$O\CopyCoder.obj: ../../Compress/$(*B).cpp - $(COMPL) -$(C_OBJS): ../../../../C/$(*B).c - $(COMPL_O2) - -!include "../../Asm.mak" +!include "../../7zip.mak" diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h old mode 100755 new mode 100644 index cdb77edf..55af3555 --- a/CPP/7zip/UI/FileManager/resource.h +++ b/CPP/7zip/UI/FileManager/resource.h @@ -1,164 +1,171 @@ #include "resourceGui.h" -#define IDR_MENUBAR1 103 -#define IDM_MENU 103 -#define IDR_ACCELERATOR1 209 -#define IDM_FILE_OPEN 210 -#define IDM_FILE_OPEN_INSIDE 211 -#define IDM_FILE_OPEN_OUTSIDE 212 -#define IDM_FILE_VIEW 220 -#define IDM_FILE_EDIT 221 -#define IDM_RENAME 230 -#define IDM_COPY_TO 231 -#define IDM_MOVE_TO 232 -#define IDM_DELETE 233 -#define IDM_FILE_SPLIT 238 -#define IDM_FILE_COMBINE 239 -#define IDM_FILE_PROPERTIES 240 -#define IDM_FILE_COMMENT 241 -#define IDM_FILE_CRC 242 -#define IDM_FILE_DIFF 243 -#define IDM_CREATE_FOLDER 250 -#define IDM_CREATE_FILE 251 -#define IDM_EDIT_CUT 320 -#define IDM_EDIT_COPY 321 -#define IDM_EDIT_PASTE 322 -#define IDM_SELECT_ALL 330 -#define IDM_DESELECT_ALL 331 -#define IDM_INVERT_SELECTION 332 -#define IDM_SELECT 333 -#define IDM_DESELECT 334 -#define IDM_SELECT_BY_TYPE 335 -#define IDM_DESELECT_BY_TYPE 336 -#define IDM_VIEW_LARGE_ICONS 410 -#define IDM_VIEW_SMALL_ICONS 411 -#define IDM_VIEW_LIST 412 -#define IDM_VIEW_DETAILS 413 -#define IDM_VIEW_ARANGE_BY_NAME 420 -#define IDM_VIEW_ARANGE_BY_TYPE 421 -#define IDM_VIEW_ARANGE_BY_DATE 422 -#define IDM_VIEW_ARANGE_BY_SIZE 423 -#define IDM_VIEW_ARANGE_NO_SORT 424 -#define IDM_OPEN_ROOT_FOLDER 430 -#define IDM_OPEN_PARENT_FOLDER 431 -#define IDM_FOLDERS_HISTORY 432 -#define IDM_VIEW_REFRESH 440 -#define IDM_VIEW_FLAT_VIEW 449 -#define IDM_VIEW_TWO_PANELS 450 -#define IDM_VIEW_TOOLBARS 451 -#define IDM_VIEW_STANDARD_TOOLBAR 460 -#define IDM_VIEW_ARCHIVE_TOOLBAR 461 -#define IDM_VIEW_TOOLBARS_LARGE_BUTTONS 462 -#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 463 -#define IDM_OPTIONS 510 -#define IDM_BENCHMARK 511 -#define IDM_BENCHMARK2 512 -#define IDM_HELP_CONTENTS 610 -#define IDM_ABOUT 620 -#define IDS_BOOKMARK 720 -#define IDB_ADD 2002 -#define IDB_EXTRACT 2003 -#define IDB_TEST 2004 -#define IDB_COPY 2010 -#define IDB_MOVE 2011 -#define IDB_DELETE 2012 -#define IDB_INFO 2013 -#define IDB_ADD2 2082 -#define IDB_EXTRACT2 2083 -#define IDB_TEST2 2084 -#define IDB_COPY2 2090 -#define IDB_MOVE2 2091 -#define IDB_DELETE2 2092 -#define IDB_INFO2 2093 -#define IDS_APP_TITLE 2200 -#define IDS_COPY 2201 -#define IDS_MOVE 2202 -#define IDS_COPY_TO 2203 -#define IDS_MOVE_TO 2204 -#define IDS_COPYING 2205 -#define IDS_MOVING 2206 -#define IDS_CANNOT_COPY 2207 -#define IDS_OPERATION_IS_NOT_SUPPORTED 2208 - -#define IDS_CONFIRM_FILE_DELETE 2210 -#define IDS_CONFIRM_FOLDER_DELETE 2211 -#define IDS_CONFIRM_ITEMS_DELETE 2212 -#define IDS_WANT_TO_DELETE_FILE 2213 -#define IDS_WANT_TO_DELETE_FOLDER 2214 -#define IDS_WANT_TO_DELETE_ITEMS 2215 -#define IDS_DELETING 2216 -#define IDS_ERROR_DELETING 2217 -#define IDS_ERROR_LONG_PATH_TO_RECYCLE 2218 - -#define IDS_RENAMING 2220 -#define IDS_ERROR_RENAMING 2221 -#define IDS_CONFIRM_FILE_COPY 2222 -#define IDS_WANT_TO_COPY_FILES 2223 - - -#define IDS_CREATE_FOLDER 2230 -#define IDS_CREATE_FOLDER_NAME 2231 -#define IDS_CREATE_FOLDER_DEFAULT_NAME 2232 -#define IDS_CREATE_FOLDER_ERROR 2233 -#define IDS_CREATE_FILE 2240 -#define IDS_CREATE_FILE_NAME 2241 -#define IDS_CREATE_FOLDER_DEFAULT_FILE_NAME 2242 -#define IDS_CREATE_FILE_DEFAULT_NAME 2242 -#define IDS_CREATE_FILE_ERROR 2243 -#define IDS_SELECT 2250 -#define IDS_DESELECT 2251 -#define IDS_SELECT_MASK 2252 -#define IDS_FOLDERS_HISTORY 2260 -#define IDS_N_SELECTED_ITEMS 2270 - -#define IDS_TOO_MANY_ITEMS 2279 -#define IDS_WANT_UPDATE_MODIFIED_FILE 2280 -#define IDS_CANNOT_UPDATE_FILE 2281 -#define IDS_CANNOT_START_EDITOR 2282 -#define IDS_OPENNING 2283 -#define IDS_VIRUS 2284 -#define IDS_COMPUTER 2300 -#define IDS_NETWORK 2301 -#define IDS_DOCUMENTS 2302 -#define IDS_ADD 2400 -#define IDS_EXTRACT 2401 -#define IDS_TEST 2402 -#define IDS_BUTTON_COPY 2420 -#define IDS_BUTTON_MOVE 2421 -#define IDS_BUTTON_DELETE 2422 -#define IDS_BUTTON_INFO 2423 -#define IDS_PROP_TOTAL_SIZE 3100 -#define IDS_PROP_FREE_SPACE 3101 -#define IDS_PROP_CLUSTER_SIZE 3102 -#define IDS_PROP_VOLUME_NAME 3103 -#define IDS_PROP_LOCAL_NAME 3200 -#define IDS_PROP_PROVIDER 3201 -#define IDS_OPTIONS 4000 -#define IDS_COMMENT 4001 -#define IDS_COMMENT2 4002 -#define IDS_SYSTEM 4010 - -#define IDS_SPLITTING 4020 -#define IDS_SPLIT_CONFIRM_TITLE 4021 -#define IDS_SPLIT_CONFIRM_MESSAGE 4022 -#define IDS_SPLIT_VOL_MUST_BE_SMALLER 4023 - -#define IDS_COMBINE 4030 -#define IDS_COMBINE_TO 4031 -#define IDS_COMBINING 4032 -#define IDS_COMBINE_SELECT_ONE_FILE 4033 -#define IDS_COMBINE_CANT_DETECT_SPLIT_FILE 4034 -#define IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART 4035 - -#define IDS_CHECKSUM_CALCULATING 4040 -#define IDS_CHECKSUM_INFORMATION 4041 -#define IDS_CHECKSUM_CRC_DATA 4042 -#define IDS_CHECKSUM_CRC_DATA_NAMES 4043 - -#define IDS_SCANNING 4050 -#define IDS_PROPERTIES 4060 - -#define IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER 4301 -#define IDS_SELECT_ONE_FILE 4302 -#define IDS_SELECT_FILES 4303 -#define IDS_FILE_EXIST 4304 +#define IDR_MENUBAR1 70 +#define IDM_MENU 71 +#define IDR_ACCELERATOR1 72 + +#define IDB_ADD 100 +#define IDB_EXTRACT 101 +#define IDB_TEST 102 +#define IDB_COPY 103 +#define IDB_MOVE 104 +#define IDB_DELETE 105 +#define IDB_INFO 106 + +#define IDB_ADD2 150 +#define IDB_EXTRACT2 151 +#define IDB_TEST2 152 +#define IDB_COPY2 153 +#define IDB_MOVE2 154 +#define IDB_DELETE2 155 +#define IDB_INFO2 156 + +#define IDM_HASH_ALL 101 +#define IDM_CRC32 102 +#define IDM_CRC64 103 +#define IDM_SHA1 104 +#define IDM_SHA256 105 + +#define IDM_OPEN 540 +#define IDM_OPEN_INSIDE 541 +#define IDM_OPEN_OUTSIDE 542 +#define IDM_FILE_VIEW 543 +#define IDM_FILE_EDIT 544 +#define IDM_RENAME 545 +#define IDM_COPY_TO 546 +#define IDM_MOVE_TO 547 +#define IDM_DELETE 548 +#define IDM_SPLIT 549 +#define IDM_COMBINE 550 +#define IDM_PROPERTIES 551 +#define IDM_COMMENT 552 +#define IDM_CRC 553 +#define IDM_DIFF 554 +#define IDM_CREATE_FOLDER 555 +#define IDM_CREATE_FILE 556 +// #define IDM_EXIT 557 +#define IDM_LINK 558 + +#define IDM_SELECT_ALL 600 +#define IDM_DESELECT_ALL 601 +#define IDM_INVERT_SELECTION 602 +#define IDM_SELECT 603 +#define IDM_DESELECT 604 +#define IDM_SELECT_BY_TYPE 605 +#define IDM_DESELECT_BY_TYPE 606 + +#define IDM_VIEW_LARGE_ICONS 700 +#define IDM_VIEW_SMALL_ICONS 701 +#define IDM_VIEW_LIST 702 +#define IDM_VIEW_DETAILS 703 + +#define IDM_VIEW_ARANGE_BY_NAME 710 +#define IDM_VIEW_ARANGE_BY_TYPE 711 +#define IDM_VIEW_ARANGE_BY_DATE 712 +#define IDM_VIEW_ARANGE_BY_SIZE 713 + +#define IDM_VIEW_ARANGE_NO_SORT 730 +#define IDM_VIEW_FLAT_VIEW 731 +#define IDM_VIEW_TWO_PANELS 732 +#define IDM_VIEW_TOOLBARS 733 +#define IDM_OPEN_ROOT_FOLDER 734 +#define IDM_OPEN_PARENT_FOLDER 735 +#define IDM_FOLDERS_HISTORY 736 +#define IDM_VIEW_REFRESH 737 +#define IDM_VIEW_AUTO_REFRESH 738 +// #define IDM_VIEW_SHOW_DELETED 739 +// #define IDM_VIEW_SHOW_STREAMS 740 + +#define IDM_VIEW_ARCHIVE_TOOLBAR 750 +#define IDM_VIEW_STANDARD_TOOLBAR 751 +#define IDM_VIEW_TOOLBARS_LARGE_BUTTONS 752 +#define IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT 753 + +#define IDS_BOOKMARK 801 + +#define IDM_OPTIONS 900 +#define IDM_BENCHMARK 901 +#define IDM_BENCHMARK2 902 + +#define IDM_HELP_CONTENTS 960 +#define IDM_ABOUT 961 + +#define IDS_OPTIONS 2100 + +#define IDS_N_SELECTED_ITEMS 3002 + +#define IDS_FILE_EXIST 3008 +#define IDS_WANT_UPDATE_MODIFIED_FILE 3009 +#define IDS_CANNOT_UPDATE_FILE 3010 +#define IDS_CANNOT_START_EDITOR 3011 +#define IDS_VIRUS 3012 +#define IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER 3013 +#define IDS_SELECT_ONE_FILE 3014 +#define IDS_SELECT_FILES 3015 +#define IDS_TOO_MANY_ITEMS 3016 + +#define IDS_COPY 6000 +#define IDS_MOVE 6001 +#define IDS_COPY_TO 6002 +#define IDS_MOVE_TO 6003 +#define IDS_COPYING 6004 +#define IDS_MOVING 6005 +#define IDS_RENAMING 6006 + +#define IDS_OPERATION_IS_NOT_SUPPORTED 6008 +#define IDS_ERROR_RENAMING 6009 +#define IDS_CONFIRM_FILE_COPY 6010 +#define IDS_WANT_TO_COPY_FILES 6011 + +#define IDS_CONFIRM_FILE_DELETE 6100 +#define IDS_CONFIRM_FOLDER_DELETE 6101 +#define IDS_CONFIRM_ITEMS_DELETE 6102 +#define IDS_WANT_TO_DELETE_FILE 6103 +#define IDS_WANT_TO_DELETE_FOLDER 6104 +#define IDS_WANT_TO_DELETE_ITEMS 6105 +#define IDS_DELETING 6106 +#define IDS_ERROR_DELETING 6107 +#define IDS_ERROR_LONG_PATH_TO_RECYCLE 6108 + +#define IDS_CREATE_FOLDER 6300 +#define IDS_CREATE_FILE 6301 +#define IDS_CREATE_FOLDER_NAME 6302 +#define IDS_CREATE_FILE_NAME 6303 +#define IDS_CREATE_FOLDER_DEFAULT_NAME 6304 +#define IDS_CREATE_FILE_DEFAULT_NAME 6305 +#define IDS_CREATE_FOLDER_ERROR 6306 +#define IDS_CREATE_FILE_ERROR 6307 + +#define IDS_COMMENT 6400 +#define IDS_COMMENT2 6401 +#define IDS_SELECT 6402 +#define IDS_DESELECT 6403 +#define IDS_SELECT_MASK 6404 + +#define IDS_PROPERTIES 6600 +#define IDS_FOLDERS_HISTORY 6601 + +#define IDS_COMPUTER 7100 +#define IDS_NETWORK 7101 +#define IDS_DOCUMENTS 7102 +#define IDS_SYSTEM 7103 + +#define IDS_ADD 7200 +#define IDS_EXTRACT 7201 +#define IDS_TEST 7202 +#define IDS_BUTTON_COPY 7203 +#define IDS_BUTTON_MOVE 7204 +#define IDS_BUTTON_DELETE 7205 +#define IDS_BUTTON_INFO 7206 + +#define IDS_SPLITTING 7303 +#define IDS_SPLIT_CONFIRM_TITLE 7304 +#define IDS_SPLIT_CONFIRM_MESSAGE 7305 +#define IDS_SPLIT_VOL_MUST_BE_SMALLER 7306 + +#define IDS_COMBINE 7400 +#define IDS_COMBINE_TO 7401 +#define IDS_COMBINING 7402 +#define IDS_COMBINE_SELECT_ONE_FILE 7403 +#define IDS_COMBINE_CANT_DETECT_SPLIT_FILE 7404 +#define IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART 7405 diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc old mode 100755 new mode 100644 index 2952ce5a..61cf33e8 --- a/CPP/7zip/UI/FileManager/resource.rc +++ b/CPP/7zip/UI/FileManager/resource.rc @@ -4,13 +4,12 @@ MY_VERSION_INFO_APP("7-Zip File Manager", "7zFM") - IDR_ACCELERATOR1 ACCELERATORS BEGIN - "N", IDM_CREATE_FILE, VIRTKEY, CONTROL, NOINVERT +// "N", IDM_CREATE_FILE, VIRTKEY, CONTROL, NOINVERT VK_F1, IDM_HELP_CONTENTS, VIRTKEY, NOINVERT VK_F12, IDM_FOLDERS_HISTORY, VIRTKEY, ALT, NOINVERT - VK_F7, IDM_CREATE_FOLDER, VIRTKEY, NOINVERT +// VK_F7, IDM_CREATE_FOLDER, VIRTKEY, NOINVERT END @@ -18,9 +17,10 @@ IDM_MENU MENU BEGIN POPUP "&File" BEGIN - MENUITEM "&Open\tEnter", IDM_FILE_OPEN - MENUITEM "Open &Inside\tCtrl+PgDn", IDM_FILE_OPEN_INSIDE - MENUITEM "Open O&utside\tShift+Enter", IDM_FILE_OPEN_OUTSIDE + MENUITEM "&Open\tEnter", IDM_OPEN + MENUITEM "Open &Inside\tCtrl+PgDn", IDM_OPEN_INSIDE + MENUITEM "Open O&utside\tShift+Enter", IDM_OPEN_OUTSIDE + MENUITEM "&View\tF3", IDM_FILE_VIEW MENUITEM "&Edit\tF4", IDM_FILE_EDIT MENUITEM SEPARATOR MENUITEM "Rena&me\tF2", IDM_RENAME @@ -28,17 +28,27 @@ BEGIN MENUITEM "&Move To...\tF6", IDM_MOVE_TO MENUITEM "&Delete\tDel", IDM_DELETE MENUITEM SEPARATOR - MENUITEM "&Split file...", IDM_FILE_SPLIT - MENUITEM "Com&bine files...", IDM_FILE_COMBINE + MENUITEM "&Split file...", IDM_SPLIT + MENUITEM "Com&bine files...", IDM_COMBINE MENUITEM SEPARATOR - MENUITEM "P&roperties\tAlt+Enter", IDM_FILE_PROPERTIES - MENUITEM "Comme&nt...\tCtrl+Z", IDM_FILE_COMMENT - MENUITEM "Calculate checksum", IDM_FILE_CRC - MENUITEM "Di&ff", IDM_FILE_DIFF + MENUITEM "P&roperties\tAlt+Enter", IDM_PROPERTIES + MENUITEM "Comme&nt...\tCtrl+Z", IDM_COMMENT + // MENUITEM "Calculate checksum", IDM_CRC + POPUP "CRC" + BEGIN + MENUITEM "CRC-32", IDM_CRC32 + MENUITEM "CRC-64", IDM_CRC64 + MENUITEM "SHA-1", IDM_SHA1 + MENUITEM "SHA-256", IDM_SHA256 + MENUITEM "*", IDM_HASH_ALL + END + MENUITEM "Di&ff", IDM_DIFF MENUITEM SEPARATOR MENUITEM "Create Folder\tF7", IDM_CREATE_FOLDER MENUITEM "Create File\tCtrl+N", IDM_CREATE_FILE MENUITEM SEPARATOR + MENUITEM "&Link...", IDM_LINK + MENUITEM SEPARATOR MENUITEM "E&xit\tAlt+F4", IDCLOSE END POPUP "&Edit" @@ -72,16 +82,21 @@ BEGIN MENUITEM "&2 Panels\tF9", IDM_VIEW_TWO_PANELS POPUP "Toolbars" BEGIN - MENUITEM "Archive Toolbar", IDM_VIEW_ARCHIVE_TOOLBAR - MENUITEM "Standard Toolbar", IDM_VIEW_STANDARD_TOOLBAR + MENUITEM "Archive Toolbar", IDM_VIEW_ARCHIVE_TOOLBAR + MENUITEM "Standard Toolbar", IDM_VIEW_STANDARD_TOOLBAR MENUITEM SEPARATOR - MENUITEM "Large Buttons", IDM_VIEW_TOOLBARS_LARGE_BUTTONS - MENUITEM "Show Buttons Text", IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT + MENUITEM "Large Buttons", IDM_VIEW_TOOLBARS_LARGE_BUTTONS + MENUITEM "Show Buttons Text", IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT END MENUITEM "Open Root Folder\t\\", IDM_OPEN_ROOT_FOLDER MENUITEM "Up One Level\tBackspace", IDM_OPEN_PARENT_FOLDER MENUITEM "Folders History...\tAlt+F12", IDM_FOLDERS_HISTORY MENUITEM "&Refresh\tCtrl+R", IDM_VIEW_REFRESH + MENUITEM "Auto Refresh", IDM_VIEW_AUTO_REFRESH + + // MENUITEM "Show NTFS streams", IDM_VIEW_SHOW_STREAMS + // MENUITEM "Show deleted files", IDM_VIEW_SHOW_DELETED + END POPUP "F&avorites" BEGIN @@ -105,7 +120,7 @@ BEGIN MENUITEM "&Contents...\tF1", IDM_HELP_CONTENTS #endif MENUITEM SEPARATOR - MENUITEM "&About 7-Zip...", IDM_ABOUT + MENUITEM "&About 7-Zip...", IDM_ABOUT END END @@ -134,99 +149,89 @@ IDB_INFO2 BITMAP "../../UI/FileManager/Info2.bmp" STRINGTABLE BEGIN - IDS_APP_TITLE "7-Zip File Manager" - IDS_COPY "Copy" - IDS_MOVE "Move" - IDS_COPY_TO "Copy to:" - IDS_MOVE_TO "Move to:" - IDS_COPYING "Copying..." - IDS_MOVING "Moving..." - IDS_CANNOT_COPY "You cannot move or copy items for such folders." - IDS_SPLITTING "Splitting..." - IDS_SPLIT_CONFIRM_TITLE "Confirm Splitting" - IDS_SPLIT_CONFIRM_MESSAGE "Are you sure you want to split file into {0} volumes?" - IDS_SPLIT_VOL_MUST_BE_SMALLER "Volume size must be smaller than size of original file" + IDS_BOOKMARK "Bookmark" - IDS_COMBINE "Combine Files" - IDS_COMBINE_TO "&Combine to:" - IDS_COMBINING "Combining..." - IDS_COMBINE_SELECT_ONE_FILE "Select only first part of split file" - IDS_COMBINE_CANT_DETECT_SPLIT_FILE "Can not detect file as split file" - IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART "Can not find more than one part of split file" + IDS_OPTIONS "Options" - IDS_CHECKSUM_CALCULATING "Checksum calculating..." - IDS_CHECKSUM_INFORMATION "Checksum information" - IDS_CHECKSUM_CRC_DATA "CRC checksum for data:" - IDS_CHECKSUM_CRC_DATA_NAMES "CRC checksum for data and names:" + IDS_N_SELECTED_ITEMS "{0} object(s) selected" - IDS_SCANNING "Scanning..." + IDS_FILE_EXIST "File {0} is already exist" + IDS_WANT_UPDATE_MODIFIED_FILE "File '{0}' was modified.\nDo you want to update it in the archive?" + IDS_CANNOT_UPDATE_FILE "Can not update file\n'{0}'" + IDS_CANNOT_START_EDITOR "Cannot start editor." + IDS_VIRUS "The file looks like a virus (the file name contains long spaces in name)." + IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path." + IDS_SELECT_ONE_FILE "You must select one file" + IDS_SELECT_FILES "You must select one or more files" + IDS_TOO_MANY_ITEMS "Too many items" - IDS_PROPERTIES "Properties" + IDS_COPY "Copy" + IDS_MOVE "Move" + IDS_COPY_TO "Copy to:" + IDS_MOVE_TO "Move to:" + IDS_COPYING "Copying..." + IDS_MOVING "Moving..." + IDS_RENAMING "Renaming..." - IDS_OPERATION_IS_NOT_SUPPORTED "Operation is not supported." - - IDS_CONFIRM_FILE_DELETE "Confirm File Delete" + IDS_OPERATION_IS_NOT_SUPPORTED "Operation is not supported." + IDS_ERROR_RENAMING "Error Renaming File or Folder" + IDS_CONFIRM_FILE_COPY "Confirm File Copy" + IDS_WANT_TO_COPY_FILES "Are you sure you want to copy files to archive" + + IDS_CONFIRM_FILE_DELETE "Confirm File Delete" IDS_CONFIRM_FOLDER_DELETE "Confirm Folder Delete" - IDS_CONFIRM_ITEMS_DELETE "Confirm Multiple File Delete" - IDS_WANT_TO_DELETE_FILE "Are you sure you want to delete '{0}'?" + IDS_CONFIRM_ITEMS_DELETE "Confirm Multiple File Delete" + IDS_WANT_TO_DELETE_FILE "Are you sure you want to delete '{0}'?" IDS_WANT_TO_DELETE_FOLDER "Are you sure you want to delete the folder '{0}' and all its contents?" IDS_WANT_TO_DELETE_ITEMS "Are you sure you want to delete these {0} items?" - IDS_DELETING "Deleting..." - IDS_ERROR_DELETING "Error Deleting File or Folder" + IDS_DELETING "Deleting..." + IDS_ERROR_DELETING "Error Deleting File or Folder" IDS_ERROR_LONG_PATH_TO_RECYCLE "The system cannot move a file with long path to the Recycle Bin" - IDS_RENAMING "Renaming..." - IDS_ERROR_RENAMING "Error Renaming File or Folder" - IDS_CONFIRM_FILE_COPY "Confirm File Copy" - IDS_WANT_TO_COPY_FILES "Are you sure you want to copy files to archive" IDS_CREATE_FOLDER "Create Folder" - IDS_CREATE_FOLDER_NAME "Folder name:" - IDS_CREATE_FOLDER_DEFAULT_NAME "New Folder" - IDS_CREATE_FOLDER_ERROR "Error Creating Folder" IDS_CREATE_FILE "Create File" + IDS_CREATE_FOLDER_NAME "Folder name:" IDS_CREATE_FILE_NAME "File Name:" - IDS_CREATE_FILE_DEFAULT_NAME "New File" + IDS_CREATE_FOLDER_DEFAULT_NAME "New Folder" + IDS_CREATE_FILE_DEFAULT_NAME "New File" + IDS_CREATE_FOLDER_ERROR "Error Creating Folder" IDS_CREATE_FILE_ERROR "Error Creating File" - IDS_SELECT "Select" - IDS_DESELECT "Deselect" - IDS_SELECT_MASK "Mask:" - IDS_FOLDERS_HISTORY "Folders History" - IDS_N_SELECTED_ITEMS "{0} object(s) selected" - - IDS_PROP_TOTAL_SIZE "Total Size" - IDS_PROP_FREE_SPACE "Free Space" - IDS_PROP_CLUSTER_SIZE "Cluster Size" - IDS_PROP_VOLUME_NAME "Label" - IDS_PROP_LOCAL_NAME "Local Name" - IDS_PROP_PROVIDER "Provider" - IDS_OPTIONS "Options" - IDS_COMMENT "Comment" - IDS_COMMENT2 "&Comment:" - IDS_SYSTEM "System" - IDS_TOO_MANY_ITEMS "Too many items" - IDS_WANT_UPDATE_MODIFIED_FILE "File '{0}' was modified.\nDo you want to update it in the archive?" - IDS_CANNOT_UPDATE_FILE "Can not update file\n'{0}'" - IDS_CANNOT_START_EDITOR "Cannot start editor." - IDS_OPENNING "Opening..." - IDS_VIRUS "The file looks like a virus (the file name contains long spaces in name)." - IDS_ADD "Add" - IDS_EXTRACT "Extract" - IDS_TEST "Test" - IDS_BUTTON_COPY "Copy" - IDS_BUTTON_MOVE "Move" - IDS_BUTTON_DELETE "Delete" - IDS_BUTTON_INFO "Info" - IDS_BOOKMARK "Bookmark" - IDS_COMPUTER "Computer" - IDS_NETWORK "Network" - IDS_DOCUMENTS "Documents" - IDS_MESSAGE_UNSUPPORTED_OPERATION_FOR_LONG_PATH_FOLDER "The operation cannot be called from a folder that has a long path." - IDS_SELECT_ONE_FILE "You must select one file" - IDS_SELECT_FILES "You must select one or more files" - IDS_FILE_EXIST "File {0} is already exist" -END + IDS_COMMENT "Comment" + IDS_COMMENT2 "&Comment:" + IDS_SELECT "Select" + IDS_DESELECT "Deselect" + IDS_SELECT_MASK "Mask:" + IDS_PROPERTIES "Properties" + IDS_FOLDERS_HISTORY "Folders History" + + IDS_COMPUTER "Computer" + IDS_NETWORK "Network" + IDS_DOCUMENTS "Documents" + IDS_SYSTEM "System" + + IDS_ADD "Add" + IDS_EXTRACT "Extract" + IDS_TEST "Test" + IDS_BUTTON_COPY "Copy" + IDS_BUTTON_MOVE "Move" + IDS_BUTTON_DELETE "Delete" + IDS_BUTTON_INFO "Info" + + IDS_SPLITTING "Splitting..." + IDS_SPLIT_CONFIRM_TITLE "Confirm Splitting" + IDS_SPLIT_CONFIRM_MESSAGE "Are you sure you want to split file into {0} volumes?" + IDS_SPLIT_VOL_MUST_BE_SMALLER "Volume size must be smaller than size of original file" + + IDS_COMBINE "Combine Files" + IDS_COMBINE_TO "&Combine to:" + IDS_COMBINING "Combining..." + IDS_COMBINE_SELECT_ONE_FILE "Select only first part of split file" + IDS_COMBINE_CANT_DETECT_SPLIT_FILE "Can not detect file as split file" + IDS_COMBINE_CANT_FIND_MORE_THAN_ONE_PART "Can not find more than one part of split file" + +END #include "AboutDialog.rc" #include "BrowseDialog.rc" @@ -235,12 +240,12 @@ END #include "EditPage.rc" #include "FoldersPage.rc" #include "LangPage.rc" +#include "LinkDialog.rc" #include "ListViewDialog.rc" #include "MenuPage.rc" #include "MessagesDialog.rc" #include "OverwriteDialog.rc" #include "PasswordDialog.rc" -#include "PluginsPage.rc" #include "ProgressDialog2.rc" #include "PropertyName.rc" #include "SettingsPage.rc" diff --git a/CPP/7zip/UI/FileManager/resourceGui.h b/CPP/7zip/UI/FileManager/resourceGui.h old mode 100755 new mode 100644 index 14cedda5..7c1b40e4 --- a/CPP/7zip/UI/FileManager/resourceGui.h +++ b/CPP/7zip/UI/FileManager/resourceGui.h @@ -1,10 +1,15 @@ #define IDI_ICON 1 -#define IDS_INCORRECT_VOLUME_SIZE 95 +#define IDS_MESSAGE_NO_ERRORS 3001 -#define IDS_FILES_COLON 2274 -#define IDS_FOLDERS_COLON 2275 -#define IDS_SIZE_COLON 2276 +#define IDS_PROGRESS_TESTING 3302 +#define IDS_OPENNING 3303 +#define IDS_SCANNING 3304 -#define IDS_PROGRESS_TESTING 4100 -#define IDS_MESSAGE_NO_ERRORS 4200 +#define IDS_CHECKSUM_CALCULATING 7500 +#define IDS_CHECKSUM_INFORMATION 7501 +#define IDS_CHECKSUM_CRC_DATA 7502 +#define IDS_CHECKSUM_CRC_DATA_NAMES 7503 +#define IDS_CHECKSUM_CRC_STREAMS_NAMES 7504 + +#define IDS_INCORRECT_VOLUME_SIZE 7307 diff --git a/CPP/7zip/UI/FileManager/resourceGui.rc b/CPP/7zip/UI/FileManager/resourceGui.rc old mode 100755 new mode 100644 index 2e706ea2..f748e0bd --- a/CPP/7zip/UI/FileManager/resourceGui.rc +++ b/CPP/7zip/UI/FileManager/resourceGui.rc @@ -2,12 +2,18 @@ STRINGTABLE BEGIN - IDS_INCORRECT_VOLUME_SIZE "Incorrect volume size" + IDS_MESSAGE_NO_ERRORS "There are no errors" - IDS_FILES_COLON "Files:" - IDS_FOLDERS_COLON "Folders:" - IDS_SIZE_COLON "Size:" + IDS_PROGRESS_TESTING "Testing" - IDS_PROGRESS_TESTING "Testing" - IDS_MESSAGE_NO_ERRORS "There are no errors" + IDS_CHECKSUM_CALCULATING "Checksum calculating..." + IDS_CHECKSUM_INFORMATION "Checksum information" + IDS_CHECKSUM_CRC_DATA "CRC checksum for data:" + IDS_CHECKSUM_CRC_DATA_NAMES "CRC checksum for data and names:" + IDS_CHECKSUM_CRC_STREAMS_NAMES "CRC checksum for streams and names:" + + IDS_INCORRECT_VOLUME_SIZE "Incorrect volume size" + + IDS_OPENNING "Opening..." + IDS_SCANNING "Scanning..." END -- cgit v1.2.3