From b44b6d5c101f0b963fa9988d326a2676d7cde827 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 26 Nov 2018 01:37:25 -0300 Subject: [PATCH] Remove two folders in src i accidentally renamed --- src/ircc/appveyor.cpp | 150 - src/smpackagee/ChangeGameSettings.cpp | 191 -- src/smpackagee/ChangeGameSettings.h | 76 - src/smpackagee/CreateLanguageDlg.cpp | 74 - src/smpackagee/CreateLanguageDlg.h | 33 - src/smpackagee/EditInsallations.cpp | 190 -- src/smpackagee/EditInsallations.h | 80 - src/smpackagee/EnterComment.cpp | 109 - src/smpackagee/EnterComment.h | 81 - src/smpackagee/EnterName.cpp | 88 - src/smpackagee/EnterName.h | 75 - src/smpackagee/LanguagesDlg.cpp | 684 ---- src/smpackagee/LanguagesDlg.h | 36 - src/smpackagee/MainMenuDlg.cpp | 335 -- src/smpackagee/MainMenuDlg.h | 85 - src/smpackagee/SMPackageInstallDlg.cpp | 469 --- src/smpackagee/SMPackageInstallDlg.h | 85 - src/smpackagee/SMPackageUtil.cpp | 302 -- src/smpackagee/ShowComment.cpp | 83 - src/smpackagee/ShowComment.h | 76 - src/smpackagee/SmpackageExportDlg.cpp | 605 ---- src/smpackagee/SmpackageExportDlg.h | 94 - src/smpackagee/StdAfx.cpp | 5 - src/smpackagee/StdAfx.h | 67 - src/smpackagee/TreeCtrlEx.cpp | 183 -- src/smpackagee/TreeCtrlEx.h | 51 - src/smpackagee/UninstallOld.cpp | 83 - src/smpackagee/UninstallOld.h | 52 - src/smpackagee/ZipArchive/Appnote.txt | 1351 -------- src/smpackagee/ZipArchive/ChangeLog.txt | 322 -- src/smpackagee/ZipArchive/License.txt | 73 - .../ZipArchive/Linux/ZipFileMapping.h | 61 - .../ZipArchive/Linux/ZipPathComponent.cpp | 87 - .../ZipArchive/Linux/ZipPlatform.cpp | 272 -- src/smpackagee/ZipArchive/Readme.txt | 645 ---- src/smpackagee/ZipArchive/StdAfx.cpp | 17 - src/smpackagee/ZipArchive/StdAfx.h | 48 - .../ZipArchive/Windows/ZipFileMapping.h | 69 - .../ZipArchive/Windows/ZipPathComponent.cpp | 72 - .../ZipArchive/Windows/ZipPlatform.cpp | 370 --- src/smpackagee/ZipArchive/ZipAbstractFile.h | 54 - .../ZipArchive/ZipArchive-net2003.vcproj | 1285 -------- .../ZipArchive/ZipArchive-net2008.vcproj | 1686 ---------- src/smpackagee/ZipArchive/ZipArchive.cpp | 2908 ----------------- src/smpackagee/ZipArchive/ZipArchive.dox | 221 -- src/smpackagee/ZipArchive/ZipArchive.h | 2070 ------------ src/smpackagee/ZipArchive/ZipArchive.rc | 109 - src/smpackagee/ZipArchive/ZipAutoBuffer.cpp | 102 - src/smpackagee/ZipArchive/ZipAutoBuffer.h | 67 - src/smpackagee/ZipArchive/ZipBaseException.h | 22 - src/smpackagee/ZipArchive/ZipCentralDir.cpp | 836 ----- src/smpackagee/ZipArchive/ZipCentralDir.h | 558 ---- src/smpackagee/ZipArchive/ZipCollections.h | 82 - .../ZipArchive/ZipCompatibility.cpp | 194 -- src/smpackagee/ZipArchive/ZipCompatibility.h | 107 - src/smpackagee/ZipArchive/ZipException.cpp | 285 -- src/smpackagee/ZipArchive/ZipException.h | 219 -- src/smpackagee/ZipArchive/ZipExport.h | 18 - src/smpackagee/ZipArchive/ZipFile.cpp | 53 - src/smpackagee/ZipArchive/ZipFile.h | 68 - src/smpackagee/ZipArchive/ZipFileHeader.cpp | 358 -- src/smpackagee/ZipArchive/ZipFileHeader.h | 344 -- src/smpackagee/ZipArchive/ZipFileMapping.h | 69 - src/smpackagee/ZipArchive/ZipMemFile.cpp | 102 - src/smpackagee/ZipArchive/ZipMemFile.h | 105 - .../ZipArchive/ZipPathComponent.cpp | 72 - src/smpackagee/ZipArchive/ZipPathComponent.h | 195 -- src/smpackagee/ZipArchive/ZipPlatform.cpp | 370 --- src/smpackagee/ZipArchive/ZipPlatform.h | 204 -- src/smpackagee/ZipArchive/ZipPlatformComm.cpp | 48 - src/smpackagee/ZipArchive/ZipStorage.cpp | 447 --- src/smpackagee/ZipArchive/ZipStorage.h | 579 ---- src/smpackagee/ZipArchive/ZipString.cpp | 28 - src/smpackagee/ZipArchive/ZipString.h | 37 - src/smpackagee/ZipArchive/__Windows_MFC.zcfg | 1 - .../ZipArchive/_copy_from_Win-MFC.bat | 5 - .../ZipArchive/_copy_from_Win-STL.bat | 5 - src/smpackagee/ZipArchive/_version.txt | 1 - src/smpackagee/ZipArchive/borland.zip | Bin 7568 -> 0 bytes src/smpackagee/ZipArchive/faq.txt | 212 -- src/smpackagee/ZipArchive/gpl.txt | 285 -- .../ZipArchive/mfc/ZipBaseException.h | 22 - .../ZipArchive/mfc/ZipCollections.h | 82 - src/smpackagee/ZipArchive/mfc/ZipFile.cpp | 53 - src/smpackagee/ZipArchive/mfc/ZipFile.h | 68 - src/smpackagee/ZipArchive/mfc/ZipString.h | 37 - src/smpackagee/ZipArchive/mfc/stdafx.h | 48 - src/smpackagee/ZipArchive/resource.h | 15 - .../ZipArchive/stl/ZipBaseException.h | 22 - .../ZipArchive/stl/ZipCollections.h | 163 - src/smpackagee/ZipArchive/stl/ZipFile.cpp | 109 - src/smpackagee/ZipArchive/stl/ZipFile.h | 115 - src/smpackagee/ZipArchive/stl/ZipString.h | 276 -- src/smpackagee/ZipArchive/stl/stdafx.h | 125 - .../ZipArchive/stl/zippie/CmdLine.cpp | 246 -- .../ZipArchive/stl/zippie/CmdLine.h | 234 -- .../ZipArchive/stl/zippie/zippie.cpp | 911 ------ .../ZipArchive/stl/zippie/zippie.dsp | 111 - .../ZipArchive/stl/zippie/zippie.dsw | 44 - .../ZipArchive/stl/zippie/zippie_DLL.dsp | 112 - .../ZipArchive/stl/zippie/zippie_DLL.dsw | 59 - src/smpackagee/res/smpackage.ico | Bin 1078 -> 0 bytes src/smpackagee/res/smpackage.rc2 | 13 - src/smpackagee/resource.h | 105 - src/smpackagee/smpackage.ICO | Bin 6006 -> 0 bytes src/smpackagee/smpackage.clw | 321 -- src/smpackagee/smpackage.cpp | 197 -- src/smpackagee/smpackage.h | 70 - src/smpackagee/smpackage.rc | 499 --- src/smpackagee/smpackageUtil.h | 85 - 110 files changed, 26382 deletions(-) delete mode 100644 src/ircc/appveyor.cpp delete mode 100644 src/smpackagee/ChangeGameSettings.cpp delete mode 100644 src/smpackagee/ChangeGameSettings.h delete mode 100644 src/smpackagee/CreateLanguageDlg.cpp delete mode 100644 src/smpackagee/CreateLanguageDlg.h delete mode 100644 src/smpackagee/EditInsallations.cpp delete mode 100644 src/smpackagee/EditInsallations.h delete mode 100644 src/smpackagee/EnterComment.cpp delete mode 100644 src/smpackagee/EnterComment.h delete mode 100644 src/smpackagee/EnterName.cpp delete mode 100644 src/smpackagee/EnterName.h delete mode 100644 src/smpackagee/LanguagesDlg.cpp delete mode 100644 src/smpackagee/LanguagesDlg.h delete mode 100644 src/smpackagee/MainMenuDlg.cpp delete mode 100644 src/smpackagee/MainMenuDlg.h delete mode 100644 src/smpackagee/SMPackageInstallDlg.cpp delete mode 100644 src/smpackagee/SMPackageInstallDlg.h delete mode 100644 src/smpackagee/SMPackageUtil.cpp delete mode 100644 src/smpackagee/ShowComment.cpp delete mode 100644 src/smpackagee/ShowComment.h delete mode 100644 src/smpackagee/SmpackageExportDlg.cpp delete mode 100644 src/smpackagee/SmpackageExportDlg.h delete mode 100644 src/smpackagee/StdAfx.cpp delete mode 100644 src/smpackagee/StdAfx.h delete mode 100644 src/smpackagee/TreeCtrlEx.cpp delete mode 100644 src/smpackagee/TreeCtrlEx.h delete mode 100644 src/smpackagee/UninstallOld.cpp delete mode 100644 src/smpackagee/UninstallOld.h delete mode 100644 src/smpackagee/ZipArchive/Appnote.txt delete mode 100644 src/smpackagee/ZipArchive/ChangeLog.txt delete mode 100644 src/smpackagee/ZipArchive/License.txt delete mode 100644 src/smpackagee/ZipArchive/Linux/ZipFileMapping.h delete mode 100644 src/smpackagee/ZipArchive/Linux/ZipPathComponent.cpp delete mode 100644 src/smpackagee/ZipArchive/Linux/ZipPlatform.cpp delete mode 100644 src/smpackagee/ZipArchive/Readme.txt delete mode 100644 src/smpackagee/ZipArchive/StdAfx.cpp delete mode 100644 src/smpackagee/ZipArchive/StdAfx.h delete mode 100644 src/smpackagee/ZipArchive/Windows/ZipFileMapping.h delete mode 100644 src/smpackagee/ZipArchive/Windows/ZipPathComponent.cpp delete mode 100644 src/smpackagee/ZipArchive/Windows/ZipPlatform.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipAbstractFile.h delete mode 100644 src/smpackagee/ZipArchive/ZipArchive-net2003.vcproj delete mode 100644 src/smpackagee/ZipArchive/ZipArchive-net2008.vcproj delete mode 100644 src/smpackagee/ZipArchive/ZipArchive.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipArchive.dox delete mode 100644 src/smpackagee/ZipArchive/ZipArchive.h delete mode 100644 src/smpackagee/ZipArchive/ZipArchive.rc delete mode 100644 src/smpackagee/ZipArchive/ZipAutoBuffer.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipAutoBuffer.h delete mode 100644 src/smpackagee/ZipArchive/ZipBaseException.h delete mode 100644 src/smpackagee/ZipArchive/ZipCentralDir.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipCentralDir.h delete mode 100644 src/smpackagee/ZipArchive/ZipCollections.h delete mode 100644 src/smpackagee/ZipArchive/ZipCompatibility.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipCompatibility.h delete mode 100644 src/smpackagee/ZipArchive/ZipException.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipException.h delete mode 100644 src/smpackagee/ZipArchive/ZipExport.h delete mode 100644 src/smpackagee/ZipArchive/ZipFile.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipFile.h delete mode 100644 src/smpackagee/ZipArchive/ZipFileHeader.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipFileHeader.h delete mode 100644 src/smpackagee/ZipArchive/ZipFileMapping.h delete mode 100644 src/smpackagee/ZipArchive/ZipMemFile.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipMemFile.h delete mode 100644 src/smpackagee/ZipArchive/ZipPathComponent.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipPathComponent.h delete mode 100644 src/smpackagee/ZipArchive/ZipPlatform.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipPlatform.h delete mode 100644 src/smpackagee/ZipArchive/ZipPlatformComm.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipStorage.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipStorage.h delete mode 100644 src/smpackagee/ZipArchive/ZipString.cpp delete mode 100644 src/smpackagee/ZipArchive/ZipString.h delete mode 100644 src/smpackagee/ZipArchive/__Windows_MFC.zcfg delete mode 100644 src/smpackagee/ZipArchive/_copy_from_Win-MFC.bat delete mode 100644 src/smpackagee/ZipArchive/_copy_from_Win-STL.bat delete mode 100644 src/smpackagee/ZipArchive/_version.txt delete mode 100644 src/smpackagee/ZipArchive/borland.zip delete mode 100644 src/smpackagee/ZipArchive/faq.txt delete mode 100644 src/smpackagee/ZipArchive/gpl.txt delete mode 100644 src/smpackagee/ZipArchive/mfc/ZipBaseException.h delete mode 100644 src/smpackagee/ZipArchive/mfc/ZipCollections.h delete mode 100644 src/smpackagee/ZipArchive/mfc/ZipFile.cpp delete mode 100644 src/smpackagee/ZipArchive/mfc/ZipFile.h delete mode 100644 src/smpackagee/ZipArchive/mfc/ZipString.h delete mode 100644 src/smpackagee/ZipArchive/mfc/stdafx.h delete mode 100644 src/smpackagee/ZipArchive/resource.h delete mode 100644 src/smpackagee/ZipArchive/stl/ZipBaseException.h delete mode 100644 src/smpackagee/ZipArchive/stl/ZipCollections.h delete mode 100644 src/smpackagee/ZipArchive/stl/ZipFile.cpp delete mode 100644 src/smpackagee/ZipArchive/stl/ZipFile.h delete mode 100644 src/smpackagee/ZipArchive/stl/ZipString.h delete mode 100644 src/smpackagee/ZipArchive/stl/stdafx.h delete mode 100644 src/smpackagee/ZipArchive/stl/zippie/CmdLine.cpp delete mode 100644 src/smpackagee/ZipArchive/stl/zippie/CmdLine.h delete mode 100644 src/smpackagee/ZipArchive/stl/zippie/zippie.cpp delete mode 100644 src/smpackagee/ZipArchive/stl/zippie/zippie.dsp delete mode 100644 src/smpackagee/ZipArchive/stl/zippie/zippie.dsw delete mode 100644 src/smpackagee/ZipArchive/stl/zippie/zippie_DLL.dsp delete mode 100644 src/smpackagee/ZipArchive/stl/zippie/zippie_DLL.dsw delete mode 100644 src/smpackagee/res/smpackage.ico delete mode 100644 src/smpackagee/res/smpackage.rc2 delete mode 100644 src/smpackagee/resource.h delete mode 100644 src/smpackagee/smpackage.ICO delete mode 100644 src/smpackagee/smpackage.clw delete mode 100644 src/smpackagee/smpackage.cpp delete mode 100644 src/smpackagee/smpackage.h delete mode 100644 src/smpackagee/smpackage.rc delete mode 100644 src/smpackagee/smpackageUtil.h diff --git a/src/ircc/appveyor.cpp b/src/ircc/appveyor.cpp deleted file mode 100644 index 5994f13984..0000000000 --- a/src/ircc/appveyor.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include -#include -#pragma comment(lib, "ws2_32.lib") - -#include -#include -#include -#include - -char const* owner = "wolfman2000"; -char const* nick = "appveyor-sm5"; -char const* server = "irc.freenode.net"; -char const* channel = "#stepmania"; - -bool -startsWithPing(char const* buffer) -{ - return std::strncmp(buffer, "PING ", 5) == 0; -} - -int -main(int argc, char* argv[]) -{ - // The common return value. - int ret; - // Set up the buffer. - char buffer[512]; - - auto* repoName = argv[1]; - auto* repoVersion = argv[2]; - auto* repoHash = argv[3]; - auto* repoAuthor = argv[4]; - auto* repoBuildUrl = argv[5]; - auto* repoSuccess = argv[6]; - - SOCKET sock; - struct WSAData* wd = (struct WSAData*)malloc(sizeof(struct WSAData)); - ret = WSAStartup(MAKEWORD(2, 0), wd); - free(wd); - - if (ret) { - std::cout << "Error loading Windows Socket API" << std::endl; - return 1; - } - - struct addrinfo hints; - struct addrinfo* ai; - - // Ensure the hints are cleared. - memset(&hints, 0, sizeof(struct addrinfo)); - // IPv4 vs IPv6: should not matter. - hints.ai_family = AF_UNSPEC; - // IRC uses TCP sockets. - hints.ai_socktype = SOCK_STREAM; - // Be explicit about TCP. - hints.ai_protocol = IPPROTO_TCP; - - ret = getaddrinfo(server, "6667", &hints, &ai); - if (ret != 0) { - std::cout << "Problem with getting the server information!" - << std::endl; - return 2; - } - - sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); - if (sock == -1) { - std::cout << "Problem with setting up the socket!" << std::endl; - return 3; - } - - ret = connect(sock, ai->ai_addr, ai->ai_addrlen); - if (ret == -1) { - std::cout << "Problem with connecting to the IRC server!" << std::endl; - } - - // The server data is not needed anymore. - freeaddrinfo(ai); - - // Start some of the basic commands. - std::sprintf(buffer, "USER %s 0 * :%s\r\n", nick, owner); - send(sock, buffer, strlen(buffer), 0); - std::sprintf(buffer, "NICK %s\r\n", nick); - send(sock, buffer, strlen(buffer), 0); - - // Respect the continuous loop. - for (;;) { - // receive the bytes as we get them. - int numBytes = recv(sock, buffer, 511, 0); - if (numBytes <= 0) { - // We have quit IRC. Get out of here. - break; - } - buffer[numBytes] = '\0'; // Ensure a null terminated string. - if (startsWithPing(buffer)) { - // We MUST reply to a PING with PONG. Otherwise, we get booted off. - buffer[1] = 'O'; - send(sock, buffer, strlen(buffer), 0); - } - // System commands should have a colon. - if (buffer[0] != ':') { - continue; - } - - // Only join once we have a 001. This indicates it's safe. - if (std::strncmp(std::strchr(buffer, ' ') + 1, "001", 3)) { - std::sprintf(buffer, "JOIN %s\r\n", channel); - send(sock, buffer, strlen(buffer), 0); - continue; - } - if (std::strncmp(std::strchr(buffer, ' ') + 1, "366", 3)) { - if (std::strncmp(repoSuccess, "success", 7) == 0) { - std::sprintf(buffer, - "PRIVMSG %s :AppVeyor build report for fork %s, " - "build %s, commit %s by %s: Compiles on " - "Windows!\r\n", - channel, - repoName, - repoVersion, - repoHash, - repoAuthor); - } else { - std::sprintf(buffer, - "PRIVMSG %s :AppVeyor build report for fork %s, " - "build %s, commit %s by %s: Did not compile on " - "Windows!\r\n", - channel, - repoName, - repoVersion, - repoHash, - repoAuthor); - } - send(sock, buffer, strlen(buffer), 0); - std::this_thread::sleep_for(std::chrono::milliseconds(200)); - - std::sprintf( - buffer, "PRIVMSG %s :Build Log: %s\r\n", channel, repoBuildUrl); - send(sock, buffer, strlen(buffer), 0); - std::this_thread::sleep_for(std::chrono::milliseconds(200)); - - std::sprintf(buffer, "QUIT Bye bye now.\r\n"); - send(sock, buffer, strlen(buffer), 0); - std::this_thread::sleep_for(std::chrono::milliseconds(200)); - } - } - - closesocket(sock); - WSACleanup(); - - return 0; -} diff --git a/src/smpackagee/ChangeGameSettings.cpp b/src/smpackagee/ChangeGameSettings.cpp deleted file mode 100644 index e7a7cdcba4..0000000000 --- a/src/smpackagee/ChangeGameSettings.cpp +++ /dev/null @@ -1,191 +0,0 @@ -// ChangeGameSettings.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "ChangeGameSettings.h" -#include "IniFile.h" -#include "SMPackageUtil.h" -#include "SpecialFiles.h" -#include ".\changegamesettings.h" -#include "archutils/Win32/DialogUtil.h" -#include "LocalizedString.h" -#include "RageUtil.h" -#include "arch/Dialog/Dialog.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// ChangeGameSettings dialog - -ChangeGameSettings::ChangeGameSettings(CWnd* pParent /*=NULL*/) - : CDialog(ChangeGameSettings::IDD, pParent) -{ - //{{AFX_DATA_INIT(ChangeGameSettings) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void -ChangeGameSettings::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ChangeGameSettings) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(ChangeGameSettings, CDialog) -//{{AFX_MSG_MAP(ChangeGameSettings) -//}}AFX_MSG_MAP -ON_WM_CTLCOLOR() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ChangeGameSettings message handlers - -BOOL -ChangeGameSettings::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - - // - // Fill the radio buttons - // - IniFile ini; - ini.ReadFile(SpecialFiles::PREFERENCES_INI_PATH); - - RString sValue; - - // video renderers - sValue = ""; - ini.GetValue("Options", "VideoRenderers", sValue); - if (sValue.CompareNoCase("opengl") == 0) - CheckDlgButton(IDC_RADIO_OPENGL, BST_CHECKED); - else if (sValue.CompareNoCase("d3d") == 0) - CheckDlgButton(IDC_RADIO_DIRECT3D, BST_CHECKED); - else - CheckDlgButton(IDC_RADIO_DEFAULT, BST_CHECKED); - - // sound drivers - sValue = ""; - ini.GetValue("Options", "SoundDrivers", sValue); - if (sValue.CompareNoCase("DirectSound") == 0) - CheckDlgButton(IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE, BST_CHECKED); - else if (sValue.CompareNoCase("DirectSound-sw") == 0) - CheckDlgButton(IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE, BST_CHECKED); - else if (sValue.CompareNoCase("WaveOut") == 0) - CheckDlgButton(IDC_RADIO_SOUND_WAVEOUT, BST_CHECKED); - else if (sValue.CompareNoCase("null") == 0) - CheckDlgButton(IDC_RADIO_SOUND_NULL, BST_CHECKED); - else - CheckDlgButton(IDC_RADIO_SOUND_DEFAULT, BST_CHECKED); - - { - int iValue = 0; - ini.GetValue("Options", "RefreshRate", iValue); - CheckDlgButton(IDC_CHECK_FORCE_60HZ, - iValue == 60 ? BST_CHECKED : BST_UNCHECKED); - } - { - bool bValue = false; - ini.GetValue("Options", "LogToDisk", bValue); - CheckDlgButton(IDC_CHECK_LOG_TO_DISK, - bValue ? BST_CHECKED : BST_UNCHECKED); - } - { - bool bValue = false; - ini.GetValue("Options", "ShowLogOutput", bValue); - CheckDlgButton(IDC_CHECK_SHOW_LOG_WINDOW, - bValue ? BST_CHECKED : BST_UNCHECKED); - } - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -static LocalizedString ERROR_WRITING_FILE("ChangeGameSettings", - "Error writing file '%s': %s"); -void -ChangeGameSettings::OnOK() -{ - // TODO: Add extra validation here - IniFile ini; - ini.ReadFile(SpecialFiles::PREFERENCES_INI_PATH); - - if (BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_OPENGL)) - ini.SetValue("Options", "VideoRenderers", (RString) "opengl"); - else if (BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_DIRECT3D)) - ini.SetValue("Options", "VideoRenderers", (RString) "d3d"); - else - ini.SetValue("Options", "VideoRenderers", RString()); - - if (BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE)) - ini.SetValue("Options", "SoundDrivers", (RString) "DirectSound"); - else if (BST_CHECKED == - IsDlgButtonChecked(IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE)) - ini.SetValue("Options", "SoundDrivers", (RString) "DirectSound-sw"); - else if (BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_WAVEOUT)) - ini.SetValue("Options", "SoundDrivers", (RString) "WaveOut"); - else if (BST_CHECKED == IsDlgButtonChecked(IDC_RADIO_SOUND_NULL)) - ini.SetValue("Options", "SoundDrivers", (RString) "null"); - else - ini.SetValue("Options", "SoundDrivers", RString()); - - if (BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_FORCE_60HZ)) { - ini.SetValue("Options", "RefreshRate", 60); - } else { - int iRefresh = 0; - ini.GetValue("Options", "RefreshRate", iRefresh); - if (iRefresh == 60) - ini.SetValue("Options", "RefreshRate", 0); - } - ini.SetValue("Options", - "LogToDisk", - BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_LOG_TO_DISK)); - ini.SetValue("Options", - "ShowLogOutput", - BST_CHECKED == IsDlgButtonChecked(IDC_CHECK_SHOW_LOG_WINDOW)); - - if (!ini.WriteFile(SpecialFiles::PREFERENCES_INI_PATH)) { - RString sError = ssprintf(ERROR_WRITING_FILE.GetValue(), - SpecialFiles::PREFERENCES_INI_PATH.c_str(), - ini.GetError().c_str()); - Dialog::OK(sError); - } - - CDialog::OnOK(); -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/ChangeGameSettings.h b/src/smpackagee/ChangeGameSettings.h deleted file mode 100644 index 559a5e639a..0000000000 --- a/src/smpackagee/ChangeGameSettings.h +++ /dev/null @@ -1,76 +0,0 @@ -#if !defined( \ - AFX_CHANGEGAMESETTINGS_H__BFA59E6F_E70A_49A7_90A6_F04D3C321CA6__INCLUDED_) -#define AFX_CHANGEGAMESETTINGS_H__BFA59E6F_E70A_49A7_90A6_F04D3C321CA6__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// ChangeGameSettings.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// ChangeGameSettings dialog - -class ChangeGameSettings : public CDialog -{ - // Construction - public: - ChangeGameSettings(CWnd* pParent = NULL); // standard constructor - - // Dialog Data - //{{AFX_DATA(ChangeGameSettings) - enum - { - IDD = IDD_CHANGE_GAME_SETTINGS - }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ChangeGameSettings) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - // Generated message map functions - //{{AFX_MSG(ChangeGameSettings) - virtual BOOL OnInitDialog(); - virtual void OnOK(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - public: -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_CHANGEGAMESETTINGS_H__BFA59E6F_E70A_49A7_90A6_F04D3C321CA6__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/CreateLanguageDlg.cpp b/src/smpackagee/CreateLanguageDlg.cpp deleted file mode 100644 index c1c545420f..0000000000 --- a/src/smpackagee/CreateLanguageDlg.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// CreateLanguageDlg.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "CreateLanguageDlg.h" -#include "Foreach.h" -#include "RageUtil.h" -#include "SMPackageUtil.h" -#include ".\createlanguagedlg.h" -#include "archutils/Win32/DialogUtil.h" -#include "archutils/Win32/ErrorStrings.h" - -// CreateLanguageDlg dialog - -IMPLEMENT_DYNAMIC(CreateLanguageDlg, CDialog) -CreateLanguageDlg::CreateLanguageDlg(CWnd* pParent /*=NULL*/) - : CDialog(CreateLanguageDlg::IDD, pParent) -{ -} - -CreateLanguageDlg::~CreateLanguageDlg() {} - -void -CreateLanguageDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_COMBO_LANGUAGES, m_comboLanguages); -} - -static const char* const g_aListedLanguageCodes[] = { - "ab", "af", "ar", "az", "be", "bg", "ca", "cs", "cy", "da", "de", "el", - "en", "es", "et", "eu", "fa", "fi", "fr", "ga", "gl", "ha", "he", "hi", - "hr", "hu", "hy", "id", "in", "is", "it", "iw", "ja", "kk", "kn", "ko", - "ky", "lt", "lv", "mk", "ms", "mt", "nl", "no", "pl", "ps", "pt", "rn", - "ro", "ru", "rw", "sk", "sl", "so", "sq", "sr", "sv", "sw", "te", "th", - "tr", "uk", "ur", "uz", "vi", "wo", "xh", "yo", "zh", "zu", -}; - -BOOL -CreateLanguageDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - - for (int i = 0; i < ARRAYLEN(g_aListedLanguageCodes); ++i) { - RString s = - SMPackageUtil::GetLanguageDisplayString(g_aListedLanguageCodes[i]); - RString sLanguage = ConvertUTF8ToACP(s); - m_comboLanguages.AddString(sLanguage); - } - m_comboLanguages.SetCurSel(0); - return TRUE; // return TRUE unless you set the focus to a control -} - -BEGIN_MESSAGE_MAP(CreateLanguageDlg, CDialog) -ON_BN_CLICKED(IDOK, OnBnClickedOk) -END_MESSAGE_MAP() - -void -CreateLanguageDlg::OnBnClickedOk() -{ - // TODO: Add your control notification handler code here - - int iIndex = m_comboLanguages.GetCurSel(); - ASSERT(iIndex != LB_ERR); - - m_sChosenLanguageCode = g_aListedLanguageCodes[iIndex]; - - OnOK(); -} diff --git a/src/smpackagee/CreateLanguageDlg.h b/src/smpackagee/CreateLanguageDlg.h deleted file mode 100644 index 3a928a71df..0000000000 --- a/src/smpackagee/CreateLanguageDlg.h +++ /dev/null @@ -1,33 +0,0 @@ -#pragma once -#include "afxwin.h" - -// CreateLanguageDlg dialog - -class CreateLanguageDlg : public CDialog -{ - DECLARE_DYNAMIC(CreateLanguageDlg) - - public: - CreateLanguageDlg(CWnd* pParent = NULL); // standard constructor - virtual ~CreateLanguageDlg(); - - // Dialog Data - enum - { - IDD = IDD_CREATE_LANGUAGE - }; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - // Generated message map functions - //{{AFX_MSG(CreateLanguageDlg) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - public: - CComboBox m_comboLanguages; - afx_msg void OnBnClickedOk(); - - CString m_sChosenLanguageCode; -}; diff --git a/src/smpackagee/EditInsallations.cpp b/src/smpackagee/EditInsallations.cpp deleted file mode 100644 index 1957f97685..0000000000 --- a/src/smpackagee/EditInsallations.cpp +++ /dev/null @@ -1,190 +0,0 @@ -// EditInsallations.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "EditInsallations.h" -#include "SMPackageUtil.h" -#include "archutils/Win32/DialogUtil.h" -#include ".\editinsallations.h" -#include "LocalizedString.h" -#include "RageFileManager.h" -#include "RageUtil.h" -#include "arch/Dialog/Dialog.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// EditInsallations dialog - -EditInsallations::EditInsallations(CWnd* pParent /*=NULL*/) - : CDialog(EditInsallations::IDD, pParent) -{ - //{{AFX_DATA_INIT(EditInsallations) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void -EditInsallations::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EditInsallations) - DDX_Control(pDX, IDC_LIST, m_list); - DDX_Control(pDX, IDC_EDIT, m_edit); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(EditInsallations, CDialog) -//{{AFX_MSG_MAP(EditInsallations) -ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove) -ON_BN_CLICKED(IDC_BUTTON_MAKE_DEFAULT, OnButtonMakeDefault) -ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd) -//}}AFX_MSG_MAP -ON_LBN_SELCHANGE(IDC_LIST, OnLbnSelchangeList) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// EditInsallations message handlers - -BOOL -EditInsallations::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - - vector vs; - SMPackageUtil::GetGameInstallDirs(vs); - for (unsigned i = 0; i < vs.size(); i++) - m_list.AddString(vs[i]); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void -EditInsallations::OnButtonRemove() -{ - // TODO: Add your control notification handler code here - ASSERT(m_list.GetCount() > 1); // cannot remove the list item in the list - ASSERT(m_list.GetCurSel() != LB_ERR); - - m_list.DeleteString(m_list.GetCurSel()); - OnLbnSelchangeList(); -} - -void -EditInsallations::OnButtonMakeDefault() -{ - // TODO: Add your control notification handler code here - ASSERT(m_list.GetCurSel() != LB_ERR); - - CString sText; - m_list.GetText(m_list.GetCurSel(), sText); - m_list.DeleteString(m_list.GetCurSel()); - m_list.InsertString(0, sText); - m_list.SetCurSel(0); -} - -static LocalizedString YOU_MUST_TYPE_IN( - "EditInstallations", - "You must type a program directory before clicking Add."); -static LocalizedString NOT_A_VALID_INSTALLATION_DIR( - "EditInstallations", - "'%s' is not a valid installation directory."); -void -EditInsallations::OnButtonAdd() -{ - // TODO: Add your control notification handler code here - RString sNewDir; - { - CString s; - m_edit.GetWindowText(s); - sNewDir = s; - } - - if (sNewDir == "") { - Dialog::OK(YOU_MUST_TYPE_IN.GetValue()); - return; - } - - bool bAlreadyInList = false; - for (int i = 0; i < m_list.GetCount(); i++) { - CString sDir; - m_list.GetText(i, sDir); - if (sDir.CompareNoCase(sNewDir) == 0) - return; - } - - if (!SMPackageUtil::IsValidInstallDir(sNewDir)) { - Dialog::OK( - ssprintf(NOT_A_VALID_INSTALLATION_DIR.GetValue(), sNewDir.c_str())); - return; - } - - m_list.AddString(sNewDir); -} - -void -EditInsallations::OnOK() -{ - vector vs; - - for (int i = 0; i < m_list.GetCount(); i++) { - CString sDir; - m_list.GetText(i, sDir); - RString s = sDir; - vs.push_back(s); - } - SMPackageUtil::WriteGameInstallDirs(vs); - - // set the new default - vector asInstallDirs; - SMPackageUtil::GetGameInstallDirs(asInstallDirs); - FILEMAN->Remount("/", asInstallDirs[0]); - - CDialog::OnOK(); -} - -void -EditInsallations::OnLbnSelchangeList() -{ - // TODO: Add your control notification handler code here - bool bSomethingSelected = m_list.GetCurSel() != LB_ERR; - bool bMoreThanOne = m_list.GetCount() > 1; - - this->GetDlgItem(IDC_BUTTON_MAKE_DEFAULT)->EnableWindow(bSomethingSelected); - this->GetDlgItem(IDC_BUTTON_REMOVE)->EnableWindow(bMoreThanOne); -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/EditInsallations.h b/src/smpackagee/EditInsallations.h deleted file mode 100644 index 14d1815535..0000000000 --- a/src/smpackagee/EditInsallations.h +++ /dev/null @@ -1,80 +0,0 @@ -#if !defined( \ - AFX_EDITINSALLATIONS_H__CD328CB4_8E35_4B12_BCD1_ADF5CE7EABC7__INCLUDED_) -#define AFX_EDITINSALLATIONS_H__CD328CB4_8E35_4B12_BCD1_ADF5CE7EABC7__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// EditInsallations.h : header file - -///////////////////////////////////////////////////////////////////////////// -// EditInsallations dialog - -class EditInsallations : public CDialog -{ - // Construction - public: - EditInsallations(CWnd* pParent = NULL); // standard constructor - - // Dialog Data - //{{AFX_DATA(EditInsallations) - enum - { - IDD = IDD_EDIT_INSTALLATIONS - }; - CListBox m_list; - CEdit m_edit; - //}}AFX_DATA - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EditInsallations) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - // Generated message map functions - //{{AFX_MSG(EditInsallations) - virtual BOOL OnInitDialog(); - afx_msg void OnButtonRemove(); - afx_msg void OnButtonMakeDefault(); - afx_msg void OnButtonAdd(); - virtual void OnOK(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - public: - afx_msg void OnLbnSelchangeList(); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_EDITINSALLATIONS_H__CD328CB4_8E35_4B12_BCD1_ADF5CE7EABC7__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/EnterComment.cpp b/src/smpackagee/EnterComment.cpp deleted file mode 100644 index e43f09afa4..0000000000 --- a/src/smpackagee/EnterComment.cpp +++ /dev/null @@ -1,109 +0,0 @@ -// EnterComment.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "EnterComment.h" -#include "archutils/Win32/DialogUtil.h" -#include ".\entercomment.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// EnterComment dialog - -EnterComment::EnterComment(CWnd* pParent /*=NULL*/) - : CDialog(EnterComment::IDD, pParent) - , m_bDontAsk(FALSE) - , m_bShowAComment(FALSE) -{ - //{{AFX_DATA_INIT(EnterComment) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void -EnterComment::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EnterComment) - DDX_Control(pDX, IDC_EDIT, m_edit); - //}}AFX_DATA_MAP - DDX_Check(pDX, IDC_DONTASK, m_bDontAsk); - DDX_Check(pDX, IDC_SHOW_A_COMMENT, m_bShowAComment); -} - -BOOL -EnterComment::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - - OnBnClickedShowAComment(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -BEGIN_MESSAGE_MAP(EnterComment, CDialog) -//{{AFX_MSG_MAP(EnterComment) -//}}AFX_MSG_MAP -ON_BN_CLICKED(IDC_SHOW_A_COMMENT, OnBnClickedShowAComment) -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// EnterComment message handlers - -void -EnterComment::OnOK() -{ - // TODO: Add extra validation here - - UpdateData(TRUE); - - if (m_bShowAComment) - m_edit.GetWindowText(m_sEnteredComment); - - CDialog::OnOK(); -} - -void -EnterComment::OnBnClickedShowAComment() -{ - UpdateData(TRUE); - - // TODO: Add your control notification handler code here - GetDlgItem(IDC_EDIT)->EnableWindow(m_bShowAComment); -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ \ No newline at end of file diff --git a/src/smpackagee/EnterComment.h b/src/smpackagee/EnterComment.h deleted file mode 100644 index e893744069..0000000000 --- a/src/smpackagee/EnterComment.h +++ /dev/null @@ -1,81 +0,0 @@ -#include "afxwin.h" -#if !defined( \ - AFX_ENTERCOMMENT_H__DE628EA8_0FE7_4594_B2A2_47BDB283FA1E__INCLUDED_) -#define AFX_ENTERCOMMENT_H__DE628EA8_0FE7_4594_B2A2_47BDB283FA1E__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// EnterComment.h : header file - -///////////////////////////////////////////////////////////////////////////// -// EnterComment dialog - -class EnterComment : public CDialog -{ - // Construction - public: - EnterComment(CWnd* pParent = NULL); // standard constructor - - CString m_sEnteredComment; - - // Dialog Data - //{{AFX_DATA(EnterComment) - enum - { - IDD = IDD_ENTER_COMMENT - }; - CEdit m_edit; - //}}AFX_DATA - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EnterComment) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - // Generated message map functions - //{{AFX_MSG(EnterComment) - virtual void OnOK(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - public: - BOOL m_bDontAsk; - BOOL m_bShowAComment; - afx_msg void OnBnClickedShowAComment(); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_ENTERCOMMENT_H__DE628EA8_0FE7_4594_B2A2_47BDB283FA1E__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/EnterName.cpp b/src/smpackagee/EnterName.cpp deleted file mode 100644 index a3a106b847..0000000000 --- a/src/smpackagee/EnterName.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// EnterName.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "EnterName.h" -#include "archutils/Win32/DialogUtil.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// EnterName dialog - -EnterName::EnterName(CWnd* pParent /*=NULL*/) - : CDialog(EnterName::IDD, pParent) -{ - //{{AFX_DATA_INIT(EnterName) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void -EnterName::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(EnterName) - DDX_Control(pDX, IDC_EDIT, m_edit); - //}}AFX_DATA_MAP -} - -BOOL -EnterName::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -BEGIN_MESSAGE_MAP(EnterName, CDialog) -//{{AFX_MSG_MAP(EnterName) -//}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// EnterName message handlers - -void -EnterName::OnOK() -{ - // TODO: Add extra validation here - m_edit.GetWindowText(m_sEnteredName); - - CDialog::OnOK(); -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/EnterName.h b/src/smpackagee/EnterName.h deleted file mode 100644 index bd98b8025f..0000000000 --- a/src/smpackagee/EnterName.h +++ /dev/null @@ -1,75 +0,0 @@ -#if !defined(AFX_ENTERNAME_H__0AB99274_EB79_4A25_B95C_627E0A99C6BA__INCLUDED_) -#define AFX_ENTERNAME_H__0AB99274_EB79_4A25_B95C_627E0A99C6BA__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// EnterName.h : header file - -///////////////////////////////////////////////////////////////////////////// -// EnterName dialog - -class EnterName : public CDialog -{ - // Construction - public: - EnterName(CWnd* pParent = NULL); // standard constructor - - CString m_sEnteredName; - - // Dialog Data - //{{AFX_DATA(EnterName) - enum - { - IDD = IDD_DIALOG_NAME - }; - CEdit m_edit; - //}}AFX_DATA - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(EnterName) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - // Generated message map functions - //{{AFX_MSG(EnterName) - virtual void OnOK(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_ENTERNAME_H__0AB99274_EB79_4A25_B95C_627E0A99C6BA__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/LanguagesDlg.cpp b/src/smpackagee/LanguagesDlg.cpp deleted file mode 100644 index d4f3872df2..0000000000 --- a/src/smpackagee/LanguagesDlg.cpp +++ /dev/null @@ -1,684 +0,0 @@ -// LanguagesDlg.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "Foreach.h" -#include "LanguagesDlg.h" -#include "SpecialFiles.h" -#include "RageUtil.h" -#include "IniFile.h" -#include "languagesdlg.h" -#include "SMPackageUtil.h" -#include "CreateLanguageDlg.h" -#include "RageFile.h" -#include "languagesdlg.h" -#include "RageFileManager.h" -#include ".\languagesdlg.h" -#include "CsvFile.h" -#include "archutils/Win32/DialogUtil.h" -#include "LocalizedString.h" -#include "arch/Dialog/Dialog.h" -#include "archutils/Win32/SpecialDirs.h" -#include "archutils/Win32/GotoURL.h" -#include "archutils/Win32/ErrorStrings.h" - -// LanguagesDlg dialog - -IMPLEMENT_DYNAMIC(LanguagesDlg, CDialog) -LanguagesDlg::LanguagesDlg(CWnd* pParent /*=NULL*/) - : CDialog(LanguagesDlg::IDD, pParent) -{ -} - -LanguagesDlg::~LanguagesDlg() {} - -void -LanguagesDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - DDX_Control(pDX, IDC_LIST_THEMES, m_listThemes); - DDX_Control(pDX, IDC_LIST_LANGUAGES, m_listLanguages); - DDX_Control(pDX, - IDC_CHECK_EXPORT_ALREADY_TRANSLATED, - m_buttonExportAlreadyTranslated); -} - -BOOL -LanguagesDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - DialogUtil::LocalizeDialogAndContents(*this); - - vector vs; - GetDirListing(SpecialFiles::THEMES_DIR + "*", vs, true); - StripCvsAndSvn(vs); - FOREACH_CONST(RString, vs, s) - m_listThemes.AddString(*s); - if (!vs.empty()) - m_listThemes.SetSel(0); - - OnSelchangeListThemes(); - - return TRUE; // return TRUE unless you set the focus to a control -} - -static RString -GetCurrentString(const CListBox& list) -{ - // TODO: Add your control notification handler code here - int iSel = list.GetCurSel(); - if (iSel == LB_ERR) - return RString(); - CString s; - list.GetText(list.GetCurSel(), s); - return RString(s); -} - -static void -SelectString(CListBox& list, const RString& sToSelect) -{ - for (int i = 0; i < list.GetCount(); i++) { - CString s; - list.GetText(i, s); - if (s == sToSelect) { - list.SetCurSel(i); - break; - } - } -} - -void -LanguagesDlg::OnSelchangeListThemes() -{ - // TODO: Add your control notification handler code here - m_listLanguages.ResetContent(); - - RString sTheme = GetCurrentString(m_listThemes); - if (!sTheme.empty()) { - RString sLanguagesDir = SpecialFiles::THEMES_DIR + sTheme + "/" + - SpecialFiles::LANGUAGES_SUBDIR; - - vector vs; - GetDirListing(sLanguagesDir + "*.ini", vs, false); - FOREACH_CONST(RString, vs, s) - { - RString sIsoCode = GetFileNameWithoutExtension(*s); - RString sLanguage = - SMPackageUtil::GetLanguageDisplayString(sIsoCode); - m_listLanguages.AddString(ConvertUTF8ToACP(sLanguage)); - } - if (!vs.empty()) - m_listLanguages.SetSel(0); - } - - OnSelchangeListLanguages(); -} - -static RString -GetLanguageFile(const RString& sTheme, const RString& sLanguage) -{ - return SpecialFiles::THEMES_DIR + sTheme + "/" + - SpecialFiles::LANGUAGES_SUBDIR + sLanguage + ".ini"; -} - -static int -GetNumValuesInIniFile(const RString& sIniFile) -{ - int count = 0; - IniFile ini; - ini.ReadFile(sIniFile); - FOREACH_CONST_Child(&ini, key) { FOREACH_CONST_Attr(key, value) count++; } - return count; -} - -static int -GetNumIntersectingIniValues(const RString& sIniFile1, const RString& sIniFile2) -{ - int count = 0; - IniFile ini1; - ini1.ReadFile(sIniFile1); - IniFile ini2; - ini2.ReadFile(sIniFile2); - FOREACH_CONST_Child(&ini1, key1) - { - const XNode* key2 = ini2.GetChild(key1->m_sName); - if (key2 == NULL) - continue; - FOREACH_CONST_Attr(key1, attr1) - { - if (key2->GetAttr(attr1->first) == NULL) - continue; - count++; - } - } - return count; -} - -void -LanguagesDlg::OnSelchangeListLanguages() -{ - // TODO: Add your control notification handler code here - int iTotalStrings = -1; - int iNeedTranslation = -1; - - RString sTheme = GetCurrentString(m_listThemes); - RString sLanguage = GetCurrentString(m_listLanguages); - - if (!sTheme.empty()) { - RString sBaseLanguageFile = - GetLanguageFile(sTheme, SpecialFiles::BASE_LANGUAGE); - iTotalStrings = GetNumValuesInIniFile(sBaseLanguageFile); - - if (!sLanguage.empty()) { - sLanguage = - SMPackageUtil::GetLanguageCodeFromDisplayString(sLanguage); - - RString sLanguageFile = GetLanguageFile(sTheme, sLanguage); - iNeedTranslation = - iTotalStrings - - GetNumIntersectingIniValues(sBaseLanguageFile, sLanguageFile); - } - } - - GetDlgItem(IDC_STATIC_TOTAL_STRINGS) - ->SetWindowText(ssprintf(iTotalStrings == -1 ? "" : "%d", iTotalStrings)); - GetDlgItem(IDC_STATIC_NEED_TRANSLATION) - ->SetWindowText( - ssprintf(iNeedTranslation == -1 ? "" : "%d", iNeedTranslation)); - - GetDlgItem(IDC_BUTTON_CREATE)->EnableWindow(!sTheme.empty()); - GetDlgItem(IDC_BUTTON_DELETE)->EnableWindow(!sLanguage.empty()); - GetDlgItem(IDC_BUTTON_EXPORT)->EnableWindow(!sLanguage.empty()); - GetDlgItem(IDC_BUTTON_IMPORT)->EnableWindow(!sLanguage.empty()); - GetDlgItem(IDC_CHECK_LANGUAGE)->EnableWindow(!sLanguage.empty()); - GetDlgItem(IDC_CHECK_EXPORT_ALREADY_TRANSLATED) - ->EnableWindow(!sLanguage.empty()); -} - -BEGIN_MESSAGE_MAP(LanguagesDlg, CDialog) -ON_LBN_SELCHANGE(IDC_LIST_THEMES, OnSelchangeListThemes) -ON_LBN_SELCHANGE(IDC_LIST_LANGUAGES, OnSelchangeListLanguages) -ON_BN_CLICKED(IDC_BUTTON_CREATE, OnBnClickedButtonCreate) -ON_BN_CLICKED(IDC_BUTTON_DELETE, OnBnClickedButtonDelete) -ON_BN_CLICKED(IDC_BUTTON_EXPORT, OnBnClickedButtonExport) -ON_BN_CLICKED(IDC_BUTTON_IMPORT, OnBnClickedButtonImport) -ON_BN_CLICKED(IDC_CHECK_LANGUAGE, OnBnClickedCheckLanguage) -END_MESSAGE_MAP() - -// LanguagesDlg message handlers - -void -LanguagesDlg::OnBnClickedButtonCreate() -{ - // TODO: Add your control notification handler code here - CreateLanguageDlg dlg; - int nResponse = dlg.DoModal(); - if (nResponse != IDOK) - return; - - RString sTheme = GetCurrentString(m_listThemes); - ASSERT(!sTheme.empty()); - - RString sLanguageFile = - GetLanguageFile(sTheme, RString(dlg.m_sChosenLanguageCode)); - - // create empty file - RageFile file; - file.Open(sLanguageFile, RageFile::WRITE); - file.Close(); // flush file - - OnSelchangeListThemes(); - SelectString(m_listLanguages, - SMPackageUtil::GetLanguageDisplayString( - RString(dlg.m_sChosenLanguageCode))); - OnSelchangeListLanguages(); -} - -static LocalizedString THIS_WILL_PERMANENTLY_DELETE( - "LanguagesDlg", - "This will permanently delete '%s'. Continue?"); -void -LanguagesDlg::OnBnClickedButtonDelete() -{ - // TODO: Add your control notification handler code here - RString sTheme = GetCurrentString(m_listThemes); - ASSERT(!sTheme.empty()); - RString sLanguage = GetCurrentString(m_listLanguages); - ASSERT(!sLanguage.empty()); - sLanguage = SMPackageUtil::GetLanguageCodeFromDisplayString(sLanguage); - - RString sLanguageFile = GetLanguageFile(sTheme, sLanguage); - - RString sMessage = - ssprintf(THIS_WILL_PERMANENTLY_DELETE.GetValue(), sLanguageFile.c_str()); - Dialog::Result ret = Dialog::AbortRetry(sMessage); - if (ret != Dialog::retry) - return; - - FILEMAN->Remove(sLanguageFile); - - OnSelchangeListThemes(); -} - -struct TranslationLine -{ - RString sSection, sID, sBaseLanguage, sCurrentLanguage; -}; - -static LocalizedString FAILED_TO_SAVE("LanguagesDlg", "Failed to save '%s'."); -static LocalizedString THERE_ARE_NO_STRINGS_TO_EXPORT( - "LanguagesDlg", - "There are no strings to export for this language."); -static LocalizedString EXPORTED_TO_YOUR_DESKTOP( - "LanguagesDlg", - "Exported to your Desktop as '%s'."); -void -LanguagesDlg::OnBnClickedButtonExport() -{ - // TODO: Add your control notification handler code here - RString sTheme = GetCurrentString(m_listThemes); - ASSERT(!sTheme.empty()); - RString sLanguage = GetCurrentString(m_listLanguages); - ASSERT(!sLanguage.empty()); - sLanguage = SMPackageUtil::GetLanguageCodeFromDisplayString(sLanguage); - - RString sBaseLanguageFile = - GetLanguageFile(sTheme, SpecialFiles::BASE_LANGUAGE); - RString sLanguageFile = GetLanguageFile(sTheme, sLanguage); - - bool bExportAlreadyTranslated = - !!m_buttonExportAlreadyTranslated.GetCheck(); - - CsvFile csv; - IniFile ini1; - ini1.ReadFile(sBaseLanguageFile); - IniFile ini2; - ini2.ReadFile(sLanguageFile); - int iNumExpored = 0; - - vector vs; - vs.push_back("Section"); - vs.push_back("ID"); - vs.push_back("Base Language Value"); - vs.push_back("Localized Value"); - csv.m_vvs.push_back(vs); - - FOREACH_CONST_Child(&ini1, key) - { - FOREACH_CONST_Attr(key, value) - { - TranslationLine tl; - tl.sSection = key->m_sName; - tl.sID = value->first; - tl.sBaseLanguage = value->second->GetValue(); - ini2.GetValue(tl.sSection, tl.sID, tl.sCurrentLanguage); - - // don't export empty strings - RString sBaseLanguageTrimmed = tl.sBaseLanguage; - TrimLeft(sBaseLanguageTrimmed, " "); - TrimRight(sBaseLanguageTrimmed, " "); - if (sBaseLanguageTrimmed.empty()) - continue; - - bool bAlreadyTranslated = !tl.sCurrentLanguage.empty(); - if (!bAlreadyTranslated || bExportAlreadyTranslated) { - vector vs; - vs.push_back(tl.sSection); - vs.push_back(tl.sID); - vs.push_back(tl.sBaseLanguage); - vs.push_back(tl.sCurrentLanguage); - csv.m_vvs.push_back(vs); - iNumExpored++; - } - } - } - - RageFileOsAbsolute file; - RString sFile = sTheme + "-" + sLanguage + ".csv"; - RString sFullFile = SpecialDirs::GetDesktopDir() + sFile; - file.Open(sFullFile, RageFile::WRITE); - if (iNumExpored == 0) { - Dialog::OK(THERE_ARE_NO_STRINGS_TO_EXPORT.GetValue()); - return; - } - - if (csv.WriteFile(file)) - Dialog::OK( - ssprintf(EXPORTED_TO_YOUR_DESKTOP.GetValue(), sFile.c_str())); - else - Dialog::OK(ssprintf(FAILED_TO_SAVE.GetValue(), sFullFile.c_str())); -} - -static LocalizedString ERROR_READING_FILE("LanguagesDlg", - "Error reading file '%s'."); -static LocalizedString ERROR_PARSING_FILE("LanguagesDlg", - "Error parsing file '%s'."); -static LocalizedString IMPORTING_THESE_STRINGS_WILL_OVERRIDE( - "LanguagesDlg", - "Importing these strings will override all data in '%s'. Continue?"); -static LocalizedString ERROR_READING("LanguagesDlg", "Error reading '%s'."); -static LocalizedString ERROR_READING_EACH_LINE_MUST_HAVE( - "LanguagesDlg", - "Error reading line '%s' from '%s': Each line must have either 3 or 4 " - "values. This row has %d values."); -static LocalizedString IMPORTED_STRINGS_INTO("LanguagesDlg", - "Imported %d strings into '%s'.\n " - "- %d were added.\n - %d were " - "modified\n - %d were unchanged\n " - "- %d empty strings were ignored"); -void -LanguagesDlg::OnBnClickedButtonImport() -{ - // TODO: Add your control notification handler code here - CFileDialog dialog(TRUE, // file open? - NULL, // default file extension - NULL, // default file name - OFN_HIDEREADONLY | OFN_NOCHANGEDIR, // flags - "CSV file (*.csv)|*.csv|||"); - int iRet = dialog.DoModal(); - RString sCsvFile = dialog.GetPathName(); - if (iRet != IDOK) - return; - - RString sTheme = GetCurrentString(m_listThemes); - ASSERT(!sTheme.empty()); - RString sLanguage = GetCurrentString(m_listLanguages); - ASSERT(!sLanguage.empty()); - sLanguage = SMPackageUtil::GetLanguageCodeFromDisplayString(sLanguage); - - RageFileOsAbsolute cvsFile; - if (!cvsFile.Open(sCsvFile)) { - Dialog::OK(ssprintf(ERROR_READING_FILE.GetValue(), sCsvFile.c_str())); - return; - } - CsvFile csv; - if (!csv.ReadFile(cvsFile)) { - Dialog::OK(ssprintf(ERROR_PARSING_FILE.GetValue(), sCsvFile.c_str())); - return; - } - - RString sLanguageFile = GetLanguageFile(sTheme, sLanguage); - - { - Dialog::Result ret = Dialog::AbortRetry( - ssprintf(IMPORTING_THESE_STRINGS_WILL_OVERRIDE.GetValue(), - sLanguageFile.c_str())); - if (ret != Dialog::retry) - return; - } - - IniFile ini; - if (!ini.ReadFile(sLanguageFile)) { - Dialog::OK(ssprintf(ERROR_READING.GetValue(), sLanguageFile.c_str())); - return; - } - - int iNumImported = 0; - int iNumAdded = 0; - int iNumModified = 0; - int iNumUnchanged = 0; - int iNumIgnored = 0; - FOREACH_CONST(CsvFile::StringVector, csv.m_vvs, line) - { - int iLineIndex = line - csv.m_vvs.begin(); - - // Skip the header row - if (iLineIndex == 0) - continue; - - TranslationLine tl; - int iNumValues = line->size(); - if (iNumValues != 3 && iNumValues != 4) { - Dialog::OK(ssprintf(ERROR_READING_EACH_LINE_MUST_HAVE.GetValue(), - join(",", *line).c_str(), - sCsvFile.c_str(), - iNumValues)); - return; - } - tl.sSection = (*line)[0]; - tl.sID = (*line)[1]; - tl.sBaseLanguage = (*line)[2]; - tl.sCurrentLanguage = iNumValues == 4 ? (*line)[3] : RString(); - - if (tl.sCurrentLanguage.empty()) { - iNumIgnored++; - } else { - RString sOldCurrentLanguage; - bool bExists = - ini.GetValue(tl.sSection, tl.sID, sOldCurrentLanguage); - if (bExists) { - if (sOldCurrentLanguage == tl.sCurrentLanguage) - iNumUnchanged++; - else - iNumModified++; - } else { - iNumAdded++; - } - - ini.SetValue(tl.sSection, tl.sID, tl.sCurrentLanguage); - iNumImported++; - } - } - - if (ini.WriteFile(sLanguageFile)) - Dialog::OK(ssprintf(IMPORTED_STRINGS_INTO.GetValue(), - iNumImported, - sLanguageFile.c_str(), - iNumAdded, - iNumModified, - iNumUnchanged, - iNumIgnored)); - else - Dialog::OK(ssprintf(FAILED_TO_SAVE.GetValue(), sLanguageFile.c_str())); - - OnSelchangeListThemes(); -} - -void -GetAllMatches(const RString& sRegex, - const RString& sString, - vector& asOut) -{ - Regex re(sRegex + "(.*)$"); - RString sMatch(sString); - while (1) { - vector asMatches; - if (!re.Compare(sMatch, asMatches)) - break; - asOut.push_back(asMatches[0]); - sMatch = asMatches[1]; - } -} - -void -DumpList(const vector& asList, RageFile& file) -{ - RString sLine; - FOREACH_CONST(RString, asList, s) - { - if (sLine.size() + s->size() > 100) { - file.PutLine(sLine); - sLine = ""; - } - - if (sLine.size()) - sLine += ", "; - else - sLine += " "; - - sLine += *s; - } - - file.PutLine(sLine); -} - -void -LanguagesDlg::OnBnClickedCheckLanguage() -{ - RString sTheme = GetCurrentString(m_listThemes); - ASSERT(!sTheme.empty()); - RString sLanguage = GetCurrentString(m_listLanguages); - ASSERT(!sLanguage.empty()); - sLanguage = SMPackageUtil::GetLanguageCodeFromDisplayString(sLanguage); - - RString sBaseLanguageFile = - GetLanguageFile(sTheme, SpecialFiles::BASE_LANGUAGE); - RString sLanguageFile = GetLanguageFile(sTheme, sLanguage); - - IniFile ini1; - ini1.ReadFile(sBaseLanguageFile); - IniFile ini2; - ini2.ReadFile(sLanguageFile); - - RageFileOsAbsolute file; - RString sFile = sTheme + "-" + sLanguage + " check.txt"; - RString sFullFile = SpecialDirs::GetDesktopDir() + sFile; - file.Open(sFullFile, RageFile::WRITE); - - { FOREACH_CONST_Child(&ini1, key){ - FOREACH_CONST_Attr(key, value){ const RString& sSection = key->m_sName; - const RString& sID = value->first; - const RString& sBaseLanguage = value->second->GetValue(); - RString sCurrentLanguage; - ini2.GetValue(sSection, sID, sCurrentLanguage); - - if (sCurrentLanguage.empty()) - continue; - - /* Check &FOO;, %{foo}, %-1.2f, %. Some mismatches here are normal, - * particularly in languages with substantially different word order rules - * than English. */ - { - RString sRegex = - "(&[A-Za-z]+;|%{[A-Za-z]+}|%[+-]?[0-9]*.?[0-9]*[sidf]|%)"; - vector asMatchesBase; - GetAllMatches(sRegex, sBaseLanguage, asMatchesBase); - - vector asMatches; - GetAllMatches(sRegex, sCurrentLanguage, asMatches); - - if (asMatchesBase.size() != asMatches.size() || - !std::equal( - asMatchesBase.begin(), asMatchesBase.end(), asMatches.begin())) { - file.PutLine( - ssprintf("Entity/substitution mismatch in section [%s] (%s):", - sSection.c_str(), - sID.c_str())); - file.PutLine(ssprintf(" %s", sCurrentLanguage.c_str())); - file.PutLine(ssprintf(" %s", sBaseLanguage.c_str())); - } - } - - /* Check "foo::bar", "foo\nbar" and double quotes. Check these - * independently of the above. */ - { - RString sRegex = "(\"|::|\\n)"; - vector asMatchesBase; - GetAllMatches(sRegex, sBaseLanguage, asMatchesBase); - - vector asMatches; - GetAllMatches(sRegex, sCurrentLanguage, asMatches); - - if (asMatchesBase.size() != asMatches.size() || - !std::equal( - asMatchesBase.begin(), asMatchesBase.end(), asMatches.begin())) { - file.PutLine( - ssprintf("Quote/line break mismatch in section [%s] (%s):", - sSection.c_str(), - sID.c_str())); - file.PutLine(ssprintf(" %s", sCurrentLanguage.c_str())); - file.PutLine(ssprintf(" %s", sBaseLanguage.c_str())); - } - } - - /* Check that both end in a period or both don't end an a period. */ - { - RString sBaseLanguage2 = sBaseLanguage; - TrimRight(sBaseLanguage2, " "); - RString sCurrentLanguage2 = sCurrentLanguage; - TrimRight(sCurrentLanguage2, " "); - - if ((sBaseLanguage2.Right(1) == ".") ^ - (sCurrentLanguage2.Right(1) == ".")) { - file.PutLine(ssprintf("Period mismatch in section [%s] (%s):", - sSection.c_str(), - sID.c_str())); - file.PutLine(ssprintf(" %s", sCurrentLanguage.c_str())); - file.PutLine(ssprintf(" %s", sBaseLanguage.c_str())); - } - } -} -} -} - -{ FOREACH_CONST_Child(&ini2, key){ - FOREACH_CONST_Attr(key, value){ const RString& sSection = key->m_sName; -const RString& sID = value->first; -const RString& sCurrentLanguage = value->second->GetValue(); -if (utf8_is_valid(sCurrentLanguage)) - continue; - -/* The text isn't valid UTF-8. We don't know what encoding it is; guess that - * it's ISO-8859-1 and convert it so it'll display correctly and can be pasted - * into the file. Don't include the original text: if we include multiple - * encodings in the resulting text file, editors won't understand the encoding - * of the file and will pick one arbitrarily. */ -file.PutLine(ssprintf("Incorrect encoding in section [%s]:", sSection.c_str())); -wstring wsConverted = ConvertCodepageToWString(sCurrentLanguage, 1252); -RString sConverted = WStringToRString(wsConverted); -file.PutLine(ssprintf("%s=%s", sID.c_str(), sConverted.c_str())); -} -} -} - -{ FOREACH_CONST_Child(&ini2, key){ vector asList; -const RString& sSection = key->m_sName; -FOREACH_CONST_Attr(key, value) -{ - const RString& sID = value->first; - RString sCurrentLanguage; - if (ini1.GetValue(sSection, sID, sCurrentLanguage)) - continue; - - asList.push_back(sID); -} -if (!asList.empty()) { - file.PutLine( - ssprintf("Obsolete translation in section [%s]:", sSection.c_str())); - DumpList(asList, file); -} -} -} - -{ - FOREACH_CONST_Child(&ini1, key) - { - vector asList; - const RString& sSection = key->m_sName; - FOREACH_CONST_Attr(key, value) - { - const RString& sID = value->first; - const RString& sBaseText = value->second->GetValue(); - if (sBaseText.empty()) - continue; - RString sCurrentLanguage; - if (ini2.GetValue(sSection, sID, sCurrentLanguage)) - continue; - - asList.push_back(sID); - } - if (!asList.empty()) { - file.PutLine( - ssprintf("Not translated in section [%s]:", sSection.c_str())); - DumpList(asList, file); - } - } -} - -file.Close(); - -GotoURL(ssprintf("file://%s", sFullFile.c_str())); -} diff --git a/src/smpackagee/LanguagesDlg.h b/src/smpackagee/LanguagesDlg.h deleted file mode 100644 index f2fc8df501..0000000000 --- a/src/smpackagee/LanguagesDlg.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include "afxwin.h" - -// LanguagesDlg dialog - -class LanguagesDlg : public CDialog -{ - DECLARE_DYNAMIC(LanguagesDlg) - - public: - LanguagesDlg(CWnd* pParent = NULL); // standard constructor - virtual ~LanguagesDlg(); - - // Dialog Data - enum - { - IDD = IDD_LANGUAGES - }; - - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnInitDialog(); - void OnSelchangeListThemes(); - void OnSelchangeListLanguages(); - - DECLARE_MESSAGE_MAP() - public: - CListBox m_listThemes; - CListBox m_listLanguages; - afx_msg void OnBnClickedButtonCreate(); - afx_msg void OnBnClickedButtonDelete(); - afx_msg void OnBnClickedButtonExport(); - afx_msg void OnBnClickedButtonImport(); - CButton m_buttonExportAlreadyTranslated; - afx_msg void OnBnClickedCheckLanguage(); -}; diff --git a/src/smpackagee/MainMenuDlg.cpp b/src/smpackagee/MainMenuDlg.cpp deleted file mode 100644 index fb5ed9d1ae..0000000000 --- a/src/smpackagee/MainMenuDlg.cpp +++ /dev/null @@ -1,335 +0,0 @@ -// MainMenuDlg.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "MainMenuDlg.h" -#include "EditInsallations.h" -#include "SmpackageExportDlg.h" -#include "ChangeGameSettings.h" -#include "RageUtil.h" -#include "SMPackageUtil.h" -#include "mainmenudlg.h" -#include "archutils/Win32/SpecialDirs.h" -#include "SpecialFiles.h" -#include "ProductInfo.h" -#include "mainmenudlg.h" -#include "LanguagesDlg.h" -#include ".\mainmenudlg.h" -#include "archutils/Win32/DialogUtil.h" -#include "LocalizedString.h" -#include "RageFileManager.h" -#include "arch/Dialog/Dialog.h" -#include "archutils/Win32/ErrorStrings.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// MainMenuDlg dialog - -MainMenuDlg::MainMenuDlg(CWnd* pParent /*=NULL*/) - : CDialog(MainMenuDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(MainMenuDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void -MainMenuDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(MainMenuDlg) - // NOTE: the ClassWizard will add DDX and DDV calls here - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(MainMenuDlg, CDialog) -//{{AFX_MSG_MAP(MainMenuDlg) -ON_BN_CLICKED(IDC_EXPORT_PACKAGES, OnExportPackages) -ON_BN_CLICKED(IDC_EDIT_INSTALLATIONS, OnEditInstallations) -ON_BN_CLICKED(IDC_CREATE_SONG, OnCreateSong) -ON_BN_CLICKED(IDC_CLEAR_KEYMAPS, OnBnClickedClearKeymaps) -ON_BN_CLICKED(IDC_CHANGE_PREFERENCES, OnBnClickedChangePreferences) -ON_BN_CLICKED(IDC_OPEN_PREFERENCES, OnBnClickedOpenPreferences) -ON_BN_CLICKED(IDC_CLEAR_PREFERENCES, OnBnClickedClearPreferences) -//}}AFX_MSG_MAP -ON_BN_CLICKED(IDC_BUTTON_LAUNCH_GAME, OnBnClickedButtonLaunchGame) -ON_BN_CLICKED(IDC_LANGUAGES, OnBnClickedLanguages) -ON_WM_CTLCOLOR() -ON_WM_ERASEBKGND() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// MainMenuDlg message handlers - -void -MainMenuDlg::OnExportPackages() -{ - // TODO: Add your control notification handler code here - CSmpackageExportDlg dlg; - dlg.DoModal(); - // if (nResponse == IDOK) -} - -void -MainMenuDlg::OnEditInstallations() -{ - // TODO: Add your control notification handler code here - EditInsallations dlg; - dlg.DoModal(); -} - -RString -GetLastErrorString() -{ - LPVOID lpMsgBuf; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR)&lpMsgBuf, - 0, - NULL); - // Process any inserts in lpMsgBuf. - // ... - // Display the string. - RString s = (LPCTSTR)lpMsgBuf; - // Free the buffer. - LocalFree(lpMsgBuf); - - return s; -} - -static LocalizedString MUSIC_FILE("MainMenuDlg", "Music file"); -static LocalizedString THE_SONG_DIRECTORY_ALREADY_EXISTS("MainMenuDlg", - "The song directory " - "'%s' already exists. " - " You cannot override " - "an existing song."); -static LocalizedString FAILED_TO_COPY_MUSIC_FILE( - "MainMenuDlg", - "Failed to copy music file '%s' to '%s': %s"); -static LocalizedString FAILED_TO_CREATE_THE_SONG_FILE( - "MainMenuDlg", - "Failed to create the song file '%s'."); -static LocalizedString SUCCESS_CREATED_THE_SONG( - "MainMenuDlg", - "Success. Created the song '%s'."); -void -MainMenuDlg::OnCreateSong() -{ - // TODO: Add your control notification handler code here - ASSERT(0); - // fix compile - CFileDialog dialog( - TRUE, // file open? - NULL, // default file extension - NULL, // default file name - OFN_HIDEREADONLY | OFN_NOCHANGEDIR, // flags - ConvertUTF8ToACP(MUSIC_FILE.GetValue() + " (*.mp3;*.ogg)|*.mp3;*.ogg|||") - .c_str()); - int iRet = dialog.DoModal(); - RString sMusicFile = dialog.GetPathName(); - if (iRet != IDOK) - return; - - RString sSongDirectory = - "Songs/My Creations/" + GetFileNameWithoutExtension(sMusicFile) + "/"; - RString sNewMusicFile = sSongDirectory + Basename(sMusicFile); - - if (DoesFileExist(sSongDirectory)) { - Dialog::OK(ssprintf(THE_SONG_DIRECTORY_ALREADY_EXISTS.GetValue(), - sSongDirectory.c_str())); - return; - } - - RageFileOsAbsolute fileIn; - fileIn.Open(sMusicFile, RageFile::READ); - RageFile fileOut; - fileOut.Open(sNewMusicFile, RageFile::WRITE); - RString sError; - bool bSuccess = FileCopy(fileIn, fileOut, sError); - if (!bSuccess) { - Dialog::OK(ssprintf(FAILED_TO_COPY_MUSIC_FILE.GetValue(), - sMusicFile.c_str(), - sNewMusicFile.c_str(), - sError.c_str())); - return; - } - - // create a blank .sm file - RString sNewSongFile = sMusicFile; - SetExtension(sNewSongFile, "sm"); - RageFile file; - if (file.Open(sNewSongFile, RageFile::WRITE)) { - Dialog::OK(ssprintf(FAILED_TO_CREATE_THE_SONG_FILE.GetValue(), - sNewSongFile.c_str())); - return; - } - file.Close(); - - Dialog::OK( - ssprintf(SUCCESS_CREATED_THE_SONG.GetValue(), sSongDirectory.c_str())); -} - -BOOL -MainMenuDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - DialogUtil::SetHeaderFont(*this, IDC_STATIC_HEADER_TEXT); - - // DialogUtil::SetDlgItemHeader( *this, IDC_STATIC_HEADER_TEXT, "header" ); - - TCHAR szCurDir[MAX_PATH]; - GetCurrentDirectory(ARRAYLEN(szCurDir), szCurDir); - GetDlgItem(IDC_EDIT_INSTALLATION)->SetWindowText(szCurDir); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -static LocalizedString FAILED_TO_DELETE_FILE("MainMenuDlg", - "Failed to delete file '%s'."); -static LocalizedString IS_ALREADY_CLEARED("MainMenuDlg", - "'%s' is already cleared."); -static LocalizedString CLEARED("MainMenuDlg", "'%s' cleared"); -void -MainMenuDlg::OnBnClickedClearKeymaps() -{ - // TODO: Add your control notification handler code here - - FILEMAN->FlushDirCache(Dirname(SpecialFiles::KEYMAPS_PATH)); - if (!DoesFileExist(SpecialFiles::KEYMAPS_PATH)) { - Dialog::OK(ssprintf(IS_ALREADY_CLEARED.GetValue(), - SpecialFiles::KEYMAPS_PATH.c_str())); - return; - } - - if (!FILEMAN->Remove(SpecialFiles::KEYMAPS_PATH)) - Dialog::OK(ssprintf(FAILED_TO_DELETE_FILE.GetValue(), - SpecialFiles::KEYMAPS_PATH.c_str())); - - Dialog::OK( - ssprintf(CLEARED.GetValue(), SpecialFiles::KEYMAPS_PATH.c_str())); -} - -void -MainMenuDlg::OnBnClickedChangePreferences() -{ - // TODO: Add your control notification handler code here - ChangeGameSettings dlg; - dlg.DoModal(); -} - -static LocalizedString DOESNT_EXIST_IT_WILL_BE_CREATED( - "MainMenuDlg", - "'%s' doesn't exist. It will be created next time you start the game."); -static LocalizedString FAILED_TO_OPEN("MainMenuDlg", "Failed to open '%s': %s"); -void -MainMenuDlg::OnBnClickedOpenPreferences() -{ - // TODO: Add your control notification handler code here - // TODO: Have RageFile* do the mapping to the OS file location. - RString sPreferencesOSFile = SpecialDirs::GetAppDataDir() + PRODUCT_ID + - "/" + SpecialFiles::PREFERENCES_INI_PATH; - HINSTANCE hinst = ::ShellExecute( - this->m_hWnd, "open", sPreferencesOSFile, "", "", SW_SHOWNORMAL); - if ((int)hinst == SE_ERR_FNF) - Dialog::OK(ssprintf(DOESNT_EXIST_IT_WILL_BE_CREATED.GetValue(), - sPreferencesOSFile.c_str())); - else if ((int)hinst <= 32) - Dialog::OK(ssprintf(FAILED_TO_OPEN.GetValue(), - sPreferencesOSFile.c_str(), - GetLastErrorString().c_str())); -} - -void -MainMenuDlg::OnBnClickedClearPreferences() -{ - // TODO: Add your control notification handler code here - FILEMAN->FlushDirCache(); - if (!DoesFileExist(SpecialFiles::PREFERENCES_INI_PATH)) { - Dialog::OK(ssprintf(IS_ALREADY_CLEARED.GetValue(), - SpecialFiles::PREFERENCES_INI_PATH.c_str())); - return; - } - - if (!FILEMAN->Remove(SpecialFiles::PREFERENCES_INI_PATH)) { - Dialog::OK(ssprintf(FAILED_TO_DELETE_FILE.GetValue(), - SpecialFiles::PREFERENCES_INI_PATH.c_str())); - return; - } - - Dialog::OK( - ssprintf(CLEARED.GetValue(), SpecialFiles::PREFERENCES_INI_PATH.c_str())); -} - -void -MainMenuDlg::OnBnClickedButtonLaunchGame() -{ - // TODO: Add your control notification handler code here - if (SMPackageUtil::LaunchGame()) - exit(0); -} - -void -MainMenuDlg::OnBnClickedLanguages() -{ - // TODO: Add your control notification handler code here - LanguagesDlg dlg; - dlg.DoModal(); -} - -HBRUSH -MainMenuDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) -{ - HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); - - // TODO: Change any attributes of the DC here - switch (pWnd->GetDlgCtrlID()) { - case IDC_STATIC_HEADER_TEXT: - case IDC_STATIC_ICON: - hbr = (HBRUSH)::GetStockObject(WHITE_BRUSH); - pDC->SetBkMode(OPAQUE); - pDC->SetBkColor(RGB(255, 255, 255)); - break; - } - - // TODO: Return a different brush if the default is not desired - return hbr; -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/MainMenuDlg.h b/src/smpackagee/MainMenuDlg.h deleted file mode 100644 index d05aee1e46..0000000000 --- a/src/smpackagee/MainMenuDlg.h +++ /dev/null @@ -1,85 +0,0 @@ -#if !defined(AFX_MAINMENUDLG_H__3CED6142_18E5_4267_B678_BE5B63735C6C__INCLUDED_) -#define AFX_MAINMENUDLG_H__3CED6142_18E5_4267_B678_BE5B63735C6C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// MainMenuDlg.h : header file - -///////////////////////////////////////////////////////////////////////////// -// MainMenuDlg dialog - -class MainMenuDlg : public CDialog -{ - // Construction - public: - MainMenuDlg(CWnd* pParent = NULL); // standard constructor - - // Dialog Data - //{{AFX_DATA(MainMenuDlg) - enum - { - IDD = IDD_MENU - }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MainMenuDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - // Generated message map functions - //{{AFX_MSG(MainMenuDlg) - afx_msg void OnExportPackages(); - afx_msg void OnEditInstallations(); - afx_msg void OnChangeApi(); - afx_msg void OnCreateSong(); - virtual BOOL OnInitDialog(); - afx_msg void OnOpenPreferencesIni(); - afx_msg void OnBnClickedClearKeymaps(); - afx_msg void OnBnClickedChangePreferences(); - afx_msg void OnBnClickedOpenPreferences(); - afx_msg void OnBnClickedClearPreferences(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - public: - afx_msg void OnBnClickedButtonLaunchGame(); - afx_msg void OnBnClickedLanguages(); - afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_MAINMENUDLG_H__3CED6142_18E5_4267_B678_BE5B63735C6C__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/SMPackageInstallDlg.cpp b/src/smpackagee/SMPackageInstallDlg.cpp deleted file mode 100644 index 643247258a..0000000000 --- a/src/smpackagee/SMPackageInstallDlg.cpp +++ /dev/null @@ -1,469 +0,0 @@ -// SMPackageInstallDlg.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "SMPackageInstallDlg.h" -#include "RageUtil.h" -#include "smpackageUtil.h" -#include "EditInsallations.h" -#include "ShowComment.h" -#include "IniFile.h" -#include "UninstallOld.h" -#include -#include "RageFileManager.h" -#include "RageFileDriverZip.h" -#include "archutils/Win32/DialogUtil.h" -#include "LocalizedString.h" -#include "RageLog.h" -#include "arch/Dialog/Dialog.h" -#include "RageFileDriverDirect.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSMPackageInstallDlg dialog - -CSMPackageInstallDlg::CSMPackageInstallDlg(RString sPackagePath, - CWnd* pParent /*=NULL*/) - : CDialog(CSMPackageInstallDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CSMPackageInstallDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT - - m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); - - m_sPackagePath = sPackagePath; -} - -void -CSMPackageInstallDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSMPackageInstallDlg) - DDX_Control(pDX, IDC_BUTTON_EDIT, m_buttonEdit); - DDX_Control(pDX, IDC_COMBO_DIR, m_comboDir); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CSMPackageInstallDlg, CDialog) -//{{AFX_MSG_MAP(CSMPackageInstallDlg) -ON_WM_PAINT() -ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit) -//}}AFX_MSG_MAP -ON_WM_CTLCOLOR() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSMPackageInstallDlg message handlers - -static bool -CompareStringNoCase(const RString& s1, const RString& s2) -{ - return s1.CompareNoCase(s2) < 0; -} - -void -GetSmzipFilesToExtract(RageFileDriver& zip, vector& vsOut) -{ - GetDirListingRecursive(&zip, "/", "*", vsOut); - SMPackageUtil::StripIgnoredSmzipFiles(vsOut); -} - -static LocalizedString COULD_NOT_OPEN_FILE("CSMPackageInstallDlg", - "Could not open file '%s'."); -static LocalizedString IS_NOT_A_VALID_ZIP("CSMPackageInstallDlg", - "'%s' is not a valid zip archive."); -BOOL -CSMPackageInstallDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // Set the icon for this dialog. The framework does this automatically - // when the application's main window is not a dialog - SetIcon(m_hIcon, TRUE); // Set big icon - SetIcon(m_hIcon, FALSE); // Set small icon - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - DialogUtil::SetHeaderFont(*this, IDC_STATIC_HEADER_TEXT); - - // mount the zip - RageFileOsAbsolute file; - if (!file.Open(m_sPackagePath)) { - Dialog::OK( - ssprintf(COULD_NOT_OPEN_FILE.GetValue(), m_sPackagePath.c_str())); - exit(1); // better way to abort? - } - - RageFileDriverZip zip; - if (!zip.Load(&file)) { - Dialog::OK( - ssprintf(IS_NOT_A_VALID_ZIP.GetValue(), m_sPackagePath.c_str())); - exit(1); // better way to abort? - } - - // - // Set the text of the first Edit box - // - RString sMessage1 = "\t" + m_sPackagePath; - CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE1); - pEdit1->SetWindowText(sMessage1); - - // - // Set the text of the second Edit box - // - { - vector vs; - GetSmzipFilesToExtract(zip, vs); - CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2); - RString sText = "\t" + join("\r\n\t", vs); - pEdit2->SetWindowText(sText); - } - - RefreshInstallationList(); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -void -CSMPackageInstallDlg::OnPaint() -{ - CPaintDC dc(this); // device context for painting - - // TODO: Add your message handler code here - - if (IsIconic()) { - CPaintDC dc(this); // device context for painting - - SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0); - - // Center icon in client rectangle - int cxIcon = GetSystemMetrics(SM_CXICON); - int cyIcon = GetSystemMetrics(SM_CYICON); - CRect rect; - GetClientRect(&rect); - int x = (rect.Width() - cxIcon + 1) / 2; - int y = (rect.Height() - cyIcon + 1) / 2; - - // Draw the icon - dc.DrawIcon(x, y, m_hIcon); - } else { - CDialog::OnPaint(); - } -} -#include -#include ".\smpackageinstalldlg.h" - -static bool -CheckPackages(RageFileDriverZip& fileDriver) -{ - int iErr; - RageFileBasic* pFile = fileDriver.Open("smzip.ctl", RageFile::READ, iErr); - if (pFile == NULL) - return true; - - IniFile ini; - ini.ReadFile(*pFile); - - int version = 0; - ini.GetValue("SMZIP", "Version", version); - if (version != 1) - return true; - - int cnt = 0; - ini.GetValue("Packages", "NumPackages", cnt); - - vector vsDirectories; - for (int i = 0; i < cnt; ++i) { - RString path; - if (!ini.GetValue("Packages", ssprintf("%i", i), path)) - continue; - - /* Does this directory exist? */ - if (!FILEMAN->IsADirectory(path)) - continue; - - if (!SMPackageUtil::IsValidPackageDirectory(path)) - continue; - - vsDirectories.push_back(path); - } - - if (vsDirectories.empty()) - return true; - - { - UninstallOld UninstallOldDlg; - UninstallOldDlg.m_sPackages = join("\r\n", vsDirectories); - int nResponse = UninstallOldDlg.DoModal(); - if (nResponse == IDCANCEL) - return false; // cancelled - if (nResponse == IDIGNORE) - return true; - } - - char cwd_[MAX_PATH]; - _getcwd(cwd_, MAX_PATH); - RString cwd(cwd_); - if (cwd[cwd.size() - 1] != '\\') - cwd += "\\"; - - for (int i = 0; i < (int)vsDirectories.size(); ++i) { - RString sDir = vsDirectories[i]; - sDir += "/"; - if (!DeleteRecursive(sDir)) // error deleting - { - return false; - } - } - - return true; -} - -static LocalizedString NO_INSTALLATIONS("CSMPackageInstallDlg", - "No Installations found. Exiting."); -static LocalizedString INSTALLING_PLEASE_WAIT("CSMPackageInstallDlg", - "Installing. Please wait..."); -static LocalizedString ERROR_OPENING_SOURCE_FILE( - "CSMPackageInstallDlg", - "Error opening source file '%s': %s"); -static LocalizedString ERROR_OPENING_DESTINATION_FILE( - "CSMPackageInstallDlg", - "Error opening destination file '%s': %s"); -static LocalizedString ERROR_COPYING_FILE("CSMPackageInstallDlg", - "Error copying file '%s': %s"); -static LocalizedString PACKAGE_INSTALLED_SUCCESSFULLY( - "CSMPackageInstallDlg", - "Package installed successfully!"); -void -CSMPackageInstallDlg::OnOK() -{ - // TODO: Add extra validation here - - int ProgressInit = 0; - - m_comboDir.EnableWindow(FALSE); - m_buttonEdit.EnableWindow(FALSE); - - RString sInstallDir; - { - CString s; - m_comboDir.GetWindowText(s); - sInstallDir = s; - } - - // selected install dir becomes the new default - int iSelectedInstallDirIndex = m_comboDir.GetCurSel(); - if (iSelectedInstallDirIndex == -1) { - Dialog::OK(NO_INSTALLATIONS.GetValue()); - return; - } - - SMPackageUtil::SetDefaultInstallDir(iSelectedInstallDirIndex); - - // mount the zip - RageFileOsAbsolute file; - if (!file.Open(m_sPackagePath)) { - Dialog::OK( - ssprintf(COULD_NOT_OPEN_FILE.GetValue(), m_sPackagePath.c_str())); - exit(1); // better way to abort? - } - - RageFileDriverZip zip; - if (!zip.Load(&file)) { - Dialog::OK( - ssprintf(IS_NOT_A_VALID_ZIP.GetValue(), m_sPackagePath.c_str())); - exit(1); // better way to abort? - } - - RageFileDriverDirect dir(sInstallDir); - // handle error? - - // Show comment (if any) - { - RString sComment = zip.GetGlobalComment(); - bool DontShowComment; - if (sComment != "" && - (!SMPackageUtil::GetPref("DontShowComment", DontShowComment) || - !DontShowComment)) { - ShowComment commentDlg; - commentDlg.m_sComment = sComment; - int nResponse = commentDlg.DoModal(); - if (nResponse != IDOK) - return; // cancelled - if (commentDlg.m_bDontShow) - SMPackageUtil::SetPref("DontShowComment", true); - } - } - - /* Check for installed packages that should be deleted before installing. */ - if (!CheckPackages(zip)) - return; // cancelled - - // Unzip the SMzip package into the installation folder - vector vs; - GetSmzipFilesToExtract(zip, vs); - for (unsigned i = 0; i < vs.size(); i++) { - // Throw some text up so the user has something to look at during the - // long pause. - CEdit* pEdit1 = (CEdit*)GetDlgItem(IDC_STATIC_MESSAGE1); - pEdit1->SetWindowText( - ssprintf(INSTALLING_PLEASE_WAIT.GetValue(), m_sPackagePath.c_str())); - CEdit* pEdit2 = (CEdit*)GetDlgItem(IDC_EDIT_MESSAGE2); - pEdit2->SetWindowText(""); - GetDlgItem(IDC_STATIC_MESSAGE2)->ShowWindow(SW_HIDE); - CProgressCtrl* pProgress1 = (CProgressCtrl*)GetDlgItem(IDC_PROGRESS1); - // Show the hided progress bar - if (!pProgress1->IsWindowVisible()) { - pProgress1->ShowWindow(SW_SHOWNORMAL); - } - // Initialize the progress bar and update the window 1 time (it's - // enough) - if (!ProgressInit) { - pProgress1->SetRange(0, (short)vs.size()); - pProgress1->SetStep(1); - pProgress1->SetPos(0); - SendMessage(WM_PAINT); - UpdateWindow(); // Force the silly thing to hadle WM_PAINT now! - ProgressInit = 1; - } - - Dialog::Result result; - do { - // Extract the files - const RString sFile = vs[i]; - LOG->Trace("Extracting: " + sFile); - - RString sError; - { - int iErr; - RageFileBasic* pFileFrom = - zip.Open(sFile, RageFile::READ, iErr); - if (pFileFrom == NULL) { - sError = ssprintf(ERROR_OPENING_SOURCE_FILE.GetValue(), - sFile.c_str(), - ssprintf("%d", iErr).c_str()); - goto show_error; - } - - int iError; - RageFileBasic* pFileTo = - dir.Open(sFile, RageFile::WRITE, iError); - if (pFileTo == NULL) { - sError = ssprintf(ERROR_OPENING_DESTINATION_FILE.GetValue(), - sFile.c_str(), - pFileTo->GetError().c_str()); - goto show_error; - } - - RString sErr; - if (!FileCopy(*pFileFrom, *pFileTo, sErr)) { - sError = ssprintf(ERROR_COPYING_FILE.GetValue(), - sFile.c_str(), - sErr.c_str()); - goto show_error; - } - - SAFE_DELETE(pFileFrom); - SAFE_DELETE(pFileTo); - } - - break; - - show_error: - Dialog::Result result = Dialog::AbortRetryIgnore(sError); - switch (result) { - case Dialog::abort: - exit(1); // better way to exit? - break; - case Dialog::retry: - break; - case Dialog::ignore: - // do nothing - break; - } - } while (result == Dialog::retry); - - pProgress1->StepIt(); // increase the progress bar of 1 step - } - - Dialog::OK(PACKAGE_INSTALLED_SUCCESSFULLY.GetValue()); - - // close the dialog - CDialog::OnOK(); -} - -void -CSMPackageInstallDlg::OnButtonEdit() -{ - // TODO: Add your control notification handler code here - EditInsallations dlg; - int nResponse = dlg.DoModal(); - if (nResponse == IDOK) { - RefreshInstallationList(); - } -} - -void -CSMPackageInstallDlg::RefreshInstallationList() -{ - m_comboDir.ResetContent(); - - vector asInstallDirs; - SMPackageUtil::GetGameInstallDirs(asInstallDirs); - for (unsigned i = 0; i < asInstallDirs.size(); i++) - m_comboDir.AddString(asInstallDirs[i]); - m_comboDir.SetCurSel(0); // guaranteed to be at least one item -} - -HBRUSH -CSMPackageInstallDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) -{ - HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); - - // TODO: Change any attributes of the DC here - switch (pWnd->GetDlgCtrlID()) { - case IDC_STATIC_HEADER_TEXT: - case IDC_STATIC_ICON: - hbr = (HBRUSH)::GetStockObject(WHITE_BRUSH); - pDC->SetBkMode(OPAQUE); - pDC->SetBkColor(RGB(255, 255, 255)); - break; - } - - // TODO: Return a different brush if the default is not desired - return hbr; -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/SMPackageInstallDlg.h b/src/smpackagee/SMPackageInstallDlg.h deleted file mode 100644 index fd070d4080..0000000000 --- a/src/smpackagee/SMPackageInstallDlg.h +++ /dev/null @@ -1,85 +0,0 @@ -#if !defined( \ - AFX_SMPACKAGEINSTALLDLG_H__5E362C4C_CA11_4071_A8AB_A0231E985DAF__INCLUDED_) -#define AFX_SMPACKAGEINSTALLDLG_H__5E362C4C_CA11_4071_A8AB_A0231E985DAF__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// SMPackageInstallDlg.h : header file - -///////////////////////////////////////////////////////////////////////////// -// CSMPackageInstallDlg dialog - -class CSMPackageInstallDlg : public CDialog -{ - // Construction - public: - CSMPackageInstallDlg(RString sPackagePath, - CWnd* pParent = NULL); // standard constructor - - // Dialog Data - //{{AFX_DATA(CSMPackageInstallDlg) - enum - { - IDD = IDD_INSTALL - }; - CButton m_buttonEdit; - CComboBox m_comboDir; - //}}AFX_DATA - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSMPackageInstallDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - void RefreshInstallationList(); - - HICON m_hIcon; - RString m_sPackagePath; - - // Generated message map functions - //{{AFX_MSG(CSMPackageInstallDlg) - virtual BOOL OnInitDialog(); - virtual void OnOK(); - afx_msg void OnPaint(); - afx_msg void OnButtonEdit(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - public: - afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_SMPACKAGEINSTALLDLG_H__5E362C4C_CA11_4071_A8AB_A0231E985DAF__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/SMPackageUtil.cpp b/src/smpackagee/SMPackageUtil.cpp deleted file mode 100644 index 2c0bd4479d..0000000000 --- a/src/smpackagee/SMPackageUtil.cpp +++ /dev/null @@ -1,302 +0,0 @@ -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "SMPackageUtil.h" -#include "archutils/Win32/RegistryAccess.h" -#include "ProductInfo.h" -#include "RageUtil.h" -#include "RageFileManager.h" -#include "resource.h" -#include "LocalizedString.h" -#include "arch/Dialog/Dialog.h" - -static const RString SMPACKAGE_KEY = - "HKEY_LOCAL_MACHINE\\Software\\" PRODUCT_ID "\\smpackage"; -static const RString INSTALLATIONS_KEY = - "HKEY_LOCAL_MACHINE\\Software\\" PRODUCT_ID "\\smpackage\\Installations"; - -void -SMPackageUtil::WriteGameInstallDirs(const vector& asInstallDirsToWrite) -{ - RegistryAccess::CreateKey(INSTALLATIONS_KEY); - - for (unsigned i = 0; i < 100; i++) { - RString sName = ssprintf("%d", i); - RString sValue; - if (i < asInstallDirsToWrite.size()) - sValue = asInstallDirsToWrite[i]; - - RegistryAccess::SetRegValue(INSTALLATIONS_KEY, sName, sValue); - } -} - -void -SMPackageUtil::GetGameInstallDirs(vector& asInstallDirsOut) -{ - asInstallDirsOut.clear(); - - for (int i = 0; i < 100; i++) { - RString sName = ssprintf("%d", i); - - RString sPath; - if (!RegistryAccess::GetRegValue(INSTALLATIONS_KEY, sName, sPath)) - continue; - - if (sPath == "") // blank entry - continue; // skip - - if (!IsValidInstallDir(sPath)) - continue; // skip - - asInstallDirsOut.push_back(sPath); - } - - // while we're at it, write to clean up stale entries - WriteGameInstallDirs(asInstallDirsOut); -} - -void -SMPackageUtil::AddGameInstallDir(const RString& sNewInstallDir) -{ - vector asInstallDirs; - GetGameInstallDirs(asInstallDirs); - - bool bAlreadyInList = false; - for (unsigned i = 0; i < asInstallDirs.size(); i++) { - if (asInstallDirs[i].CompareNoCase(sNewInstallDir) == 0) { - bAlreadyInList = true; - break; - } - } - - if (!bAlreadyInList) - asInstallDirs.push_back(sNewInstallDir); - - WriteGameInstallDirs(asInstallDirs); -} - -void -SMPackageUtil::SetDefaultInstallDir(int iInstallDirIndex) -{ - // move the specified index to the top of the list - vector asInstallDirs; - GetGameInstallDirs(asInstallDirs); - ASSERT(iInstallDirIndex >= 0 && - iInstallDirIndex < (int)asInstallDirs.size()); - RString sDefaultInstallDir = asInstallDirs[iInstallDirIndex]; - asInstallDirs.erase(asInstallDirs.begin() + iInstallDirIndex); - asInstallDirs.insert(asInstallDirs.begin(), sDefaultInstallDir); - WriteGameInstallDirs(asInstallDirs); -} - -void -SMPackageUtil::SetDefaultInstallDir(const RString& sInstallDir) -{ - vector asInstallDirs; - GetGameInstallDirs(asInstallDirs); - - for (unsigned i = 0; i < asInstallDirs.size(); i++) { - if (asInstallDirs[i].CompareNoCase(sInstallDir) == 0) { - SetDefaultInstallDir(i); - break; - } - } -} - -bool -SMPackageUtil::IsValidInstallDir(const RString& sInstallDir) -{ - return DoesOsAbsoluteFileExist(sInstallDir + "/Songs"); -} - -bool -SMPackageUtil::GetPref(const RString& name, bool& val) -{ - return RegistryAccess::GetRegValue(SMPACKAGE_KEY, name, val); -} - -bool -SMPackageUtil::SetPref(const RString& name, bool val) -{ - return RegistryAccess::SetRegValue(SMPACKAGE_KEY, name, val); -} - -/* Get a package directory. For most paths, this is the first two components. - * For songs and note skins, this is the first three. */ -RString -SMPackageUtil::GetPackageDirectory(const RString& path) -{ - // ignore CVS/.svn files: - if (path.find("CVS") != string::npos) - return ""; - if (path.find(".svn") != string::npos) - return ""; - - vector Parts; - split(path, "\\", Parts); - - unsigned NumParts = 2; - // Songs/group/single_song, NoteSkins/gametype/single_noteskin: - if (!Parts[0].CompareNoCase("Songs") || - !Parts[0].CompareNoCase("NoteSkins")) - NumParts = 3; - if (Parts.size() < NumParts) - return ""; - - Parts.erase(Parts.begin() + NumParts, Parts.end()); - - RString ret = join("\\", Parts); - if (!IsADirectory(ret)) - return ""; - return ret; -} - -bool -SMPackageUtil::IsValidPackageDirectory(const RString& path) -{ - /* Make sure the path contains only second-level directories, and doesn't - * contain any ".", "..", "...", etc. dirs. */ - vector Parts; - split(path, "\\", Parts, true); - if (Parts.size() == 0) - return false; - - /* Make sure we're not going to "uninstall" an entire Songs subfolder. */ - unsigned NumParts = 2; - if (!Parts[0].CompareNoCase("songs")) - NumParts = 3; - if (Parts.size() < NumParts) - return false; - - /* Make sure the path doesn't contain any ".", "..", "...", etc. dirs. */ - for (unsigned i = 0; i < Parts.size(); ++i) - if (Parts[i][0] == '.') - return false; - - return true; -} - -static LocalizedString COULD_NOT_FIND("SMPackageUtil", "Could not find '%s'."); -bool -SMPackageUtil::LaunchGame() -{ - PROCESS_INFORMATION pi; - STARTUPINFO si; - ZeroMemory(&si, sizeof(si)); - - RString sFile = "Program\\" PRODUCT_FAMILY ".exe"; - - BOOL bSuccess = CreateProcess(sFile, // pointer to name of executable module - NULL, // pointer to command line string - NULL, // process security attributes - NULL, // thread security attributes - false, // handle inheritance flag - 0, // creation flags - NULL, // pointer to new environment block - NULL, // pointer to current directory name - &si, // pointer to STARTUPINFO - &pi // pointer to PROCESS_INFORMATION - ); - if (!bSuccess) { - RString sError = ssprintf(COULD_NOT_FIND.GetValue(), sFile.c_str()); - Dialog::OK(sError); - return false; - } - - return true; -} - -RString -SMPackageUtil::GetLanguageDisplayString(const RString& sIsoCode) -{ - const LanguageInfo* li = GetLanguageInfo(sIsoCode); - return ssprintf( - "%s (%s)", li ? li->szIsoCode : sIsoCode.c_str(), li->szEnglishName); -} - -RString -SMPackageUtil::GetLanguageCodeFromDisplayString(const RString& sDisplayString) -{ - RString s = sDisplayString; - // strip the space and everything after - size_t iSpace = s.find(' '); - ASSERT(iSpace != s.npos); - s.erase(s.begin() + iSpace, s.end()); - return s; -} - -void -SMPackageUtil::StripIgnoredSmzipFiles(vector& vsFilesInOut) -{ - for (int i = vsFilesInOut.size() - 1; i >= 0; i--) { - const RString& sFile = vsFilesInOut[i]; - - bool bEraseThis = false; - bEraseThis |= EndsWith(sFile, "smzip.ctl"); - bEraseThis |= EndsWith(sFile, ".old"); - bEraseThis |= EndsWith(sFile, "Thumbs.db"); - bEraseThis |= EndsWith(sFile, ".DS_Store"); - bEraseThis |= (sFile.find("CVS") != string::npos); - - if (bEraseThis) - vsFilesInOut.erase(vsFilesInOut.begin() + i); - } -} - -bool -SMPackageUtil::DoesOsAbsoluteFileExist(const RString& sOsAbsoluteFile) -{ -#if defined(WIN32) - DWORD dwAttr = ::GetFileAttributes(sOsAbsoluteFile); - return bool(dwAttr != (DWORD)-1); -#endif -} - -static const RString TEMP_MOUNT_POINT = "/@package/"; - -RageFileOsAbsolute::~RageFileOsAbsolute() -{ - if (!m_sOsDir.empty()) - FILEMAN->Unmount("dir", m_sOsDir, TEMP_MOUNT_POINT); -} - -bool -RageFileOsAbsolute::Open(const RString& path, int mode) -{ - if (!m_sOsDir.empty()) - FILEMAN->Unmount("dir", m_sOsDir, TEMP_MOUNT_POINT); - - m_sOsDir = path; - size_t iStart = m_sOsDir.find_last_of("/\\"); - ASSERT(iStart != m_sOsDir.npos); - m_sOsDir.erase(m_sOsDir.begin() + iStart, m_sOsDir.end()); - - FILEMAN->Mount("dir", m_sOsDir, TEMP_MOUNT_POINT); - RString sFileName = path.Right(path.size() - m_sOsDir.size()); - return RageFile::Open(TEMP_MOUNT_POINT + sFileName, mode); -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/ShowComment.cpp b/src/smpackagee/ShowComment.cpp deleted file mode 100644 index 58391996e6..0000000000 --- a/src/smpackagee/ShowComment.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// ShowComment.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "ShowComment.h" -#include "archutils/Win32/DialogUtil.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// ShowComment dialog - -ShowComment::ShowComment(CWnd* pParent /*=NULL*/) - : CDialog(ShowComment::IDD, pParent) - , m_bDontShow(FALSE) -{ - //{{AFX_DATA_INIT(ShowComment) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void -ShowComment::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(ShowComment) - DDX_Control(pDX, IDC_EDIT, m_edit); - //}}AFX_DATA_MAP - DDX_Check(pDX, IDC_DONTSHOW, m_bDontShow); -} - -BEGIN_MESSAGE_MAP(ShowComment, CDialog) -//{{AFX_MSG_MAP(ShowComment) -//}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// ShowComment message handlers - -BOOL -ShowComment::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - - m_edit.SetWindowText(m_sComment); - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/ShowComment.h b/src/smpackagee/ShowComment.h deleted file mode 100644 index 4bcef49f99..0000000000 --- a/src/smpackagee/ShowComment.h +++ /dev/null @@ -1,76 +0,0 @@ -#if !defined(AFX_SHOWCOMMENT_H__1FA603E3_5CCD_4D9E_9EC9_88AD55A06270__INCLUDED_) -#define AFX_SHOWCOMMENT_H__1FA603E3_5CCD_4D9E_9EC9_88AD55A06270__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// ShowComment.h : header file - -///////////////////////////////////////////////////////////////////////////// -// ShowComment dialog - -class ShowComment : public CDialog -{ - // Construction - public: - ShowComment(CWnd* pParent = NULL); // standard constructor - - CString m_sComment; - - // Dialog Data - //{{AFX_DATA(ShowComment) - enum - { - IDD = IDD_SHOW_COMMENT - }; - CEdit m_edit; - //}}AFX_DATA - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ShowComment) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - // Generated message map functions - //{{AFX_MSG(ShowComment) - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - public: - BOOL m_bDontShow; -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_SHOWCOMMENT_H__1FA603E3_5CCD_4D9E_9EC9_88AD55A06270__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/SmpackageExportDlg.cpp b/src/smpackagee/SmpackageExportDlg.cpp deleted file mode 100644 index 8334b2b3bf..0000000000 --- a/src/smpackagee/SmpackageExportDlg.cpp +++ /dev/null @@ -1,605 +0,0 @@ -// SmpackageExportDlg.cpp : implementation file - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "SmpackageExportDlg.h" -#include "RageUtil.h" -#include "ZipArchive\ZipArchive.h" -#include "EnterName.h" -#include "EnterComment.h" -#include "smpackageUtil.h" -#include "EditInsallations.h" -#include "IniFile.h" -#include "RageFileDriverMemory.h" -#include "archutils/Win32/SpecialDirs.h" -#include "archutils/Win32/DialogUtil.h" -#include "LocalizedString.h" -#include "RageFileDriverDirect.h" -#include "arch/Dialog/Dialog.h" - -#include -#include -#include -#include ".\smpackageexportdlg.h" -using namespace std; - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -///////////////////////////////////////////////////////////////////////////// -// CSmpackageExportDlg dialog - -CSmpackageExportDlg::CSmpackageExportDlg(CWnd* pParent /*=NULL*/) - : CDialog(CSmpackageExportDlg::IDD, pParent) -{ - //{{AFX_DATA_INIT(CSmpackageExportDlg) - // NOTE: the ClassWizard will add member initialization here - //}}AFX_DATA_INIT -} - -void -CSmpackageExportDlg::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CSmpackageExportDlg) - DDX_Control(pDX, IDC_COMBO_DIR, m_comboDir); - DDX_Control( - pDX, IDC_BUTTON_EXPORT_AS_INDIVIDUAL, m_buttonExportAsIndividual); - DDX_Control(pDX, IDC_BUTTON_EXPORT_AS_ONE, m_buttonExportAsOne); - DDX_Control(pDX, IDC_TREE, m_tree); - //}}AFX_DATA_MAP -} - -BEGIN_MESSAGE_MAP(CSmpackageExportDlg, CDialog) -//{{AFX_MSG_MAP(CSmpackageExportDlg) -ON_BN_CLICKED(IDC_BUTTON_EXPORT_AS_ONE, OnButtonExportAsOne) -ON_BN_CLICKED(IDC_BUTTON_EXPORT_AS_INDIVIDUAL, OnButtonExportAsIndividual) -ON_BN_CLICKED(IDC_BUTTON_PLAY, OnButtonPlay) -ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit) -ON_CBN_SELCHANGE(IDC_COMBO_DIR, OnSelchangeComboDir) -ON_BN_CLICKED(IDC_BUTTON_OPEN, OnButtonOpen) -//}}AFX_MSG_MAP -ON_WM_CTLCOLOR() -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// CSmpackageExportDlg message handlers - -BOOL -CSmpackageExportDlg::OnInitDialog() -{ - CDialog::OnInitDialog(); - - // TODO: Add extra initialization here - DialogUtil::LocalizeDialogAndContents(*this); - - RefreshInstallationList(); - - RefreshTree(); - - return TRUE; // return TRUE unless you set the focus to a control -} - -RString -ReplaceInvalidFileNameChars(RString sOldFileName) -{ - RString sNewFileName = sOldFileName; - const char charsToReplace[] = { ' ', '!', '@', '#', '$', '%', '^', - '&', '*', '(', ')', '+', '=', '[', - ']', '{', '}', '|', ':', '\"', '\\', - '<', '>', ',', '?', '/' }; - for (int i = 0; i < sizeof(charsToReplace); i++) - sNewFileName.Replace(charsToReplace[i], '_'); - return sNewFileName; -} - -static LocalizedString ERROR_ADDING_FILE("SmpackageExportDlg", - "Error adding file '%s'."); -static bool -ExportPackage(const RString& sPackageName, - const RString& sSourceInstallDir, - const vector& asDirectoriesToExport, - const RString& sComment) -{ - CZipArchive zip; - - // - // Create the package zip file - // - const RString sPackagePath = SpecialDirs::GetDesktopDir() + sPackageName; - try { - zip.Open(sPackagePath, CZipArchive::zipCreate); - } catch (CException* e) { - e->ReportError(); - zip.Close(); - e->Delete(); - return false; - } - - zip.SetGlobalComment(sComment); - - /* Find files to add to zip. */ - vector asFilePaths; - { - RageFileDriverDirect fileDriver(sSourceInstallDir); - - for (unsigned i = 0; i < asDirectoriesToExport.size(); i++) { - RString sDir = asDirectoriesToExport[i]; - if (sDir.Right(1) != "/") - sDir += "/"; - GetDirListingRecursive(&fileDriver, sDir, "*", asFilePaths); - SMPackageUtil::StripIgnoredSmzipFiles(asFilePaths); - } - } - - // Must use backslashes in the path, or else WinZip and WinRAR don't see the - // files. Not sure if this is ZipArchive's fault. - //;XXX - - { - IniFile ini; - ini.SetValue("SMZIP", "Version", 1); - - set Directories; - for (unsigned i = 0; i < asFilePaths.size(); i++) { - const RString name = - SMPackageUtil::GetPackageDirectory(asFilePaths[i]); - if (name != "") - Directories.insert(name); - } - - set::const_iterator it; - int num = 0; - for (it = Directories.begin(); it != Directories.end(); ++it) - ini.SetValue("Packages", ssprintf("%i", num++), *it); - ini.SetValue("Packages", "NumPackages", num); - - RageFileObjMem f; - ini.WriteFile(f); - RString buf = f.GetString(); - - CZipMemFile control; - control.Write(buf.GetBuffer(0), buf.size()); - - control.Seek(0, CZipAbstractFile::begin); - zip.AddNewFile(control, "smzip.ctl"); - } - - // - // Add files to zip - // - for (unsigned j = 0; j < asFilePaths.size(); j++) { - RString sFilePath = asFilePaths[j]; - - RString sExt = GetExtension(sFilePath); - bool bUseCompression = true; - if (sExt.CompareNoCase("ogv") == 0 || sExt.CompareNoCase("avi") == 0 || - sExt.CompareNoCase("mpeg") == 0 || sExt.CompareNoCase("mpg") == 0 || - sExt.CompareNoCase("mp3") == 0 || sExt.CompareNoCase("oga") == 0 || - sExt.CompareNoCase("ogg") == 0 || sExt.CompareNoCase("gif") == 0 || - sExt.CompareNoCase("jpg") == 0 || sExt.CompareNoCase("jpeg") == 0 || - sExt.CompareNoCase("png") == 0) - bUseCompression = false; - - try { - zip.AddNewFile(sSourceInstallDir + sFilePath, - sFilePath, - bUseCompression ? Z_BEST_COMPRESSION - : Z_NO_COMPRESSION, - true); - } catch (CException* e) { - Dialog::OK( - ssprintf(ERROR_ADDING_FILE.GetValue(), sFilePath.c_str())); - zip.Close(); - e->Delete(); - return false; - } - } - - zip.Close(); - return true; -} - -bool -CSmpackageExportDlg::MakeComment(RString& comment) -{ - bool DontAskForComment; - if (SMPackageUtil::GetPref("DontAskForComment", DontAskForComment) && - DontAskForComment) { - comment = ""; - return true; - } - - EnterComment commentDlg; - int nResponse = commentDlg.DoModal(); - if (nResponse != IDOK) - return false; // cancelled - - comment = commentDlg.m_sEnteredComment; - if (commentDlg.m_bDontAsk) - SMPackageUtil::SetPref("DontAskForComment", true); - - return true; -} - -static LocalizedString NO_ITEMS_ARE_CHECKED("CSmpackageExportDlg", - "No items are checked."); -static LocalizedString SUCCESSFULLY_EXPORTED( - "CSmpackageExportDlg", - "Successfully exported package '%s' to your Desktop."); -void -CSmpackageExportDlg::OnButtonExportAsOne() -{ - vector asPaths; - GetCheckedPaths(asPaths); - - if (asPaths.size() == 0) { - Dialog::OK(NO_ITEMS_ARE_CHECKED.GetValue()); - return; - } else if (asPaths.size() == 1) { - OnButtonExportAsIndividual(); - return; - } - - // Generate a package name - RString sPackageName; - EnterName nameDlg; - int nResponse = nameDlg.DoModal(); - if (nResponse != IDOK) - return; // cancelled - sPackageName = nameDlg.m_sEnteredName; - sPackageName = ReplaceInvalidFileNameChars(sPackageName + ".smzip"); - - // Generate a comment - RString sComment; - if (!MakeComment(sComment)) - return; // cancelled - - if (ExportPackage(sPackageName, GetCurrentInstallDir(), asPaths, sComment)) - Dialog::OK( - ssprintf(SUCCESSFULLY_EXPORTED.GetValue(), sPackageName.c_str())); -} - -static LocalizedString THE_FOLLOWING_PACKAGES_WERE_EXPORTED( - "CSmpackageExportDlg", - "The following packages were exported to your Desktop:"); -static LocalizedString THE_FOLLOWING_PACKAGES_FAILED( - "CSmpackageExportDlg", - "The following packages failed to export:"); -void -CSmpackageExportDlg::OnButtonExportAsIndividual() -{ - vector asPaths; - GetCheckedPaths(asPaths); - - if (asPaths.size() == 0) { - Dialog::OK(NO_ITEMS_ARE_CHECKED.GetValue()); - return; - } - - // Generate a comment - RString sComment; - if (!MakeComment(sComment)) - return; // cancelled - - vector asExportedPackages; - vector asFailedPackages; - for (unsigned i = 0; i < asPaths.size(); i++) { - // Generate a package name for every path - RString sPath = asPaths[i]; - - RString sPackageName = ReplaceInvalidFileNameChars(sPath) + ".smzip"; - - vector asPathsToExport; - asPathsToExport.push_back(sPath); - - if (ExportPackage( - sPackageName, GetCurrentInstallDir(), asPathsToExport, sComment)) - asExportedPackages.push_back(sPackageName); - else - asFailedPackages.push_back(sPackageName); - } - - RString sMessage; - if (asExportedPackages.size() > 0) - sMessage += THE_FOLLOWING_PACKAGES_WERE_EXPORTED.GetValue() + "\n\n" + - join("\n", asExportedPackages); - - if (asFailedPackages.size() > 0) { - if (!sMessage.empty()) - sMessage += "\n\n"; - sMessage += THE_FOLLOWING_PACKAGES_FAILED.GetValue() + "\n\n" + - join("\n", asFailedPackages); - } - Dialog::OK(sMessage); -} - -void -CSmpackageExportDlg::OnButtonPlay() -{ - // TODO: Add your control notification handler code here - SMPackageUtil::LaunchGame(); - exit(0); -} - -void -CSmpackageExportDlg::GetTreeItems(CArray& aItemsOut) -{ - CArray aRootsToExplore; - - // add all top-level roots - HTREEITEM item = m_tree.GetRootItem(); - while (item != NULL) { - aRootsToExplore.Add(item); - item = m_tree.GetNextSiblingItem(item); - } - - while (aRootsToExplore.GetSize() > 0) { - HTREEITEM item = aRootsToExplore[0]; - aRootsToExplore.RemoveAt(0); - aItemsOut.Add(item); - - HTREEITEM child = m_tree.GetChildItem(item); - while (child != NULL) { - aRootsToExplore.Add(child); - child = m_tree.GetNextSiblingItem(child); - } - } -} - -void -CSmpackageExportDlg::GetCheckedTreeItems( - CArray& aCheckedItemsOut) -{ - CArray aItems; - - GetTreeItems(aItems); - for (int i = 0; i < aItems.GetSize(); i++) - if (m_tree.GetCheck(aItems[i])) - aCheckedItemsOut.Add(aItems[i]); -} - -void -CSmpackageExportDlg::GetCheckedPaths(vector& aPathsOut) -{ - CArray aItems; - - GetCheckedTreeItems(aItems); - for (int i = 0; i < aItems.GetSize(); i++) { - HTREEITEM item = aItems[i]; - - RString sPath; - - while (item) { - sPath = RString((LPCTSTR)m_tree.GetItemText(item)) + '/' + sPath; - item = m_tree.GetParentItem(item); - } - - TrimRight(sPath, "/"); // strip off last slash - - aPathsOut.push_back(sPath); - } -} - -void -CSmpackageExportDlg::OnButtonEdit() -{ - // TODO: Add your control notification handler code here - EditInsallations dlg; - int nResponse = dlg.DoModal(); - if (nResponse == IDOK) { - RefreshInstallationList(); - RefreshTree(); - } -} - -void -CSmpackageExportDlg::RefreshInstallationList() -{ - m_comboDir.ResetContent(); - - vector asInstallDirs; - SMPackageUtil::GetGameInstallDirs(asInstallDirs); - for (unsigned i = 0; i < asInstallDirs.size(); i++) { - m_comboDir.AddString(asInstallDirs[i]); - } - m_comboDir.SetCurSel(0); // guaranteed to be at least one item -} - -void -CSmpackageExportDlg::OnSelchangeComboDir() -{ - // TODO: Add your control notification handler code here - RefreshTree(); -} - -RString -CSmpackageExportDlg::GetCurrentInstallDir() -{ - CString s; - m_comboDir.GetWindowText(s); - RString s2 = s; - if (s2.Right(1) != "/") - s2 += "/"; - return s2; -} - -void -CSmpackageExportDlg::RefreshTree() -{ - m_tree.DeleteAllItems(); - - RageFileDriverDirect fileDriver(GetCurrentInstallDir()); - - // Add announcers - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("Announcers"); - fileDriver.GetDirListing("Announcers/*", as1, true, false); - for (unsigned i = 0; i < as1.size(); i++) - m_tree.InsertItem(as1[i], item1); - } - - // Add characters - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("Characters"); - fileDriver.GetDirListing("Characters/*", as1, true, false); - for (unsigned i = 0; i < as1.size(); i++) - m_tree.InsertItem(as1[i], item1); - } - - // Add themes - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("Themes"); - fileDriver.GetDirListing("Themes/*", as1, true, false); - for (unsigned i = 0; i < as1.size(); i++) - m_tree.InsertItem(as1[i], item1); - } - - // Add BGAnimations - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("BGAnimations"); - fileDriver.GetDirListing("BGAnimations/*", as1, true, false); - for (unsigned i = 0; i < as1.size(); i++) - m_tree.InsertItem(as1[i], item1); - } - - // Add RandomMovies - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("RandomMovies"); - fileDriver.GetDirListing("RandomMovies/*.ogv", as1, false, false); - fileDriver.GetDirListing("RandomMovies/*.avi", as1, false, false); - fileDriver.GetDirListing("RandomMovies/*.mpg", as1, false, false); - fileDriver.GetDirListing("RandomMovies/*.mpeg", as1, false, false); - for (unsigned i = 0; i < as1.size(); i++) - m_tree.InsertItem(as1[i], item1); - } - - // Add visualizations - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("Visualizations"); - fileDriver.GetDirListing("Visualizations/*.ogv", as1, false, false); - fileDriver.GetDirListing("Visualizations/*.avi", as1, false, false); - fileDriver.GetDirListing("Visualizations/*.mpg", as1, false, false); - fileDriver.GetDirListing("Visualizations/*.mpeg", as1, false, false); - for (unsigned i = 0; i < as1.size(); i++) - m_tree.InsertItem(as1[i], item1); - } - - // Add courses - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("Courses"); - fileDriver.GetDirListing("Courses/*.crs", as1, false, false); - for (unsigned i = 0; i < as1.size(); i++) { - as1[i] = as1[i].Left(as1[i].size() - 4); // strip off ".crs" - m_tree.InsertItem(as1[i], item1); - } - } - - // - // Add NoteSkins - // - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("NoteSkins"); - fileDriver.GetDirListing("NoteSkins/*", as1, true, false); - for (unsigned i = 0; i < as1.size(); i++) { - vector as2; - HTREEITEM item2 = m_tree.InsertItem(as1[i], item1); - fileDriver.GetDirListing( - "NoteSkins/" + as1[i] + "/*", as2, true, false); - for (unsigned j = 0; j < as2.size(); j++) - m_tree.InsertItem(as2[j], item2); - } - } - - // - // Add Songs - // - { - vector as1; - HTREEITEM item1 = m_tree.InsertItem("Songs"); - fileDriver.GetDirListing("Songs/*", as1, true, false); - for (unsigned i = 0; i < as1.size(); i++) { - vector as2; - HTREEITEM item2 = m_tree.InsertItem(as1[i], item1); - fileDriver.GetDirListing( - "Songs/" + as1[i] + "/*", as2, true, false); - for (unsigned j = 0; j < as2.size(); j++) - m_tree.InsertItem(as2[j], item2); - } - } - - // Strip out any CVS/.svn items - CArray aItems; - GetTreeItems(aItems); - for (int i = 0; i < aItems.GetSize(); i++) { - if (m_tree.GetItemText(aItems[i]).CompareNoCase("CVS") == 0 || - m_tree.GetItemText(aItems[i]).CompareNoCase(".svn") == 0) - m_tree.DeleteItem(aItems[i]); - } -} - -void -CSmpackageExportDlg::OnButtonOpen() -{ - // TODO: Add your control notification handler code here - - char szCurDir[MAX_PATH]; - GetCurrentDirectory(MAX_PATH, szCurDir); - - char szCommandToExecute[MAX_PATH] = "explorer "; - strcat(szCommandToExecute, szCurDir); - - PROCESS_INFORMATION pi; - STARTUPINFO si; - ZeroMemory(&si, sizeof(si)); - - CreateProcess(NULL, // pointer to name of executable module - szCommandToExecute, // pointer to command line string - NULL, // process security attributes - NULL, // thread security attributes - false, // handle inheritance flag - 0, // creation flags - NULL, // pointer to new environment block - NULL, // pointer to current directory name - &si, // pointer to STARTUPINFO - &pi // pointer to PROCESS_INFORMATION - ); -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/SmpackageExportDlg.h b/src/smpackagee/SmpackageExportDlg.h deleted file mode 100644 index 1351700a2e..0000000000 --- a/src/smpackagee/SmpackageExportDlg.h +++ /dev/null @@ -1,94 +0,0 @@ -#if !defined( \ - AFX_SMPACKAGEEXPORTDLG_H__3E19CBFB_E8F6_4C18_B0A4_636979B80A4D__INCLUDED_) -#define AFX_SMPACKAGEEXPORTDLG_H__3E19CBFB_E8F6_4C18_B0A4_636979B80A4D__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "afxtempl.h" - -// SmpackageExportDlg.h : header file - -///////////////////////////////////////////////////////////////////////////// -// CSmpackageExportDlg dialog - -class CSmpackageExportDlg : public CDialog -{ - // Construction - public: - CSmpackageExportDlg(CWnd* pParent = NULL); // standard constructor - - // Dialog Data - //{{AFX_DATA(CSmpackageExportDlg) - enum - { - IDD = IDD_EXPORTER - }; - CComboBox m_comboDir; - CButton m_buttonExportAsIndividual; - CButton m_buttonExportAsOne; - CTreeCtrl m_tree; - //}}AFX_DATA - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSmpackageExportDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - void RefreshInstallationList(); - void RefreshTree(); - void GetTreeItems(CArray& aItemsOut); - void GetCheckedTreeItems(CArray& aCheckedItemsOut); - void GetCheckedPaths(vector& aCheckedItemsOut); - bool MakeComment(RString& comment); - RString GetCurrentInstallDir(); - - // Generated message map functions - //{{AFX_MSG(CSmpackageExportDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnButtonExportAsOne(); - afx_msg void OnButtonExportAsIndividual(); - afx_msg void OnButtonPlay(); - afx_msg void OnButtonEdit(); - afx_msg void OnSelchangeComboDir(); - afx_msg void OnButtonOpen(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - public: -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_SMPACKAGEEXPORTDLG_H__3E19CBFB_E8F6_4C18_B0A4_636979B80A4D__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/StdAfx.cpp b/src/smpackagee/StdAfx.cpp deleted file mode 100644 index 92ba9f4701..0000000000 --- a/src/smpackagee/StdAfx.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// smpackage.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" diff --git a/src/smpackagee/StdAfx.h b/src/smpackagee/StdAfx.h deleted file mode 100644 index f1cf81fffa..0000000000 --- a/src/smpackagee/StdAfx.h +++ /dev/null @@ -1,67 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#if !defined(AFX_STDAFX_H__D450D5ED_5C49_4A8B_B887_076F62424F1F__INCLUDED_) -#define AFX_STDAFX_H__D450D5ED_5C49_4A8B_B887_076F62424F1F__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#pragma warning(disable : 4786) // turn off broken debugger warning - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers - -// prevent windows includes from pulling in debug CRTs: -#if defined(_DEBUG) -#undef _DEBUG -#define RESTORE_DEBUG -#endif - -#include // MFC core and standard components -#include // MFC extensions -#include // MFC support for Internet Explorer 4 Common Controls -#ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT - -#if defined(RESTORE_DEBUG) -#undef RESTORE_DEBUG -#define _DEBUG -#endif - -#include -using namespace std; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_STDAFX_H__D450D5ED_5C49_4A8B_B887_076F62424F1F__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/TreeCtrlEx.cpp b/src/smpackagee/TreeCtrlEx.cpp deleted file mode 100644 index 0ff7fb1864..0000000000 --- a/src/smpackagee/TreeCtrlEx.cpp +++ /dev/null @@ -1,183 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// Author: Sami (M.ALSAMSAM), ittiger@ittiger.net -// -// Filename: TreeCtrlEx.cpp -// -// http : www.ittiger.net -// -////////////////////////////////////////////////////////////// -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "TreeCtrlEx.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#define new DEBUG_NEW -#endif - -////////////////////////////////// -CTreeCtrlEx::CTreeCtrlEx() {} - -CTreeCtrlEx::~CTreeCtrlEx() {} - -////////////////////////////////// -IMPLEMENT_DYNAMIC(CTreeCtrlEx, CTreeCtrl) - -BEGIN_MESSAGE_MAP(CTreeCtrlEx, CTreeCtrl) -//{{AFX_MSG_MAP(CTreeCtrlEx) -ON_WM_PAINT() -//}}AFX_MSG_MAP -END_MESSAGE_MAP() - -////////////////////////////////////////////////////////////////////// -void -CTreeCtrlEx::SetItemFont(HTREEITEM hItem, LOGFONT& logfont) -{ - Color_Font cf; - if (!m_mapColorFont.Lookup(hItem, cf)) - cf.color = (COLORREF)-1; - cf.logfont = logfont; - m_mapColorFont[hItem] = cf; -} - -////////////////////////////////////////////////////////////////////// -void -CTreeCtrlEx::SetItemBold(HTREEITEM hItem, BOOL bBold) -{ - SetItemState(hItem, bBold ? TVIS_BOLD : 0, TVIS_BOLD); -} - -////////////////////////////////////////////////////////////////////// -void -CTreeCtrlEx::SetItemColor(HTREEITEM hItem, COLORREF color) -{ - Color_Font cf; - if (!m_mapColorFont.Lookup(hItem, cf)) - cf.logfont.lfFaceName[0] = '\0'; - cf.color = color; - m_mapColorFont[hItem] = cf; -} - -////////////////////////////////////////////////////////////////////// -BOOL -CTreeCtrlEx::GetItemFont(HTREEITEM hItem, LOGFONT* plogfont) -{ - Color_Font cf; - if (!m_mapColorFont.Lookup(hItem, cf)) - return FALSE; - if (cf.logfont.lfFaceName[0] == '\0') - return FALSE; - *plogfont = cf.logfont; - return TRUE; -} - -////////////////////////////////////////////////////////////////////// -BOOL -CTreeCtrlEx::GetItemBold(HTREEITEM hItem) -{ - return GetItemState(hItem, TVIS_BOLD) & TVIS_BOLD; -} - -////////////////////////////////////////////////////////////////////// -COLORREF -CTreeCtrlEx::GetItemColor(HTREEITEM hItem) -{ - // Returns (COLORREF)-1 if color was not set - Color_Font cf; - if (!m_mapColorFont.Lookup(hItem, cf)) - return (COLORREF)-1; - return cf.color; -} - -////////////////////////////////////////////////////////////////////// -void -CTreeCtrlEx::OnPaint() -{ - CPaintDC dc(this); - - // Create a memory DC compatible with the paint DC - CDC memDC; - memDC.CreateCompatibleDC(&dc); - - CRect rcClip, rcClient; - dc.GetClipBox(&rcClip); - GetClientRect(&rcClient); - - // Select a compatible bitmap into the memory DC - CBitmap bitmap; - bitmap.CreateCompatibleBitmap(&dc, rcClient.Width(), rcClient.Height()); - memDC.SelectObject(&bitmap); - - // Set clip region to be same as that in paint DC - CRgn rgn; - rgn.CreateRectRgnIndirect(&rcClip); - memDC.SelectClipRgn(&rgn); - rgn.DeleteObject(); - - // First let the control do its default drawing. - CWnd::DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0); - - HTREEITEM hItem = GetFirstVisibleItem(); - - int iItemCount = GetVisibleCount() + 1; - while (hItem && iItemCount--) { - CRect rect; - - // Do not meddle with selected items or drop highlighted items - UINT selflag = TVIS_DROPHILITED | TVIS_SELECTED; - Color_Font cf; - - // if ( !(GetTreeCtrl().GetItemState( hItem, selflag ) & selflag ) - // && m_mapColorFont.Lookup( hItem, cf )) - - if ((GetItemState(hItem, selflag) & selflag) && ::GetFocus() == m_hWnd) - ; - else if (m_mapColorFont.Lookup(hItem, cf)) { - CFont* pFontDC; - CFont fontDC; - LOGFONT logfont; - - if (cf.logfont.lfFaceName[0] != '\0') - logfont = cf.logfont; - else { - // No font specified, so use window font - CFont* pFont = GetFont(); - pFont->GetLogFont(&logfont); - } - - if (GetItemBold(hItem)) - logfont.lfWeight = 700; - - fontDC.CreateFontIndirect(&logfont); - pFontDC = memDC.SelectObject(&fontDC); - - if (cf.color != (COLORREF)-1) - memDC.SetTextColor(cf.color); - else - memDC.SetTextColor(GetSysColor(COLOR_WINDOWTEXT)); - - CString sItem = GetItemText(hItem); - - GetItemRect(hItem, &rect, TRUE); - memDC.SetBkColor(GetSysColor(COLOR_WINDOW)); - memDC.TextOut(rect.left + 2, rect.top + 1, sItem); - - memDC.SelectObject(pFontDC); - } - hItem = GetNextVisibleItem(hItem); - } - - dc.BitBlt(rcClip.left, - rcClip.top, - rcClip.Width(), - rcClip.Height(), - &memDC, - rcClip.left, - rcClip.top, - SRCCOPY); - - memDC.DeleteDC(); -} diff --git a/src/smpackagee/TreeCtrlEx.h b/src/smpackagee/TreeCtrlEx.h deleted file mode 100644 index 9103fc973e..0000000000 --- a/src/smpackagee/TreeCtrlEx.h +++ /dev/null @@ -1,51 +0,0 @@ -///////////////////////////////////////////////////////////// -// -// Author: Sami (M.ALSAMSAM), ittiger@ittiger.net -// -// Filename: TreeCtrlEx.h -// -// http : www.ittiger.net -// -////////////////////////////////////////////////////////////// -#if !defined(AFX_TREECTRLEX_H__5D969ED4_7DEA_4FB5_8C1D_E12D1CCF0989__INCLUDED_) -#define AFX_TREECTRLEX_H__5D969ED4_7DEA_4FB5_8C1D_E12D1CCF0989__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include - -////////////////////////////////////////////////////////////////////// -class CTreeCtrlEx : public CTreeCtrl -{ - DECLARE_DYNAMIC(CTreeCtrlEx) - - public: - CTreeCtrlEx(); - virtual ~CTreeCtrlEx(); - - void SetItemFont(HTREEITEM, LOGFONT&); - void SetItemBold(HTREEITEM, BOOL); - void SetItemColor(HTREEITEM, COLORREF); - BOOL GetItemFont(HTREEITEM, LOGFONT*); - BOOL GetItemBold(HTREEITEM); - COLORREF GetItemColor(HTREEITEM); - - protected: - struct Color_Font - { - COLORREF color; - LOGFONT logfont; - }; - - CMap m_mapColorFont; - - protected: - //{{AFX_MSG(CTreeCtrlEx) - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -#endif // !defined(AFX_TREECTRLEX_H__5D969ED4_7DEA_4FB5_8C1D_E12D1CCF0989__INCLUDED_) diff --git a/src/smpackagee/UninstallOld.cpp b/src/smpackagee/UninstallOld.cpp deleted file mode 100644 index 9bca889888..0000000000 --- a/src/smpackagee/UninstallOld.cpp +++ /dev/null @@ -1,83 +0,0 @@ -// UninstallOld.cpp : implementation file -// - -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "UninstallOld.h" -#include "SMPackageUtil.h" -#include "archutils/Win32/DialogUtil.h" - -// UninstallOld dialog - -UninstallOld::UninstallOld(CWnd* pParent /*=NULL*/) - : CDialog(UninstallOld::IDD, pParent) - , m_sPackages(_T("")) -{ -} - -UninstallOld::~UninstallOld() {} - -BOOL -UninstallOld::OnInitDialog() -{ - CDialog::OnInitDialog(); - - DialogUtil::LocalizeDialogAndContents(*this); - - GetDlgItem(IDC_PACKAGES)->SetWindowText(m_sPackages); - - return TRUE; // return TRUE unless you set the focus to a control -} - -BEGIN_MESSAGE_MAP(UninstallOld, CDialog) -//{{AFX_MSG_MAP(UninstallOld) -//}}AFX_MSG_MAP -ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedNo) -END_MESSAGE_MAP() - -// UninstallOld message handlers - -void -UninstallOld::OnOK() -{ - EndDialog(IDOK); -} - -void -UninstallOld::OnCancel() -{ - EndDialog(IDCANCEL); -} - -void -UninstallOld::OnBnClickedNo() -{ - EndDialog(IDIGNORE); -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/UninstallOld.h b/src/smpackagee/UninstallOld.h deleted file mode 100644 index 8d7be352da..0000000000 --- a/src/smpackagee/UninstallOld.h +++ /dev/null @@ -1,52 +0,0 @@ -#pragma once - -// UninstallOld dialog - -class UninstallOld : public CDialog -{ - public: - UninstallOld(CWnd* pParent = NULL); // standard constructor - virtual ~UninstallOld(); - // Overrides - - // Dialog Data - enum - { - IDD = IDD_UNINSTALL_OLD_PACKAGES - }; - - protected: - virtual BOOL OnInitDialog(); - void OnOK(); - void OnCancel(); - - DECLARE_MESSAGE_MAP() - public: - CString m_sPackages; - afx_msg void OnBnClickedNo(); -}; - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/ZipArchive/Appnote.txt b/src/smpackagee/ZipArchive/Appnote.txt deleted file mode 100644 index ae2eeaf101..0000000000 --- a/src/smpackagee/ZipArchive/Appnote.txt +++ /dev/null @@ -1,1351 +0,0 @@ -File: APPNOTE.TXT - .ZIP File Format Specification -Version: 4.0 -Revised: 11/01/2000 - -Disclaimer ----------- - -Although PKWARE will attempt to supply current and accurate -information relating to its file formats, algorithms, and the -subject programs, the possibility of error can not be eliminated. -PKWARE therefore expressly disclaims any warranty that the -information contained in the associated materials relating to the -subject programs and/or the format of the files created or -accessed by the subject programs and/or the algorithms used by -the subject programs, or any other matter, is current, correct or -accurate as delivered. Any risk of damage due to any possible -inaccurate information is assumed by the user of the information. -Furthermore, the information relating to the subject programs -and/or the file formats created or accessed by the subject -programs and/or the algorithms used by the subject programs is -subject to change without notice. - -General Format of a .ZIP file ------------------------------ - - Files stored in arbitrary order. Large .ZIP files can span multiple - diskette media or be split into user-defined segment sizes. The - minimum user-defined segment size for a split .ZIP file is 64K. - - Overall .ZIP file format: - - [local file header 1] - [file data 1] - [data descriptor 1] - . - . - . - [local file header n] - [file data n] - [data descriptor n] - [central directory] - - - A. Local file header: - - local file header signature 4 bytes (0x04034b50) - version needed to extract 2 bytes - general purpose bit flag 2 bytes - compression method 2 bytes - last mod file time 2 bytes - last mod file date 2 bytes - crc-32 4 bytes - compressed size 4 bytes - uncompressed size 4 bytes - filename length 2 bytes - extra field length 2 bytes - - filename (variable size) - extra field (variable size) - - B. File data - - Immediately following the local header for a file - is the compressed or stored data for the file. - The series of [local file header][file data][data - descriptor] repeats for each file in the .ZIP archive. - - C. Data descriptor: - - crc-32 4 bytes - compressed size 4 bytes - uncompressed size 4 bytes - - This descriptor exists only if bit 3 of the general - purpose bit flag is set (see below). It is byte aligned - and immediately follows the last byte of compressed data. - This descriptor is used only when it was not possible to - seek in the output .ZIP file, e.g., when the output .ZIP file - was standard output or a non seekable device. - - D. Central directory structure: - - [file header 1] - . - . - . - [file header n] - [digital signature] - [end of central directory record] - - File header: - - central file header signature 4 bytes (0x02014b50) - version made by 2 bytes - version needed to extract 2 bytes - general purpose bit flag 2 bytes - compression method 2 bytes - last mod file time 2 bytes - last mod file date 2 bytes - crc-32 4 bytes - compressed size 4 bytes - uncompressed size 4 bytes - filename length 2 bytes - extra field length 2 bytes - file comment length 2 bytes - disk number start 2 bytes - internal file attributes 2 bytes - external file attributes 4 bytes - relative offset of local header 4 bytes - - filename (variable size) - extra field (variable size) - file comment (variable size) - - Digital signature: - - header signature 4 bytes (0x05054b50) - size of data 2 bytes - signature data (variable size) - - End of central directory record: - - end of central dir signature 4 bytes (0x06054b50) - number of this disk 2 bytes - number of the disk with the - start of the central directory 2 bytes - total number of entries in - the central dir on this disk 2 bytes - total number of entries in - the central dir 2 bytes - size of the central directory 4 bytes - offset of start of central - directory with respect to - the starting disk number 4 bytes - .ZIP file comment length 2 bytes - .ZIP file comment (variable size) - - E. Explanation of fields: - - version made by (2 bytes) - - The upper byte indicates the compatibility of the file - attribute information. If the external file attributes - are compatible with MS-DOS and can be read by PKZIP for - DOS version 2.04g then this value will be zero. If these - attributes are not compatible, then this value will - identify the host system on which the attributes are - compatible. Software can use this information to determine - the line record format for text files etc. The current - mappings are: - - 0 - MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems) - 1 - Amiga 2 - OpenVMS - 3 - Unix 4 - VM/CMS - 5 - Atari ST 6 - OS/2 H.P.F.S. - 7 - Macintosh 8 - Z-System - 9 - CP/M 10 - Windows NTFS - 11 thru 255 - unused - - The lower byte indicates the version number of the - software used to encode the file. The value/10 - indicates the major version number, and the value - mod 10 is the minor version number. - - version needed to extract (2 bytes) - - The minimum software version needed to extract the - file, mapped as above. - - general purpose bit flag: (2 bytes) - - Bit 0: If set, indicates that the file is encrypted. - - (For Method 6 - Imploding) - Bit 1: If the compression method used was type 6, - Imploding, then this bit, if set, indicates - an 8K sliding dictionary was used. If clear, - then a 4K sliding dictionary was used. - Bit 2: If the compression method used was type 6, - Imploding, then this bit, if set, indicates - 3 Shannon-Fano trees were used to encode the - sliding dictionary output. If clear, then 2 - Shannon-Fano trees were used. - - (For Methods 8 and 9 - Deflating) - Bit 2 Bit 1 - 0 0 Normal (-en) compression option was used. - 0 1 Maximum (-exx/-ex) compression option was used. - 1 0 Fast (-ef) compression option was used. - 1 1 Super Fast (-es) compression option was used. - - Note: Bits 1 and 2 are undefined if the compression - method is any other. - - Bit 3: If this bit is set, the fields crc-32, compressed - size and uncompressed size are set to zero in the - local header. The correct values are put in the - data descriptor immediately following the compressed - data. (Note: PKZIP version 2.04g for DOS only - recognizes this bit for method 8 compression, newer - versions of PKZIP recognize this bit for any - compression method.) - - Bit 4: Reserved for use with method 8, for enhanced - deflating. - - Bit 5: If this bit is set, this indicates that the file is - compressed patched data. (Note: Requires PKZIP - version 2.70 or greater) - - Bit 6: Currently unused. - - Bit 7: Currently unused. - - Bit 8: Currently unused. - - Bit 9: Currently unused. - - Bit 10: Currently unused. - - Bit 11: Currently unused. - - Bit 12: Reserved by PKWARE for enhanced compression. - - Bit 13: Reserved by PKWARE. - - Bit 14: Reserved by PKWARE. - - Bit 15: Reserved by PKWARE. - - compression method: (2 bytes) - - (see accompanying documentation for algorithm - descriptions) - - 0 - The file is stored (no compression) - 1 - The file is Shrunk - 2 - The file is Reduced with compression factor 1 - 3 - The file is Reduced with compression factor 2 - 4 - The file is Reduced with compression factor 3 - 5 - The file is Reduced with compression factor 4 - 6 - The file is Imploded - 7 - Reserved for Tokenizing compression algorithm - 8 - The file is Deflated - 9 - Enhanced Deflating using Deflate64(tm) - 10 - PKWARE Date Compression Library Imploding - - date and time fields: (2 bytes each) - - The date and time are encoded in standard MS-DOS format. - If input came from standard input, the date and time are - those at which compression was started for this data. - - CRC-32: (4 bytes) - - The CRC-32 algorithm was generously contributed by - David Schwaderer and can be found in his excellent - book "C Programmers Guide to NetBIOS" published by - Howard W. Sams & Co. Inc. The 'magic number' for - the CRC is 0xdebb20e3. The proper CRC pre and post - conditioning is used, meaning that the CRC register - is pre-conditioned with all ones (a starting value - of 0xffffffff) and the value is post-conditioned by - taking the one's complement of the CRC residual. - If bit 3 of the general purpose flag is set, this - field is set to zero in the local header and the correct - value is put in the data descriptor and in the central - directory. - - compressed size: (4 bytes) - uncompressed size: (4 bytes) - - The size of the file compressed and uncompressed, - respectively. If bit 3 of the general purpose bit flag - is set, these fields are set to zero in the local header - and the correct values are put in the data descriptor and - in the central directory. - - filename length: (2 bytes) - extra field length: (2 bytes) - file comment length: (2 bytes) - - The length of the filename, extra field, and comment - fields respectively. The combined length of any - directory record and these three fields should not - generally exceed 65,535 bytes. If input came from standard - input, the filename length is set to zero. - - disk number start: (2 bytes) - - The number of the disk on which this file begins. - - internal file attributes: (2 bytes) - - The lowest bit of this field indicates, if set, that - the file is apparently an ASCII or text file. If not - set, that the file apparently contains binary data. - The remaining bits are unused in version 1.0. - - Bits 1 and 2 are reserved for use by PKWARE. - - external file attributes: (4 bytes) - - The mapping of the external attributes is - host-system dependent (see 'version made by'). For - MS-DOS, the low order byte is the MS-DOS directory - attribute byte. If input came from standard input, this - field is set to zero. - - relative offset of local header: (4 bytes) - - This is the offset from the start of the first disk on - which this file appears, to where the local header should - be found. - - filename: (Variable) - - The name of the file, with optional relative path. - The path stored should not contain a drive or - device letter, or a leading slash. All slashes - should be forward slashes '/' as opposed to - backwards slashes '\' for compatibility with Amiga - and Unix file systems etc. If input came from standard - input, there is no filename field. - - extra field: (Variable) - - This is for expansion. If additional information - needs to be stored for special needs or for specific - platforms, it should be stored here. Earlier versions - of the software can then safely skip this file, and - find the next file or header. This field will be 0 - length in version 1.0. - - In order to allow different programs and different types - of information to be stored in the 'extra' field in .ZIP - files, the following structure should be used for all - programs storing data in this field: - - header1+data1 + header2+data2 . . . - - Each header should consist of: - - Header ID - 2 bytes - Data Size - 2 bytes - - Note: all fields stored in Intel low-byte/high-byte order. - - The Header ID field indicates the type of data that is in - the following data block. - - Header ID's of 0 thru 31 are reserved for use by PKWARE. - The remaining ID's can be used by third party vendors for - proprietary usage. - - The current Header ID mappings defined by PKWARE are: - - 0x0007 AV Info - 0x0009 OS/2 - 0x000a NTFS - 0x000c OpenVMS - 0x000d Unix - 0x000f Patch Descriptor - 0x0014 PKCS#7 Store for X.509 Certificates - 0x0015 X.509 Certificate ID and Signature for - individual file - 0x0016 X.509 Certificate ID for Central Directory - - Several third party mappings commonly used are: - - 0x4b46 FWKCS MD5 (see below) - 0x07c8 Macintosh - 0x4341 Acorn/SparkFS - 0x4453 Windows NT security descriptor (binary ACL) - 0x4704 VM/CMS - 0x470f MVS - 0x4c41 OS/2 access control list (text ACL) - 0x4d49 Info-ZIP OpenVMS - 0x5455 extended timestamp - 0x5855 Info-ZIP Unix (original, also OS/2, NT, etc) - 0x6542 BeOS/BeBox - 0x756e ASi Unix - 0x7855 Info-ZIP Unix (new) - 0xfd4a SMS/QDOS - - The Data Size field indicates the size of the following - data block. Programs can use this value to skip to the - next header block, passing over any data blocks that are - not of interest. - - Note: As stated above, the size of the entire .ZIP file - header, including the filename, comment, and extra - field should not exceed 64K in size. - - In case two different programs should appropriate the same - Header ID value, it is strongly recommended that each - program place a unique signature of at least two bytes in - size (and preferably 4 bytes or bigger) at the start of - each data area. Every program should verify that its - unique signature is present, in addition to the Header ID - value being correct, before assuming that it is a block of - known type. - - -OS/2 Extra Field: - - The following is the layout of the OS/2 attributes "extra" - block. (Last Revision 09/05/95) - - Note: all fields stored in Intel low-byte/high-byte order. - - Value Size Description - ----- ---- ----------- - (OS/2) 0x0009 2 bytes Tag for this "extra" block type - TSize 2 bytes Size for the following data block - BSize 4 bytes Uncompressed Block Size - CType 2 bytes Compression type - EACRC 4 bytes CRC value for uncompress block - (var) variable Compressed block - - The OS/2 extended attribute structure (FEA2LIST) is - compressed and then stored in it's entirety within this - structure. There will only ever be one "block" of data in - VarFields[]. - - -UNIX Extra Field: - - The following is the layout of the Unix "extra" block. - Note: all fields are stored in Intel low-byte/high-byte - order. - - Value Size Description - ----- ---- ----------- - (UNIX) 0x000d 2 bytes Tag for this "extra" block type - TSize 2 bytes Size for the following data block - Atime 4 bytes File last access time - Mtime 4 bytes File last modification time - Uid 2 bytes File user ID - Gid 2 bytes File group ID - (var) variable Variable length data field - - The variable length data field will contain file type - specific data. Currently the only values allowed are - the original "linked to" file names for hard or symbolic - links, and the major and minor device node numbers for - character and block device nodes. Since device nodes - cannot be either symbolic or hard links, only one set of - variable length data is stored. Link files will have the - name of the original file stored. This name is NOT NULL - terminated. Its size can be determined by checking TSize - - 12. Device entries will have eight bytes stored as two 4 - byte entries (in little endian format). The first entry - will be the major device number, and the second the minor - device number. - - - -OpenVMS Extra Field: - - The following is the layout of the OpenVMS attributes - "extra" block. - - Note: all fields stored in Intel low-byte/high-byte order. - - Value Size Description - ----- ---- ----------- - (VMS) 0x000c 2 bytes Tag for this "extra" block type - TSize 2 bytes Size of the total "extra" block - CRC 4 bytes 32-bit CRC for remainder of the block - Tag1 2 bytes OpenVMS attribute tag value #1 - Size1 2 bytes Size of attribute #1, in bytes - (var.) Size1 Attribute #1 data - . - . - . - TagN 2 bytes OpenVMS attribute tage value #N - SizeN 2 bytes Size of attribute #N, in bytes - (var.) SizeN Attribute #N data - - Rules: - - 1. There will be one or more of attributes present, which - will each be preceded by the above TagX & SizeX values. - These values are identical to the ATR$C_XXXX and - ATR$S_XXXX constants which are defined in ATR.H under - OpenVMS C. Neither of these values will ever be zero. - - 2. No word alignment or padding is performed. - - 3. A well-behaved PKZIP/OpenVMS program should never produce - more than one sub-block with the same TagX value. Also, - there will never be more than one "extra" block of type - 0x000c in a particular directory record. - - -NTFS Extra Field: - - The following is the layout of the NTFS attributes - "extra" block. (Note: At this time the Mtime, Atime - and Ctime values may be used on any WIN32 system.) - - Note: all fields stored in Intel low-byte/high-byte order. - - Value Size Description - ----- ---- ----------- - (NTFS) 0x000a 2 bytes Tag for this "extra" block type - TSize 2 bytes Size of the total "extra" block - Reserved 4 bytes Reserved for future use - Tag1 2 bytes NTFS attribute tag value #1 - Size1 2 bytes Size of attribute #1, in bytes - (var.) Size1 Attribute #1 data - . - . - . - TagN 2 bytes NTFS attribute tage value #N - SizeN 2 bytes Size of attribute #N, in bytes - (var.) SizeN Attribute #N data - - For NTFS, values for Tag1 through TagN are as follows: - (currently only one set of attributes is defined for NTFS) - - Tag Size Description - ----- ---- ----------- - 0x0001 2 bytes Tag for attribute #1 - Size1 2 bytes Size of attribute #1, in bytes - Mtime 8 bytes File last modification time - Atime 8 bytes File last access time - Ctime 8 bytes File creation time - - -PATCH Descriptor Extra Field: - - The following is the layout of the Patch Descriptor "extra" - block. - - Note: all fields stored in Intel low-byte/high-byte order. - - Value Size Description - ----- ---- ----------- - (Patch) 0x000f 2 bytes Tag for this "extra" block type - TSize 2 bytes Size of the total "extra" block - Version 2 bytes Version of the descriptor - Flags 4 bytes Actions and reactions (see below) - OldSize 4 bytes Size of the file about to be patched - OldCRC 4 bytes 32-bit CRC of the file to be patched - NewSize 4 bytes Size of the resulting file - NewCRC 4 bytes 32-bit CRC of the resulting file - - Actions and reactions - - Bits Description - ---- ---------------- - 0 Use for autodetection - 1 Treat as selfpatch - 2-3 RESERVED - 4-5 Action (see below) - 6-7 RESERVED - 8-9 Reaction (see below) to absent file - 10-11 Reaction (see below) to newer file - 12-13 Reaction (see below) to unknown file - 14-15 RESERVED - 16-31 RESERVED - - Actions - - Action Value - ------ ----- - none 0 - add 1 - delete 2 - patch 3 - - Reactions - - Reaction Value - -------- ----- - ask 0 - skip 1 - ignore 2 - fail 3 - - -PKCS#7 Store for X.509 Certificates - - This field is contains the information about each - certificate a file is signed with. This field should only - appear in the first central directory record, and will be - ignored in any other record. - - Note: all fields stored in Intel low-byte/high-byte order. - - Value Size Description - ----- ---- ----------- - (Store) 0x0014 2 bytes Tag for this "extra" block type - SSize 2 bytes Size of the store data - SData (variable) Data about the store - - SData - Value Size Description - ----- ---- ----------- - Version 2 bytes Version number, 0x0001 for now - StoreD (variable) Actual store data - - The StoreD member is suitable for passing as the pbData - member of a CRYPT_DATA_BLOB to the CertOpenStore() function - in Microsoft's CryptoAPI. The SSize member above will be - cbData + 6, where cbData is the cbData member of the same - CRYPT_DATA_BLOB. The encoding type to pass to - CertOpenStore() should be - PKCS_7_ANS_ENCODING | X509_ASN_ENCODING. - - -X.509 Certificate ID and Signature for individual file - - This field contains the information about which certificate - in the PKCS#7 Store was used to sign the particular file. - It also contains the signature data. This field can appear - multiple times, but can only appear once per certificate. - - Note: all fields stored in Intel low-byte/high-byte order. - - Value Size Description - ----- ---- ----------- - (CID) 0x0015 2 bytes Tag for this "extra" block type - CSize 2 bytes Size of Method - Method (variable) - - Method - Value Size Description - ----- ---- ----------- - Version 2 bytes Version number, for now 0x0001 - AlgID 2 bytes Algorithm ID used for signing - IDSize 2 bytes Size of Certificate ID data - CertID (variable) Certificate ID data - SigSize 2 bytes Size of Signature data - Sig (variable) Signature data - - CertID - Value Size Description - ----- ---- ----------- - Size1 4 bytes Size of CertID, should be (IDSize - 4) - Size1 4 bytes A bug in version one causes this value - to appear twice. - IssSize 4 bytes Issuer data size - Issuer (variable) Issuer data - SerSize 4 bytes Serial Number size - Serial (variable) Serial Number data - - The Issuer and IssSize members are suitable for creating a - CRYPT_DATA_BLOB to be the Issuer member of a CERT_INFO - struct. The Serial and SerSize members would be the - SerialNumber member of the same CERT_INFO struct. This - struct would be used to find the certificate in the store - the file was signed with. Those structures are from the MS - CryptoAPI. - - Sig and SigSize are the actual signature data and size - generated by signing the file with the MS CryptoAPI using a - hash created with the given AlgID. - - -X.509 Certificate ID and Signature for central directory - - This field contains the information about which certificate - in the PKCS#7 Store was used to sign the central directory. - It should only appear with the first central directory - record, along with the store. The data structure is the - same as the CID, except that SigSize will be 0, and there - will be no Sig member. - - This field is also kept after the last central directory - record, as the signature data (ID 0x05054b50, it looks like - a central directory record of a different type). This - second copy of the data is the Signature Data member of the - record, and will have a SigSize that is non-zero, and will - have Sig data. - - Note: all fields stored in Intel low-byte/high-byte order. - - Value Size Description - ----- ---- ----------- - (CDID) 0x0016 2 bytes Tag for this "extra" block type - CSize 2 bytes Size of Method - Method (variable) - - - FWKCS MD5 Extra Field: - - The FWKCS Contents_Signature System, used in - automatically identifying files independent of filename, - optionally adds and uses an extra field to support the - rapid creation of an enhanced contents_signature: - - Header ID = 0x4b46 - Data Size = 0x0013 - Preface = 'M','D','5' - followed by 16 bytes containing the uncompressed file's - 128_bit MD5 hash(1), low byte first. - - When FWKCS revises a .ZIP file central directory to add - this extra field for a file, it also replaces the - central directory entry for that file's uncompressed - filelength with a measured value. - - FWKCS provides an option to strip this extra field, if - present, from a .ZIP file central directory. In adding - this extra field, FWKCS preserves .ZIP file Authenticity - Verification; if stripping this extra field, FWKCS - preserves all versions of AV through PKZIP version 2.04g. - - FWKCS, and FWKCS Contents_Signature System, are - trademarks of Frederick W. Kantor. - - (1) R. Rivest, RFC1321.TXT, MIT Laboratory for Computer - Science and RSA Data Security, Inc., April 1992. - ll.76-77: "The MD5 algorithm is being placed in the - public domain for review and possible adoption as a - standard." - - file comment: (Variable) - - The comment for this file. - - number of this disk: (2 bytes) - - The number of this disk, which contains central - directory end record. - - number of the disk with the start of the central - directory: (2 bytes) - - The number of the disk on which the central - directory starts. - - total number of entries in the central dir on - this disk: (2 bytes) - - The number of central directory entries on this disk. - - total number of entries in the central dir: (2 bytes) - - The total number of files in the .ZIP file. - - size of the central directory: (4 bytes) - - The size (in bytes) of the entire central directory. - - offset of start of central directory with respect to - the starting disk number: (4 bytes) - - Offset of the start of the central directory on the - disk on which the central directory starts. - - .ZIP file comment length: (2 bytes) - - The length of the comment for this .ZIP file. - - .ZIP file comment: (Variable) - - The comment for this .ZIP file. - - F. General notes: - - 1) All fields unless otherwise noted are unsigned and stored - in Intel low-byte:high-byte, low-word:high-word order. - - 2) String fields are not null terminated, since the - length is given explicitly. - - 3) Local headers should not span disk boundaries. Also, even - though the central directory can span disk boundaries, no - single record in the central directory should be split - across disks. - - 4) The entries in the central directory may not necessarily - be in the same order that files appear in the .ZIP file. - - 5) Spanned/Split archives created using PKZIP for Windows - (V2.50 or greater), PKZIP Command Line (V2.50 or greater), - or PKZIP Explorer will include a special spanning - signature as the first 4 bytes of the first segment of - the archive. This signature (0x08074b50) will be - followed immediately by the local header signature for - the first file in the archive. Spanned archives - created with this special signature are compatible with - all versions of PKZIP from PKWARE. Split archives can - only be uncompressed by other versions of PKZIP that - know how to create a split archive. - -UnShrinking - Method 1 ----------------------- - -Shrinking is a Dynamic Ziv-Lempel-Welch compression algorithm -with partial clearing. The initial code size is 9 bits, and -the maximum code size is 13 bits. Shrinking differs from -conventional Dynamic Ziv-Lempel-Welch implementations in several -respects: - -1) The code size is controlled by the compressor, and is not - automatically increased when codes larger than the current - code size are created (but not necessarily used). When - the decompressor encounters the code sequence 256 - (decimal) followed by 1, it should increase the code size - read from the input stream to the next bit size. No - blocking of the codes is performed, so the next code at - the increased size should be read from the input stream - immediately after where the previous code at the smaller - bit size was read. Again, the decompressor should not - increase the code size used until the sequence 256,1 is - encountered. - -2) When the table becomes full, total clearing is not - performed. Rather, when the compressor emits the code - sequence 256,2 (decimal), the decompressor should clear - all leaf nodes from the Ziv-Lempel tree, and continue to - use the current code size. The nodes that are cleared - from the Ziv-Lempel tree are then re-used, with the lowest - code value re-used first, and the highest code value - re-used last. The compressor can emit the sequence 256,2 - at any time. - -Expanding - Methods 2-5 ------------------------ - -The Reducing algorithm is actually a combination of two -distinct algorithms. The first algorithm compresses repeated -byte sequences, and the second algorithm takes the compressed -stream from the first algorithm and applies a probabilistic -compression method. - -The probabilistic compression stores an array of 'follower -sets' S(j), for j=0 to 255, corresponding to each possible -ASCII character. Each set contains between 0 and 32 -characters, to be denoted as S(j)[0],...,S(j)[m], where m<32. -The sets are stored at the beginning of the data area for a -Reduced file, in reverse order, with S(255) first, and S(0) -last. - -The sets are encoded as { N(j), S(j)[0],...,S(j)[N(j)-1] }, -where N(j) is the size of set S(j). N(j) can be 0, in which -case the follower set for S(j) is empty. Each N(j) value is -encoded in 6 bits, followed by N(j) eight bit character values -corresponding to S(j)[0] to S(j)[N(j)-1] respectively. If -N(j) is 0, then no values for S(j) are stored, and the value -for N(j-1) immediately follows. - -Immediately after the follower sets, is the compressed data -stream. The compressed data stream can be interpreted for the -probabilistic decompression as follows: - -let Last-Character <- 0. -loop until done - if the follower set S(Last-Character) is empty then - read 8 bits from the input stream, and copy this - value to the output stream. - otherwise if the follower set S(Last-Character) is non-empty then - read 1 bit from the input stream. - if this bit is not zero then - read 8 bits from the input stream, and copy this - value to the output stream. - otherwise if this bit is zero then - read B(N(Last-Character)) bits from the input - stream, and assign this value to I. - Copy the value of S(Last-Character)[I] to the - output stream. - - assign the last value placed on the output stream to - Last-Character. -end loop - -B(N(j)) is defined as the minimal number of bits required to -encode the value N(j)-1. - -The decompressed stream from above can then be expanded to -re-create the original file as follows: - -let State <- 0. - -loop until done - read 8 bits from the input stream into C. - case State of - 0: if C is not equal to DLE (144 decimal) then - copy C to the output stream. - otherwise if C is equal to DLE then - let State <- 1. - - 1: if C is non-zero then - let V <- C. - let Len <- L(V) - let State <- F(Len). - otherwise if C is zero then - copy the value 144 (decimal) to the output stream. - let State <- 0 - - 2: let Len <- Len + C - let State <- 3. - - 3: move backwards D(V,C) bytes in the output stream - (if this position is before the start of the output - stream, then assume that all the data before the - start of the output stream is filled with zeros). - copy Len+3 bytes from this position to the output stream. - let State <- 0. - end case -end loop - -The functions F,L, and D are dependent on the 'compression -factor', 1 through 4, and are defined as follows: - -For compression factor 1: - L(X) equals the lower 7 bits of X. - F(X) equals 2 if X equals 127 otherwise F(X) equals 3. - D(X,Y) equals the (upper 1 bit of X) * 256 + Y + 1. -For compression factor 2: - L(X) equals the lower 6 bits of X. - F(X) equals 2 if X equals 63 otherwise F(X) equals 3. - D(X,Y) equals the (upper 2 bits of X) * 256 + Y + 1. -For compression factor 3: - L(X) equals the lower 5 bits of X. - F(X) equals 2 if X equals 31 otherwise F(X) equals 3. - D(X,Y) equals the (upper 3 bits of X) * 256 + Y + 1. -For compression factor 4: - L(X) equals the lower 4 bits of X. - F(X) equals 2 if X equals 15 otherwise F(X) equals 3. - D(X,Y) equals the (upper 4 bits of X) * 256 + Y + 1. - -Imploding - Method 6 --------------------- - -The Imploding algorithm is actually a combination of two distinct -algorithms. The first algorithm compresses repeated byte -sequences using a sliding dictionary. The second algorithm is -used to compress the encoding of the sliding dictionary output, -using multiple Shannon-Fano trees. - -The Imploding algorithm can use a 4K or 8K sliding dictionary -size. The dictionary size used can be determined by bit 1 in the -general purpose flag word; a 0 bit indicates a 4K dictionary -while a 1 bit indicates an 8K dictionary. - -The Shannon-Fano trees are stored at the start of the compressed -file. The number of trees stored is defined by bit 2 in the -general purpose flag word; a 0 bit indicates two trees stored, a -1 bit indicates three trees are stored. If 3 trees are stored, -the first Shannon-Fano tree represents the encoding of the -Literal characters, the second tree represents the encoding of -the Length information, the third represents the encoding of the -Distance information. When 2 Shannon-Fano trees are stored, the -Length tree is stored first, followed by the Distance tree. - -The Literal Shannon-Fano tree, if present is used to represent -the entire ASCII character set, and contains 256 values. This -tree is used to compress any data not compressed by the sliding -dictionary algorithm. When this tree is present, the Minimum -Match Length for the sliding dictionary is 3. If this tree is -not present, the Minimum Match Length is 2. - -The Length Shannon-Fano tree is used to compress the Length part -of the (length,distance) pairs from the sliding dictionary -output. The Length tree contains 64 values, ranging from the -Minimum Match Length, to 63 plus the Minimum Match Length. - -The Distance Shannon-Fano tree is used to compress the Distance -part of the (length,distance) pairs from the sliding dictionary -output. The Distance tree contains 64 values, ranging from 0 to -63, representing the upper 6 bits of the distance value. The -distance values themselves will be between 0 and the sliding -dictionary size, either 4K or 8K. - -The Shannon-Fano trees themselves are stored in a compressed -format. The first byte of the tree data represents the number of -bytes of data representing the (compressed) Shannon-Fano tree -minus 1. The remaining bytes represent the Shannon-Fano tree -data encoded as: - - High 4 bits: Number of values at this bit length + 1. (1 - 16) - Low 4 bits: Bit Length needed to represent value + 1. (1 - 16) - -The Shannon-Fano codes can be constructed from the bit lengths -using the following algorithm: - -1) Sort the Bit Lengths in ascending order, while retaining the - order of the original lengths stored in the file. - -2) Generate the Shannon-Fano trees: - - Code <- 0 - CodeIncrement <- 0 - LastBitLength <- 0 - i <- number of Shannon-Fano codes - 1 (either 255 or 63) - - loop while i >= 0 - Code = Code + CodeIncrement - if BitLength(i) <> LastBitLength then - LastBitLength=BitLength(i) - CodeIncrement = 1 shifted left (16 - LastBitLength) - ShannonCode(i) = Code - i <- i - 1 - end loop - -3) Reverse the order of all the bits in the above ShannonCode() - vector, so that the most significant bit becomes the least - significant bit. For example, the value 0x1234 (hex) would - become 0x2C48 (hex). - -4) Restore the order of Shannon-Fano codes as originally stored - within the file. - -Example: - - This example will show the encoding of a Shannon-Fano tree - of size 8. Notice that the actual Shannon-Fano trees used - for Imploding are either 64 or 256 entries in size. - -Example: 0x02, 0x42, 0x01, 0x13 - - The first byte indicates 3 values in this table. Decoding the - bytes: - 0x42 = 5 codes of 3 bits long - 0x01 = 1 code of 2 bits long - 0x13 = 2 codes of 4 bits long - - This would generate the original bit length array of: - (3, 3, 3, 3, 3, 2, 4, 4) - - There are 8 codes in this table for the values 0 thru 7. Using - the algorithm to obtain the Shannon-Fano codes produces: - - Reversed Order Original -Val Sorted Constructed Code Value Restored Length ---- ------ ----------------- -------- -------- ------ -0: 2 1100000000000000 11 101 3 -1: 3 1010000000000000 101 001 3 -2: 3 1000000000000000 001 110 3 -3: 3 0110000000000000 110 010 3 -4: 3 0100000000000000 010 100 3 -5: 3 0010000000000000 100 11 2 -6: 4 0001000000000000 1000 1000 4 -7: 4 0000000000000000 0000 0000 4 - -The values in the Val, Order Restored and Original Length columns -now represent the Shannon-Fano encoding tree that can be used for -decoding the Shannon-Fano encoded data. How to parse the -variable length Shannon-Fano values from the data stream is beyond -the scope of this document. (See the references listed at the end of -this document for more information.) However, traditional decoding -schemes used for Huffman variable length decoding, such as the -Greenlaw algorithm, can be successfully applied. - -The compressed data stream begins immediately after the -compressed Shannon-Fano data. The compressed data stream can be -interpreted as follows: - -loop until done - read 1 bit from input stream. - - if this bit is non-zero then (encoded data is literal data) - if Literal Shannon-Fano tree is present - read and decode character using Literal Shannon-Fano tree. - otherwise - read 8 bits from input stream. - copy character to the output stream. - otherwise (encoded data is sliding dictionary match) - if 8K dictionary size - read 7 bits for offset Distance (lower 7 bits of offset). - otherwise - read 6 bits for offset Distance (lower 6 bits of offset). - - using the Distance Shannon-Fano tree, read and decode the - upper 6 bits of the Distance value. - - using the Length Shannon-Fano tree, read and decode - the Length value. - - Length <- Length + Minimum Match Length - - if Length = 63 + Minimum Match Length - read 8 bits from the input stream, - add this value to Length. - - move backwards Distance+1 bytes in the output stream, and - copy Length characters from this position to the output - stream. (if this position is before the start of the output - stream, then assume that all the data before the start of - the output stream is filled with zeros). -end loop - -Tokenizing - Method 7 --------------------- - -This method is not used by PKZIP. - -Deflating - Method 8 ------------------ - -The Deflate algorithm is similar to the Implode algorithm using -a sliding dictionary of up to 32K with secondary compression -from Huffman/Shannon-Fano codes. - -The compressed data is stored in blocks with a header describing -the block and the Huffman codes used in the data block. The header -format is as follows: - - Bit 0: Last Block bit This bit is set to 1 if this is the last - compressed block in the data. - Bits 1-2: Block type - 00 (0) - Block is stored - All stored data is byte aligned. - Skip bits until next byte, then next word = block - length, followed by the ones compliment of the block - length word. Remaining data in block is the stored - data. - - 01 (1) - Use fixed Huffman codes for literal and distance codes. - Lit Code Bits Dist Code Bits - --------- ---- --------- ---- - 0 - 143 8 0 - 31 5 - 144 - 255 9 - 256 - 279 7 - 280 - 287 8 - - Literal codes 286-287 and distance codes 30-31 are - never used but participate in the huffman construction. - - 10 (2) - Dynamic Huffman codes. (See expanding Huffman codes) - - 11 (3) - Reserved - Flag a "Error in compressed data" if seen. - -Expanding Huffman Codes ------------------------ -If the data block is stored with dynamic Huffman codes, the Huffman -codes are sent in the following compressed format: - - 5 Bits: # of Literal codes sent - 256 (256 - 286) - All other codes are never sent. - 5 Bits: # of Dist codes - 1 (1 - 32) - 4 Bits: # of Bit Length codes - 3 (3 - 19) - -The Huffman codes are sent as bit lengths and the codes are built as -described in the implode algorithm. The bit lengths themselves are -compressed with Huffman codes. There are 19 bit length codes: - - 0 - 15: Represent bit lengths of 0 - 15 - 16: Copy the previous bit length 3 - 6 times. - The next 2 bits indicate repeat length (0 = 3, ... ,3 = 6) - Example: Codes 8, 16 (+2 bits 11), 16 (+2 bits 10) will - expand to 12 bit lengths of 8 (1 + 6 + 5) - 17: Repeat a bit length of 0 for 3 - 10 times. (3 bits of length) - 18: Repeat a bit length of 0 for 11 - 138 times (7 bits of length) - -The lengths of the bit length codes are sent packed 3 bits per value -(0 - 7) in the following order: - - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 - -The Huffman codes should be built as described in the Implode algorithm -except codes are assigned starting at the shortest bit length, i.e. the -shortest code should be all 0's rather than all 1's. Also, codes with -a bit length of zero do not participate in the tree construction. The -codes are then used to decode the bit lengths for the literal and -distance tables. - -The bit lengths for the literal tables are sent first with the number -of entries sent described by the 5 bits sent earlier. There are up -to 286 literal characters; the first 256 represent the respective 8 -bit character, code 256 represents the End-Of-Block code, the remaining -29 codes represent copy lengths of 3 thru 258. There are up to 30 -distance codes representing distances from 1 thru 32k as described -below. - - Length Codes - ------------ - Extra Extra Extra Extra - Code Bits Length Code Bits Lengths Code Bits Lengths Code Bits Length(s) - ---- ---- ------ ---- ---- ------- ---- ---- ------- ---- ---- --------- - 257 0 3 265 1 11,12 273 3 35-42 281 5 131-162 - 258 0 4 266 1 13,14 274 3 43-50 282 5 163-194 - 259 0 5 267 1 15,16 275 3 51-58 283 5 195-226 - 260 0 6 268 1 17,18 276 3 59-66 284 5 227-257 - 261 0 7 269 2 19-22 277 4 67-82 285 0 258 - 262 0 8 270 2 23-26 278 4 83-98 - 263 0 9 271 2 27-30 279 4 99-114 - 264 0 10 272 2 31-34 280 4 115-130 - - Distance Codes - -------------- - Extra Extra Extra Extra - Code Bits Dist Code Bits Dist Code Bits Distance Code Bits Distance - ---- ---- ---- ---- ---- ------ ---- ---- -------- ---- ---- -------- - 0 0 1 8 3 17-24 16 7 257-384 24 11 4097-6144 - 1 0 2 9 3 25-32 17 7 385-512 25 11 6145-8192 - 2 0 3 10 4 33-48 18 8 513-768 26 12 8193-12288 - 3 0 4 11 4 49-64 19 8 769-1024 27 12 12289-16384 - 4 1 5,6 12 5 65-96 20 9 1025-1536 28 13 16385-24576 - 5 1 7,8 13 5 97-128 21 9 1537-2048 29 13 24577-32768 - 6 2 9-12 14 6 129-192 22 10 2049-3072 - 7 2 13-16 15 6 193-256 23 10 3073-4096 - -The compressed data stream begins immediately after the -compressed header data. The compressed data stream can be -interpreted as follows: - -do - read header from input stream. - - if stored block - skip bits until byte aligned - read count and 1's compliment of count - copy count bytes data block - otherwise - loop until end of block code sent - decode literal character from input stream - if literal < 256 - copy character to the output stream - otherwise - if literal = end of block - break from loop - otherwise - decode distance from input stream - - move backwards distance bytes in the output stream, and - copy length characters from this position to the output - stream. - end loop -while not last block - -if data descriptor exists - skip bits until byte aligned - read crc and sizes -endif - -Decryption ----------- - -The encryption used in PKZIP was generously supplied by Roger -Schlafly. PKWARE is grateful to Mr. Schlafly for his expert -help and advice in the field of data encryption. - -PKZIP encrypts the compressed data stream. Encrypted files must -be decrypted before they can be extracted. - -Each encrypted file has an extra 12 bytes stored at the start of -the data area defining the encryption header for that file. The -encryption header is originally set to random values, and then -itself encrypted, using three, 32-bit keys. The key values are -initialized using the supplied encryption password. After each byte -is encrypted, the keys are then updated using pseudo-random number -generation techniques in combination with the same CRC-32 algorithm -used in PKZIP and described elsewhere in this document. - -The following is the basic steps required to decrypt a file: - -1) Initialize the three 32-bit keys with the password. -2) Read and decrypt the 12-byte encryption header, further - initializing the encryption keys. -3) Read and decrypt the compressed data stream using the - encryption keys. - -Step 1 - Initializing the encryption keys ------------------------------------------ - -Key(0) <- 305419896 -Key(1) <- 591751049 -Key(2) <- 878082192 - -loop for i <- 0 to length(password)-1 - update_keys(password(i)) -end loop - -Where update_keys() is defined as: - -update_keys(char): - Key(0) <- crc32(key(0),char) - Key(1) <- Key(1) + (Key(0) & 000000ffH) - Key(1) <- Key(1) * 134775813 + 1 - Key(2) <- crc32(key(2),key(1) >> 24) -end update_keys - -Where crc32(old_crc,char) is a routine that given a CRC value and a -character, returns an updated CRC value after applying the CRC-32 -algorithm described elsewhere in this document. - -Step 2 - Decrypting the encryption header ------------------------------------------ - -The purpose of this step is to further initialize the encryption -keys, based on random data, to render a plaintext attack on the -data ineffective. - -Read the 12-byte encryption header into Buffer, in locations -Buffer(0) thru Buffer(11). - -loop for i <- 0 to 11 - C <- buffer(i) ^ decrypt_byte() - update_keys(C) - buffer(i) <- C -end loop - -Where decrypt_byte() is defined as: - -unsigned char decrypt_byte() - local unsigned short temp - temp <- Key(2) | 2 - decrypt_byte <- (temp * (temp ^ 1)) >> 8 -end decrypt_byte - -After the header is decrypted, the last 1 or 2 bytes in Buffer -should be the high-order word/byte of the CRC for the file being -decrypted, stored in Intel low-byte/high-byte order. Versions of -PKZIP prior to 2.0 used a 2 byte CRC check; a 1 byte CRC check is -used on versions after 2.0. This can be used to test if the password -supplied is correct or not. - -Step 3 - Decrypting the compressed data stream ----------------------------------------------- - -The compressed data stream can be decrypted as follows: - -loop until done - read a character into C - Temp <- C ^ decrypt_byte() - update_keys(temp) - output Temp -end loop - -In addition to the above mentioned contributors to PKZIP and PKUNZIP, -I would like to extend special thanks to Robert Mahoney for suggesting -the extension .ZIP for this software. - -References: - - Fiala, Edward R., and Greene, Daniel H., "Data compression with - finite windows", Communications of the ACM, Volume 32, Number 4, - April 1989, pages 490-505. - - Held, Gilbert, "Data Compression, Techniques and Applications, - Hardware and Software Considerations", John Wiley & Sons, 1987. - - Huffman, D.A., "A method for the construction of minimum-redundancy - codes", Proceedings of the IRE, Volume 40, Number 9, September 1952, - pages 1098-1101. - - Nelson, Mark, "LZW Data Compression", Dr. Dobbs Journal, Volume 14, - Number 10, October 1989, pages 29-37. - - Nelson, Mark, "The Data Compression Book", M&T Books, 1991. - - Storer, James A., "Data Compression, Methods and Theory", - Computer Science Press, 1988 - - Welch, Terry, "A Technique for High-Performance Data Compression", - IEEE Computer, Volume 17, Number 6, June 1984, pages 8-19. - - Ziv, J. and Lempel, A., "A universal algorithm for sequential data - compression", Communications of the ACM, Volume 30, Number 6, - June 1987, pages 520-540. - - Ziv, J. and Lempel, A., "Compression of individual sequences via - variable-rate coding", IEEE Transactions on Information Theory, - Volume 24, Number 5, September 1978, pages 530-536. diff --git a/src/smpackagee/ZipArchive/ChangeLog.txt b/src/smpackagee/ZipArchive/ChangeLog.txt deleted file mode 100644 index 9f4d092f99..0000000000 --- a/src/smpackagee/ZipArchive/ChangeLog.txt +++ /dev/null @@ -1,322 +0,0 @@ -/** \page pageHist Revision history - - ver 2.3.4 (06-2003) - - Bug fixed: - - - problems with extracting some archives (very rare) (thanks to Ben Jos Walbeehm for the fix) - - problems with extracting some archives created under Linux (thanks to Jürgen Marquardt for reporting) - - small compilation errors under MSVC++ .NET (thanks to Darren Whobrey for the fixes) - - setting password in zippie (thanks to Amnon David for the fix) - - Changes: - - - CZipArchive::TestFile throws an exception now if CZipArchive::CloseFile returned -1. It makes it work as described in the documentation that an exception is thrown when the file is corrupted (thanks to Silvio Scarpati for pointing this out). - - it is now possible to add an already opened file to an archive (thanks to Kristjan Bjarnason for the change) - - ver 2.3.3 (01-2003) - - Features added: - - - CZipArchive::m_bRemoveDriveLetter option added - - Bugs fixed: - - - not extracting files from the last volume when opening an existing archive created in TDSpan mode, where the last volume filename has other extension than ".zip" - - added PKZIP_BUG_WORKAROUND definition to the zlib.h file distributed with ZipArchive library as well as to ZipArchive project files (in case the zlib library is replaced with a new version). - It deals with pkzip bug existing in some archives (thanks to Ben Jos Walbeehm for reporting). - - ver 2.3.2 (08-2002) - - Bug fixed: - - - problem with creating disk spanning archives in the STL version of the library (thanks to Luiz Rafael Culik for reporting) - - ver 2.3.1 (05-2002) - - Bug fixed: - - - using CZipMemFile::CZipMemFile(BYTE* , UINT , long ) constructor could cause memory errors (thanks to Laurent Doré) - - ver 2.3 (04-2002) (includes changes and fixes from 2.2a to 2.2c) - - Features added: - - - Visual Studio .NET compatibility - - methods CZipArchive::GetFromArchive added, which allow copying files from another archive without decompressing them - - many times requested replacing of files in the archive feature; it works with methods CZipArchive::GetFromArchive and a new - CZipArchive::AddNewFile(CZipAddNewFileInfo& ) which was introduced due to increasing parameters count - - added method CZipArchive::RenameFile which renames a file in the archive maintaining its physical position inside the archive - - projects and necessary changes for compiling ZipArchive as a DLL version (courtesy of Jonathan Reis) - see \ref subsDLL and \ref subDLLnotes -
( they are not embedded into existing ones, but made separated, since the DLL version needs separated project for zlib.dll and for the static version, - zlib library is already included in the projects to minimize linking problems with applications) - - added CZipArchive::WillBeDuplicated which lets you check quickly if the given filename would duplicate an existing one in the archive - - CZipArchive::GetCount has now an additional parameter and can return the number of files in the archive not counting the directories - - CZipArchive::Close has been given also an additional parameter (\e bUpdateTimeStamp) and can set the modification time of the zip archive to the modification time of the newest file inside the archive - - method CZipArchive::GetIndexes added - - ZipArc application updated to support renaming, replacing (as well as updating files in the archive) and getting compressed files from another archive - - Changes: - - zlib library updated to version 1.1.4 that fixes the security vulnerability in version 1.1.3 - as described in - \htmlonly - http://www.zlib.org/advisory-2002-03-11.txt - \endhtmlonly - - if the file inside the archive has the wrong date/time stamp set, then the extracted file is given the current time instead of reporting an error - - a little change in CZipArchive::PredictFileNameInZip : parameter \e bAnsiOem changed to \e bExactly (apart from the name, the meaning has also been changed) - - removed parameter bFileNameOnly from CZipArchive::DeleteFiles(const CZipStringArray &); - - Bugs fixed: - - eliminated possible errors when using CZipArchive::zipsmCheckForEff with disk-spanning mode - - reading some files created with other archivers failed occasionally in CZipFileHeader::ReadLocal (thanks to Christian von Seydlitz) - - while a file recompression (smartness level included CZipArchive::zipsmCheckForEff) if the - AutoFlush feature was enabled, there were redundant bytes added to the archive (thanks to Roman Scherzer) - - aborting extraction of multi-disk archive caused errors (thanks to Sabina Terenzi) - - some GUI fixes in ZipArc - - Known issues: - - under Windows XP, in TD disk spanning mode, when the central directory is not entirely - written on the last volume (but divided between volumes), \e SHGetFileInfo hangs up (it is used i.e. by \e CFileDialog::DoModal) - Windows probably tries to analize - zip structure, but fails becuase it is an additional feature of ZipArchive library to create multi volume archives on non-removable data storage - - ver 2.2 (10-2001) Time for global changes - - Features added: - - deleting multiple files from the archive is now way faster - the files are not - deleted separately as it was so far, but the library creates a map of holes and continuous areas and moves the data to remain in file over the holes; it means that the data is copied - only once and not for every file to delete. - - callback functions has been replaced by functional objects to make the code cleaner and to make it possible to pass more information during a callback call (see: CZipArchive::SetCallback). The same application written using the library with callback functions - and then with functional objects as callbacks (slightly modified) has proven to be circa 15% faster in the latter case (that's why it's in \e features), i.a. because only data that changes is passed to the callback method, method derived from CZipCallback::Callback can be inlined if defined inside the class declaration). Important issues: - - it affects the following functions parameters: - - CZipArchive::AddNewFile, - - CZipArchive::ExtractFile, - - CZipArchive::TestFile, - - CZipArchive::SetSpanCallback - - the meaning of the parameters passed to a callback functor is different from that what has so far been passed to the callback functions - (see CZipCallback) - - see \ref sectCallb if you're not sure how to use functors - - added callback feature when deleting files - - added callback feature when saving central directory - - added possibility to extract or delete files which filenames match the specified wildcard pattern (see CZipArchive::FindMatches) - - iterating the central directory elements speeded up (hence all the operations that iterate the central directory were speeded up, especially sorting, multiple adding, extracting, testing) - - the library now doesn't throw an exception if the platform the archive was created under is not supported, but it tries to distinguish files from directories - - CZipArchive::Flush can be called now for a disk-spanning archive in creation finalizing it then, and yet allows extracting or testing (see the function description for more) - - function CZipArchive::CloseNewFile can be called after an exception to allow to repair the archive later - - adding files with one of CZipArchive::AddNewFile functions can be safely aborted in a non-disk-spanning archive (the added data is removed from the archive) - - added function CZipException::GetErrorMessage for compatibility with MFC \c CException::GetErrorMessage - - added parameter \e bForce to CZipArchive::SetTempPath that creates the directory if it doesn't exists - - the archive created with the library under Windows can be now correctly extracted under Linux and vice versa without the need for setting the system compatibility of the files - - function CZipArchive::SetIgnoreCRC added to make possible working with the Java TM Archives (jar) - - function CZipArchive::GetFindFastIndex added - - function CZipArchive::GetCentralDirInfo added - - function CZipArchive::GetCentralDirSize added - - function CZipArchive::GetCurrentDisk added - - function CZipArchive::IsReadOnly added - - function CZipFileHeader::CompressionEfficient added - - function CZipFileHeader::GetCompressionRatio added - - \c const keywords added to functions - - TRACE messages are now easier to locate in MSVC++ (double clicking gets you directly to the code now) - - - - Changes: - - if the callback functor's method \c Callback returns \c false, - a CZipException is thrown with code CZipException::abortedAction or CZipException::abortedSafely; - - function CZipArchive::DeleteFiles(const CZipStringArray) uses now FindFast array; added \e bFileNameOnly parameter - - function CZipArchive::GetNoEntries renamed to GetCount (more standard, easier to type and easier to find at the beginning) - - the encrypted file is not recompressed again if the difference in sizes before and after compression is the - length of the encryption header - - function CZipArchive::OpenFile throws exception CZipException::badPassword if the password - was not set for the encrypted file instead of returning \c false; - - versioning shortened - - - Bugs fixed: - - CZipStorage::Flush doesn't call now m_pFile->Flush() (it has proven to slow - down the archive creation speed significantly) - it is called in different places instead - - CZipArchive::TestFile sometimes was not detecting wrong password set - - filenames in zip are now correctly converted after calling CZipArchive::Flush - - fixed value of CZipArchive::zipsmCheckForEffInMem; the bug cause the temporary file to be always created in memory - - ZipPlatform::GetDeviceFreeSpace was not working on Windows with other devices than removable (in spite of what is written in MSDN - it is sometimes needed to add slash when passing drive name to \c GetDiskFreeSpace and sometimes not). - I'm not sure if this bug concerned all Windows platforms (it was detected on Windows 2000) - - crash eliminated when the file modification time could not be retrieved (in case of an impossible value e.g. a year is 28980) - - Unix attributes corrected - - CZipArchive::ExtractFile had wrong value passed to the callback function - - ver 2.1.1 (10-2001) - - Features added: - - - Linux version at the beta stage (thanks to Luiz Rafael Culik for help) - - smart and efficient compression added to CZipArchive::AddNewFile
- i.a. optional compression to a temporary file first or to memory, in a disk spanning mode, - to see whether the file is smaller after compression and if it is not - then add it without the compression (see also CZipArchive::Smartness) - - integration of the help system with MSDN made possible (see: \ref sectHelp) - - adding a file with the user-specified filename in zip ( CZipArchive::AddNewFile(LPCTSTR , LPCTSTR , int , int , unsigned long ) ) - - adding files from memory and extracting files to memory - ( CZipArchive::AddNewFile(CZipMemFile&, LPCTSTR, int, int, unsigned long) and - CZipArchive::ExtractFile(WORD, CZipMemFile&, DWORD)) - - function CZipArchive::Flush added - increases the safety when working with zip archives (thanks to Brad Kremer for the idea) - - function CZipArchive::SetCaseSensitivity added (see the function description which functions it affects) - - function CZipArchive::PredictFileNameInZip added - - function CZipArchive::PredictExtractedFileName added - - function CZipArchive::FindFile speeded up again, the case-sensitivity parameter meaning changed, added possibility to find a filename only without a path (see the function description) - - function CZipArchive::TrimRootPath function improved - - function CZipArchive::Close allows now to write the central directory to the archive even after exception, which lets you e.g. repair the archive later - - obtaining error descriptions (English only) - see CZipException::GetErrorDescription() - - STL sample application added (a command line archiver which works for both Windows and Linux; located in \e stl/zippie) - - in TestZipDlg sample application added switch in options to allow an effective compression - - several minor enhancements - - Changes: - - - CZipPathComponent functions renamed : GetFullFileName -> GetFileName, GetFileName -> GetFileTitle, SetFileName -> SetFileTitle - - file \e __[...].zcfg is created depending on the current configuration when using scripts to copy files (see a note at \ref secCompil) - - Bugs fixed: - - - when performing a non-case-sensitive search with CZipArchive::FindFile (thanks to Kenny Prole) - - in CZipString (STL) when using a different locale than English and - non-English characters (see \ref stlNotes for info on how to set your locale in the program) - - CZipStorage::Flush call now m_pFile->Flush() as well (it might have caused a zip creation problems sometimes) - - ver 1.6.6 (08-2001) - - Features added: - - - CZipPathComponent understands now a UNC path, so it is possible to - extract files over a network (other operations over a network were - already possible) - - sample application updated to reflect previous (ver 1.6.5) and - current changes (necessary prefix added to a UNC path following - the Windows File Name Conventions : see \ref q11 "FAQ") - - - ver 1.6.5 (07-2001) - - Features added: - - - added function CZipArchive::SetRootPath that allows more flexible path - manipulations when using CZipArchive::AddNewFile and CZipArchive::ExtractFile - - ability to set the archive system compatibility to a value different - than the current system ID with the function CZipArchive::SetSystemCompatibility() - - Bugs fixed: - - - bug which caused not updating the time stamp of an extracted file - and an exception being thrown, if the file had the read-only attribute set - (thanks to Arnon Meydav) - - bugs in conversion of Unix attributes - - directories inside the archive are now recognized properly by Unix archivers - if the archive was created for Unix platform - - - ver 1.6.4 (06-2001) - - - fixed errors that made impossible using CZipMemFile class and - creation of the archives in memory - - - - ver 1.6.3 (05-2001) - - - zlib library sources incorporated into ZipArchive library projects -(eliminates most often link errors) - - - ver 1.6.2 (04-2001) - - - ZipPlatform::SetVolLabel() appends now a directory separator to the drive name (lack of it caused errors sometimes) - - added a simple protection against compiling MFC or STL version without copying the proper files first - - added several preprocessor directives for Borland compilers - - - ver 1.6.1 (03-2001) - - Features added: - - - non MFC dependent version (STL) - - porting to different platforms made easier - - possibility to read zip files created on other platforms than Windows - (correct interpretation of file/directory attributes) - - documentation generated (using - \htmlonly - Doxygen - \endhtmlonly - ) - - Changes: - - - LICENSING CHANGED - - overall tuning - - sample application updated - - ver 1.5.1 (02-2001) - - - Features added: - - - ability to reuse the archive after an exception thrown during extraction - - added progress control possibilities to CZipArchive::AddNewFile, CZipArchive::ExtractFile, CZipArchive::TestFile - - when the central directory was not located, the library throws CZipException::cdirNotFound, which allows distinguish from other exceptions (useful when we want to keep prompting the user to insert the last disk in a multi-disk spanning archive). - - - Changes: - - - CZipArchive::FindFile operation boosted ( thanks to Darin Warling) - - library name changed to ZipArchive - - the sample application updated - - Bugs fixed: - - - removed bug during extracting an encrypted file with 0 size - - fixed bug when extracting a file with an extra field in a local file header (CFileHeader::ReadLocal) - - ver 1.4.1 (01-2001) - - Disk numbering in a disk spanning archive begins now from PKBACK# 001 not PKBACK# 000 - - Adding and extracting without a full path possible in CZipArchive::AddNewFile and CZipArchive::ExtractFile. - - Several minor changes and enhancements - - Changed names for several classes. - - ver 1.3.1 (11-2000) - - - Testing the archive made easier - - Added support for password encryption and decryption. The encryption used in PKZIP was generously supplied by Roger Schlafly. - - Unicode support added - - ver 1.2.2 (08-2000) - - Bugs fixed - - ver 1.2.1 (06-2000) -\par - the code has been completely rewritten from the very beginning; - the main improvements are: - - multi-disk archive support - - creation of the disk spanning archives with the user-defined volume size - - ability to modify existing archives (add, delete files) - - modification self-extracting archives - - write buffer used for faster disk write operations - - one class for zip and unzip functions - - fast adding, deleting and extracting files with a single function call - - ver 1.1.2 (03-2000) - - international characters in filenames inside archive are now - converted in a compatible way with other archiving programs (they are stored - converted to OEM inside archive). - - ver 1.1.1 (01-2000) -\par - the first version; it is just modified code from zip.c and unzip.c files - written by Gilles Vollant and distributed with zlib library; - the modifications are as follows: - - added class' wrappers - - several bugs fixed - - several enhancements added - - MFC support added - - memory leaks eliminated when write error occurred - - automatically free used memory on destruction or exception - - modern error notification using exceptions - -*/ diff --git a/src/smpackagee/ZipArchive/License.txt b/src/smpackagee/ZipArchive/License.txt deleted file mode 100644 index ae3039860c..0000000000 --- a/src/smpackagee/ZipArchive/License.txt +++ /dev/null @@ -1,73 +0,0 @@ -/** \page pageLic Licensing information - -ZipArchive library - creation, modification and decompression of "zip" format archives
-Copyright © 2000 - 2003 Tadeusz Dracz.
-E-Mail: \htmlonly tdracz@artpol-software.com
-Web: http://www.artpol-software.com \endhtmlonly - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -
-************************************************************************* -An English version of the \ref pageGPL "GNU GPL" is in the %gpl.txt file distributed with -this project. Translations to other languages are available at: -\htmlonly -http://www.gnu.org/copyleft/gpl.html -\endhtmlonly - - -Distributing ZipArchive under GNU GPL implies ZipArchive can only be used -with software that is licensed under conditions compliant with the GPL. -Embedding in proprietary software requires an alternative license. - - -\section s1 Alternative license for use with proprietary software - - -If you want to distribute software in a commercial context that incorporates -ZipArchive and you do not want to meet the conditions of GNU GPL -(e.g. an obligation to provide a customer with the source code of your -software that uses the ZipArchive library), you need to have a commercial license. -- The commercial license provides you with the same rights as the GNU GPL, but in -addition allows you to embed ZipArchive library in proprietary software without -affecting the copyright of this software (it removes the GNU GPL obligation -to publish the source code) -- The license gives you royalty free distribution rights -- The license does not allow you to transfer these rights -- The license is granted per developer -- You won't need to purchase an additional license for the future versions of the library - - -The commercial license is available free of charge for using ZipArchive library in: -- freeware software (freeware is software that is available free of charge, but which is copyrighted by the developer, who retains the right to control its redistribution and to sell it in the future) - - excluded is software which is associated with an equipment that the same company manufactures and which has no practical usage value without the mentioned equipment (e.g. software used for maintenace of machines) - unless the equipment is free as well - - if you decide to sell the software in the future - you will need to purchase the commercial license for using the ZipArchive library, unless it is distributed in the shareware way - see below -- software distributed in the Shareware way (Shareware distribution gives users a chance to try software before buying it. If you try a Shareware program and continue using it, you are expected to register. Individual programs differ on details -- some request registration while others require it, some specify a maximum trial period. -Copyright laws apply to both Shareware and commercial software and the copyright holder retains all rights, with the exception that copying and distributing the program for evaluation purposes is encouraged, subject to certain conditions. For example, some authors require written permission before a commercial disk vendor may copy their Shareware. ) - - excluded is software which price for a single copy is higher than the price of the ZipArchive library for a single developer - -Extended Licence for HBZLIB (library for zip compression in \htmlonly Harbour\endhtmlonly)
-You can create proprietary software using hbzlib respecting the follow: -- ZipArchive library must be linked together with hbzlib -- you cannot use ZipArchive as a dynamic library (DLL), it must be linked staticaly with the software -- the commercial license for ZipArchive is free of charge, but these grants are valid only if the whole application is written with Harbour - -There is a fee for the commercial license for using the library in the software not falling into the mentioned categories. -
-It is recommended that you should print two copies of the commercial license -document after you receive it, sign them and send by post. One copy, signed by the author will be sent back to you. -Please \htmlonly contact the author or visit the Artpol Software web site \endhtmlonly to find out more. - -*/ diff --git a/src/smpackagee/ZipArchive/Linux/ZipFileMapping.h b/src/smpackagee/ZipArchive/Linux/ZipFileMapping.h deleted file mode 100644 index b16f251b95..0000000000 --- a/src/smpackagee/ZipArchive/Linux/ZipFileMapping.h +++ /dev/null @@ -1,61 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFileMapping.h $ -// $Archive: /ZipArchive_Linux/ZipFileMapping.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_) -#define AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include - -namespace ziparchv { - -struct CZipFileMapping -{ - CZipFileMapping() - { - m_iSize = 0; - m_pFileMap = NULL; - } - bool CreateMapping(CZipFile* pFile) - { - if (!pFile) - return false; - m_iSize = pFile->GetLength(); - m_pFileMap = mmap( - 0, m_iSize, PROT_READ | PROT_WRITE, MAP_SHARED, pFile->m_hFile, 0); - return (m_pFileMap != NULL); - } - void RemoveMapping() - { - - if (m_pFileMap) { - munmap(m_pFileMap, m_iSize); - m_pFileMap = NULL; - } - } - ~CZipFileMapping() { RemoveMapping(); } - char* GetMappedMemory() { return reinterpret_cast(m_pFileMap); } - - protected: - void* m_pFileMap; - size_t m_iSize; -}; -} - -#endif // !defined(AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/Linux/ZipPathComponent.cpp b/src/smpackagee/ZipArchive/Linux/ZipPathComponent.cpp deleted file mode 100644 index ed0c1c03d5..0000000000 --- a/src/smpackagee/ZipArchive/Linux/ZipPathComponent.cpp +++ /dev/null @@ -1,87 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPathComponent.cpp $ -// $Archive: /ZipArchive_Linux/ZipPathComponent.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipPathComponent.h" -#include "stdafx.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CZipPathComponent::~CZipPathComponent() {} - -void -CZipPathComponent::SetFullPath(LPCTSTR lpszFullPath) -{ - - CZipString szTempPath(lpszFullPath); - const CZipString szPrefix = _T("\\\\?\\unc\\"); - int i = -1, iLen = szPrefix.GetLength(); - if (iLen > szTempPath.GetLength()) - iLen = szTempPath.GetLength(); - CZipString szPossiblePrefix = szTempPath.Left(iLen); - szPossiblePrefix.MakeLower(); // must perform case insensitive comparison - while (++i < iLen && szPossiblePrefix[i] == szPrefix[i]) - ; - if (i == 2 || i == 4 || i == 8) // unc path, unicode path or unc path - // meeting windows file name conventions - { - m_szPrefix = szTempPath.Left(i); - szTempPath = szTempPath.Mid(i); - } else - m_szPrefix.Empty(); - - m_szDrive.Empty(); - m_szFileTitle.Empty(); - m_szDirectory.Empty(); - m_szFileExt.Empty(); - int p; - for (p = szTempPath.GetLength() - 1; p >= 0; p--) - if (szTempPath[p] == m_cSeparator) - break; - - if (p != -1) { - m_szDirectory = szTempPath.Left(p); - if (p == szTempPath.GetLength() - 1) - return; // no filename present - else - p++; - } else - p = 0; - - // p points at the beginning of the filename - m_szFileTitle = szTempPath.Mid(p); - for (p = m_szFileTitle.GetLength() - 1; p >= 0; p--) - if (m_szFileTitle[p] == _T('.')) - break; - - if (p != -1) { - m_szFileExt = m_szFileTitle.Mid(p + 1); - m_szFileTitle = m_szFileTitle.Left(p); - } -} - -CZipString -CZipPathComponent::GetNoDrive() const -{ - CZipString szPath = m_szDirectory; - CZipString szFileName = GetFileName(); - if (!szFileName.IsEmpty() && !szPath.IsEmpty()) - szPath += m_cSeparator; - - szPath += szFileName; - return szPath; -} diff --git a/src/smpackagee/ZipArchive/Linux/ZipPlatform.cpp b/src/smpackagee/ZipArchive/Linux/ZipPlatform.cpp deleted file mode 100644 index 20fd2cc067..0000000000 --- a/src/smpackagee/ZipArchive/Linux/ZipPlatform.cpp +++ /dev/null @@ -1,272 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPlatform.cpp $ -// $Archive: /ZipArchive_Linux/ZipPlatform.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipPlatform.h" -#include "ZipAutoBuffer.h" -#include "ZipException.h" -#include "ZipFileHeader.h" -#include "stdafx.h" - -#include - -#include "ZipPathComponent.h" - -#include "ZipCompatibility.h" -#include -#include -#include -#include -#include -#include - -const TCHAR CZipPathComponent::m_cSeparator = _T('/'); - -#ifndef _UTIMBUF_DEFINED -#define _utimbuf utimbuf -#endif - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -DWORD -ZipPlatform::GetDeviceFreeSpace(LPCTSTR lpszPath) -{ - struct statfs sStats; - if (statfs(lpszPath, &sStats) == -1) - return 0; - - return sStats.f_bsize * sStats.f_bavail; -} - -bool -ZipPlatform::GetFileSize(LPCTSTR lpszFileName, DWORD& dSize) -{ - int f = open(lpszFileName, O_RDONLY); - if (f == -1) - return false; - int iSize = lseek(f, 0, SEEK_END); - close(f); - if (iSize == -1) - return false; - dSize = (DWORD)iSize; - return true; -} - -CZipString -ZipPlatform::GetTmpFileName(LPCTSTR lpszPath, DWORD iSizeNeeded) -{ - TCHAR empty[] = _T(""), prefix[] = _T("zar"); - TCHAR* buf = NULL; - CZipString tempPath; - if (lpszPath) { - // first try the user provided directory - tempPath = lpszPath; - if (ZipPlatform::GetDeviceFreeSpace(tempPath) < iSizeNeeded) - tempPath.Empty(); - else { - CZipPathComponent::AppendSeparator(tempPath); - tempPath += prefix; - tempPath += _T("XXXXXX"); - TCHAR* c = mktemp(tempPath.GetBuffer(tempPath.GetLength())); - tempPath.ReleaseBuffer(); - if (c) - return tempPath; - else - tempPath.Empty(); - } - } - - TCHAR* v = tempnam(tempPath, prefix); - tempPath = v; - free(v); - - if (!tempPath.IsEmpty()) { - CZipPathComponent zpc(tempPath); - if (ZipPlatform::GetDeviceFreeSpace(zpc.GetFilePath()) < iSizeNeeded) - return empty; - return tempPath; - } else - return empty; -} - -bool -ZipPlatform::GetCurrentDirectory(CZipString& sz) -{ - char* pBuf = getcwd(NULL, 0); - if (!pBuf) - return false; - sz = pBuf; - free(pBuf); - return true; -} - -bool -ZipPlatform::SetFileAttr(LPCTSTR lpFileName, DWORD uAttr) -{ - return chmod(lpFileName, uAttr >> 16) == 0; -} - -bool -ZipPlatform::GetFileAttr(LPCTSTR lpFileName, DWORD& uAttr) -{ - struct stat sStats; - if (stat(lpFileName, &sStats) == -1) - return false; - uAttr = (sStats.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_IFMT)) << 16; - return true; -} - -bool -ZipPlatform::GetFileModTime(LPCTSTR lpFileName, time_t& ttime) -{ - - struct stat st; - if (stat(lpFileName, &st) != 0) - return false; - - ttime = st.st_mtime; - return ttime != -1; -} - -bool -ZipPlatform::SetFileModTime(LPCTSTR lpFileName, time_t ttime) -{ - struct utimbuf ub; - ub.actime = time(NULL); - ub.modtime = ttime == -1 - ? time(NULL) - : ttime; // if wrong file time, set it to the current - return utime(lpFileName, &ub) == 0; -} - -bool -ZipPlatform::ChangeDirectory(LPCTSTR lpDirectory) -{ - return chdir(lpDirectory) == 0; -} -int -ZipPlatform::FileExists(LPCTSTR lpszName) -{ - struct stat st; - if (stat(lpszName, &st) != 0) - return 0; - else { - if (S_ISDIR(st.st_mode)) - return -1; - else - return 1; - } -} - -ZIPINLINE bool -ZipPlatform::IsDriveRemovable(LPCTSTR lpszFilePath) -{ - // not implemmented - return true; -} - -ZIPINLINE bool -ZipPlatform::SetVolLabel(LPCTSTR lpszPath, LPCTSTR lpszLabel) -{ - // not implemmented - return true; -} - -ZIPINLINE void -ZipPlatform::AnsiOem(CZipAutoBuffer& buffer, bool bAnsiToOem) -{ - // not implemmented -} - -ZIPINLINE bool -ZipPlatform::RemoveFile(LPCTSTR lpszFileName, bool bThrow) -{ - if (unlink(lpszFileName) != 0) - if (bThrow) - CZipException::Throw(CZipException::notRemoved, lpszFileName); - else - return false; - return true; -} -ZIPINLINE bool -ZipPlatform::RenameFile(LPCTSTR lpszOldName, LPCTSTR lpszNewName, bool bThrow) -{ - - if (rename(lpszOldName, lpszNewName) != 0) - if (bThrow) - CZipException::Throw(CZipException::notRenamed, lpszOldName); - else - return false; - return true; -} -ZIPINLINE bool -ZipPlatform::IsDirectory(DWORD uAttr) -{ - return S_ISDIR(uAttr >> 16) != 0; -} -ZIPINLINE bool -ZipPlatform::CreateDirectory(LPCTSTR lpDirectory) -{ - return mkdir(lpDirectory, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) == 0; -} - -ZIPINLINE DWORD -ZipPlatform::GetDefaultAttributes() -{ - return 0x81a40000; -} - -ZIPINLINE DWORD -ZipPlatform::GetDefaultDirAttributes() -{ - return 0x41ff0010; -} - -ZIPINLINE int -ZipPlatform::GetSystemID() -{ - return ZipCompatibility::zcUnix; -} - -ZIPINLINE bool -ZipPlatform::GetSystemCaseSensitivity() -{ - return true; -} - -bool -ZipPlatform::TruncateFile(int iDes, DWORD iSize) -{ - return ftruncate(iDes, iSize) == 0; -} - -int -ZipPlatform::OpenFile(LPCTSTR lpszFileName, UINT iMode, int iShareMode) -{ - return open(lpszFileName, iMode, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); -} - -bool -ZipPlatform::FlushFile(int iDes) -{ - return fsync(iDes) == 0; -} - -int -ZipPlatform::GetFileSystemHandle(int iDes) -{ - return iDes; -} diff --git a/src/smpackagee/ZipArchive/Readme.txt b/src/smpackagee/ZipArchive/Readme.txt deleted file mode 100644 index 286b19deb6..0000000000 --- a/src/smpackagee/ZipArchive/Readme.txt +++ /dev/null @@ -1,645 +0,0 @@ -/* - -For conditions of distribution and use, see the copyright notice in License.txt. -Please read the documentation instead of this document -(it may be difficult to read it due to formatting tags for an automatic documentation generation). -If you do not have it, please download it from http://www.artpol-software.com/ - -*/ - -/** \mainpage ZipArchive library documentation - -\section secGen General Information - - -The ZipArchive library
-
-Copyright © 2000 - 2003 Tadeusz Dracz
-
- -\b Version: 2.3.4
-\b Date: 26-June-2003 - - -This library adds zip compression and decompression functionality to your program, allowing you to create and modify ZIP files in the compatible way with WinZip, PKZIP and other popular archivers. -Its easy and practical interface makes the library suitable for the beginners as well as for the advanced users. - -See \ref pageHist "what's new" in this version.
-To be notified about the future library updates, sign up for the \ref pageSubsc. - - -\ref pageSyst "Platforms supported:" -- Windows 9x\\Me\\NT\\2000\\XP (MFC and STL)
\ref sectVisual "Microsoft Visual C++ 6.0" (.NET compatible ), \ref sectBorl "Borland C++" - -- \ref sectLinux "Linux (STL)" - -\author Tadeusz Dracz
-E-Mail: \htmlonly tdracz@artpol-software.com \endhtmlonly
-Web Site: \htmlonly http://www.artpol-software.com \endhtmlonly - -This library uses \htmlonly the zlib library \endhtmlonly by Jean-loup Gailly and Mark Adler to perform inflate and deflate operations. - -\section sectFeat Features Summary: -- work in a compatible way with PKZIP and WinZip (apart from \ref TDSpan "TD disk spanning mode" which is specific to this library) -- create, modify, extract and test zip archives -- create and extract multi-disk archives (on non-removable disks as well) -- add file to the archive from another archive without decompressing the file (copy compressed data) (see CZipArchive::GetFromArchive) -- highly optimized deleting multiple files from the archive -- optimized replacing and renaming files in the archive -- compression from and decompression to memory, create the whole archive in memory, extract the archive from memory (see \ref sectMemory) -- password encryption and decryption supported -- possibility to create or extract self-extracting archives -- smart compression, if enabled, prevents the file in the archive to be larger after compression (see CZipArchive::Smartness) -- safe compression with CZipArchive::Flush function -- using functional objects as callback - - to provide easy disk change in a multi-disk archives - - for the progress control when adding, extracting, testing or deleting files or saving archive's central directory -- extracting and deleting using wildcard pattern matching (see CZipArchive::FindMatches) -- UNC and Windows Unicode paths recognized -- wide characters supported -- support for the Java TM Archive (jar) File Format (see CZipArchive::SetIgnoreCRC) -- can be used as a static library or DLL (necessary VC++ projects included) -- possibility to integrate help system with MSDN (see \ref sectHelp) -- easy interface -- easy transfer to other system platforms -- speedy -- well documented -- full source code provided -- sample applications provided (for the STL version located in \e stl/zippie, -the MFC version (multithreaded) is available separately) - -No software product is entirely bugless and neither is this library. If you find a bug (or suspect one), please mail me. The bugs are usually corrected within few days. Many thanks to the people that already tracked them down and submitted. - -\section secQl The Introduction - -All you need to know about the licensing: \ref pageLic . - -It's a good start to read these pages first (prior to reading the raw documentation): -- \ref pageSyst -- \ref pageGen - -Have you got a question? Maybe it's one of the \ref pageFaq "frequently asked questions". - -\ref pageHist not only shows how the development of the library went so far, but also you may find here an -interesting library feature without digging through the documentation. - -If you wish to be notified about the future library updates, sign up for the \ref pageSubsc . - - - - */ - -/** - - \page pageSyst Compilation & Integration - - \par - - \ref secCompil - - \ref winMFC - - \ref winSTL - - \ref LnxSTL - - \ref sectVisual - - \ref subsM1 - - \ref subsM2 - - \ref subsDLL - - \ref sectBorl - - \ref subExample - - \ref sectLinux - - \ref subsLnxNot - - \ref subsLnxCom - - \ref sectNotes - - \ref stlNotes - - \ref subDLLnotes - - \ref MFCsample - - - \section secCompil Compiling for different implementations and platforms - - - The files required for all the library versions are located in the program - root directory. You also need to copy additional files to the library - root directory from the two more subfolders. Depending on the configuration - these files are located in: - - - \subsection winMFC Windows MFC - \e \\Windows and \e \\mfc
- You can just execute _copy from Win-MFC.bat batch file. - - \subsection winSTL Windows STL - \e \\Windows and \e \\stl
- You can just execute _copy from Win-STL.bat batch file. - - \subsection LnxSTL Linux (STL version) - \e \\Linux and \e \\stl
- You can just execute _copy_from_Linux.sh script file - (don't forget to set executable rights before e.g. with the command: - chmod +x _copy_from_Linux.sh ). - - \note If you use one of the mentioned scripts to copy the files then for easy - orientation there will be a file \e __[...].zcfg created with the - name depending on the current configuration - - \section sectVisual Visual C++ : integrating with the project - - To add ZipArchive library functionality into your project you need to link - the library to the project. You can do this in at least two ways - (in both cases you need to include ZipArchive.h header in your sources). - - \subsection subsM1 Method 1 - - Add \e ZipArchive.lib with the proper path e.g. ..\\ZipArchive\\debug\\ZipArchive.lib to Project Settings->Link->Input->Object/library modules - and add ZipArchive library directory to the preprocessor searches ( Project Settings -> C++ -> Preprocessor -> Additional include directories ). - - \subsection subsM2 Method 2 (simpler) - - Insert Zip project into workspace and set project dependencies: your project dependent on ZipArchive project - ( Project -> Dependencies and then on the dialog that will appear - you select your project name from the combo box and check the box next to ZipArchive project name). - When you use this method, you link configurations in your project with - configurations in the ZipArchive project that have the same name in both projects. So if you need to use - for example "Static Release" configuration from ZipArchive project, you need to create one with the same name - in your application project and make sure that your project uses MFC library and run-time library in same way - ( Project->Settings->General->Microsoft Fundation Classes and Project->Settings-> c/c++ ->Code Generation->Use run-time library ). - - \subsection subsDLL DLL version - - When you're using the DLL version of the ZipArchive library, you need to define in your program ZIP_HAS_DLL (e.g. in Project Settings -> C++ -> Preprocessor -> Preprocessor definitions ). - Apart from integrating the ZipArchive library with your program (use one of the methods above), you also need to take into account zlib.lib file (use zlib/zlib.dsw to create it and add to preprocessor includes) or zlib/zlib.dsw project (insert into workspace and set ZipArchive project dependent on it)). - Files zlib.dll and ZipArchive.dll must be available for the program when running (e.g. in the program's directory). - - - - You can read about linking problems in the \ref pageFaq. - - \section sectBorl Borland C++ compatibility - The library contains a project files for Borland C++ 5.0 ( - They were created using Visual C++ Project Conversion Utility (VCTOBPR.EXE). - You can start this tool with the command Tools->Visual C++ Project Conversion Utility . - - \note Be sure to create \e Release subfolder before compiling one of these projects, - otherwise you'll get a write error. - - In case the projects provided don't work for you, you can create your own. You need to copy - to the root directory appropriate files for \ref winMFC "MFC" or \ref winSTL "STL" versions. - You may use the Borland project conversion utility. - - The library contains also \e makefiles which should work with other versions of Borland. - - - \subsection subExample Compiling the sample application - There is a Borland C++ project provided with the sample application \c ZipArc.
- To compile it you need compiled MFC version of ZipArchive library. - - \note Be sure to create \e Release subfolder first, otherwise you'll get - a write error. - - Add the library (\e ZipArchive.lib ) to the project (Project->Add To Project) and compile. - - If you wish to convert Visual C++ project using Visual C++ Project Conversion Utility then after - converting to properly compile the application you need to remove \e odbccp32.lib from the project file - and comment everything out in \e ZipArc_TLB.cpp or remove this file from the project files. - - \section sectLinux Linux platform - - \subsection subsLnxNot Notes - - - \b Usage - - When using the library under Linux you should be aware of a few things: - - after you get the system attributes with CZipFileHeader::GetSystemAttr() function, - you need to shift them right by 16 ( e.g. uAttr = header.GetSystemAttr() >> 16 ) - - the reason for that is the way the attributes are stored in the archive created under (or for) Linux. - - due to lack of implementation of ZipPlatform::IsDriveRemovable(), which has proven to be a kind of difficult to do, - the device containing the archive is always assumed to be removable; the only effect of this - is that you need to set \e iVolumeSize to a value different from 0 when opening with the function - CZipArchive::Open() the archive created in tdSpan mode. - - - \b Compiling - - - the library was tested under g++ version 2.96 - - warnings that use of the \c tempnam and \c mktemp is not safe can be ignored, because the - temporary file is created almost straight away. - - - \subsection subsLnxCom Compiling the library and liniking with the application - - First you need to copy the appropriate files (\ref LnxSTL "see above")
- - If you haven't got the zlib library already installed on your system, you can install - it using \e Makefile in the \e zlib subdirectory (type \e make and then make install ) - - only static version (you can download a full version of the zlib library from the ZipArchive library site). - If you don't want to install the zlib library, you need to include it in the ZipArchive library - ( edit the \e Makefile in the main directory and change comments, so that - OBJSZLIB is not an empty value but points to zlib library object files) - - Compile the library by typing \e make. The resulting file is a static library \e libziparch.a - - You can copy the library and the headers (if you have an appropriate rights) to \e /usr/lib and - \e /usr/include/ziparchive (you can change them in \e Makefile) with the command make install - - Now you can link the library to your application
- e.g. with the command (if the library is in the same directory)
- g++ $I. -o app app.cpp -lstdc++ -lz libziparch.a
- or if you have the library installed in the /usr subdirectories:
- g++ $I/usr/include/ziparchive -o app app.cpp -lstdc++ -lz -lziparch
- If you haven't got the zlib library installed, you need to omit the switch \e -lz in the above commands. - \anchor stlLinuxTest - - There is a test application named \e zippie.cpp (in \e stl/zippie which you can compile typing make zippie - (providing that you have installed the ZipArchive library). If you haven't got the zlib library installed, - you need to switch the comments (comment one line and uncomment another) in the \e Makefile in the section \e "zippie:". - - If you wish to uninstall the library type make uninstall - - \section sectNotes Notes - - \subsection stlNotes STL version - - [Windows only] If your locale is different from English and you wish to use non-English - characters in zip files, you need to set your locale with function - \e std::locale::global(std::locale("")) to set it to be the same as your - system locale or e.g. \e std::locale::global(std::locale("French")) - to set it to the specified value (do not use \e _T() macro here when using - Unicode); \e setlocale() function is not sufficient in this case. - - There is a sample application that compiles under Windows (MSVC) and Linux (see below - to find out \ref stlLinuxTest "how to compile it under Linux"). This sample application demonstrates most of the - ZipArchive library features and is located in \e stl/zippie. - - \subsection subDLLnotes Compiling as DLL - [Windows only] - - The project that compiles the DLL version of the ZipArchive library needs to have defined ZIP_HAS_DLL, ZIP_BUILD_DLL and also ZLIB_DLL. - - The project that uses the ZipArchive library as the DLL version need to have defined ZIP_HAS_DLL - - \subsection MFCsample MFC sample application (ZipArc) - MFC sample application using ZipArchive library is available separately. Main features: - - MDI application - - multithreaded - you can work with many zip files at one time - - shell integration (remembers the last application used to open zip files and can restore it correctly) - - drag & drop support - - detailed error reports - - you can open and modify SFX archives - - it demonstrates the use of the following functions (most of them are placed in ZipArcDoc.cpp) : - CZipArchive::AddNewFile, - CZipArchive::Close, - CZipArchive::CloseFile, - CZipArchive::CloseNewFile, - CZipArchive::DeleteFiles, - CZipArchive::EnableFindFast, - CZipArchive::ExtractFile, - CZipArchive::FindFile, - CZipArchive::FindMatches, - CZipArchive::Flush, - CZipArchive::GetArchivePath, - CZipArchive::GetCentralDirInfo, - CZipArchive::GetCentralDirSize, - CZipArchive::GetCurrentDisk, - CZipArchive::GetFileInfo, - CZipArchive::GetFindFastIndex, - CZipArchive::GetGlobalComment, - CZipArchive::GetCount, - CZipArchive::GetPassword, - CZipArchive::GetSpanMode, - CZipArchive::IsClosed, - CZipArchive::IsReadOnly, - CZipArchive::Open, - CZipArchive::RenameFile, - CZipArchive::PredictExtractedFileName, - CZipArchive::SetAdvanced, - CZipArchive::SetCallback, - CZipArchive::SetFileComment, - CZipArchive::SetGlobalComment, - CZipArchive::SetIgnoreCRC, - CZipArchive::SetPassword, - CZipArchive::SetRootPath, - CZipArchive::SetSpanCallback, - CZipArchive::SetTempPath, - CZipArchive::TestFile, - CZipArchive::WillBeDuplicated,
- CZipFileHeader::IsEncrypted, - CZipFileHeader::IsDirectory, - CZipFileHeader::GetTime, - CZipFileHeader::GetSystemCompatibility, - CZipFileHeader::GetSystemAttr, - CZipFileHeader::GetSize, - CZipFileHeader::GetFileName, - CZipFileHeader::GetEffComprSize, - CZipFileHeader::GetCompressionRatio, - CZipFileHeader::GetComment, - CZipFileHeader::CompressionEfficient, - - -*/ - - -/** - -\page pageGen General Information - -\par -\ref sectCompress -\par -\ref sectSpan -\par -\ref sectPass -\par -\ref sectSE -\par -\ref sectExc -\par -\ref sectMemory -\par -\ref sectCallb -\par -\ref sectHelp -\par - - - -\section sectCompress Compression and decompression - -There are some functions defined for fast operations on archive: CZipArchive::AddNewFile, - CZipArchive::ExtractFile, CZipArchive::DeleteFile, CZipArchive::TestFile. - You only need to call functions CZipArchive::Open - before and CZipArchive::Close - after using them. Calling CZipArchive::Close function after you've done modifying the archive is necessary -for the archive to be intact. - -\section sectSpan Multi-disk archives - -This library can create multi-disk archives in two ways (modes): - -\anchor PKSpan -- PKSpan mode. Disk spanning is performed in the compatible way with all other main zip programs. It means that: - - the archive can only be created on a removable device, - - the size of the volume is auto-detected - - the label is written to the disk - - you need to define a callback functor for changing disks and set it with CZipArchive::SetSpanCallback function. - -\anchor TDSpan -- TDSpan mode. Disk spanning is performed in the internal mode. It means that: - - the archive can be created on non-removable device as well - - you need to define the single volume size - - there is no need to set callback functor in this mode. - -\anchor convertZips -These two disk spanning modes create volumes with compatible internal structure. It means that you can easily convert the volumes created in one mode to the other one by renaming the files (in TDSpan mode each volume but last has a number as an extension). To convert the archive from TD to PKZIP compatible archive, copy each file to the removable media, giving them the extension ".zip". You should also label each disk with the appropriate label starting from "pkback# 001" -(note the space between '#' and '0'). - -There is a limited functions set available while working with multi-disk archives. Only adding is allowed when creating the archive and only extracting and testing after opening an existing one. Deleting files from these archives is not allowed at all. - -Class CZipArchive uses write buffer to make write operations as fast as possible. You can change its size with CZipArchive::SetAdvanced function (first argument). While creating a multi-disk archive, set the size of the buffer to the maximum size of the volume for the best performance. - -The popular archivers such as PKZIP and WinZip cannot operate on archive in TDSpan mode. You need to convert them to PKZIP span mode (\ref convertZips "have a look above"). Remember about copying the files to the removable media (it does not comply with Winzip, which can extract a multi-disk archive from any media but only from the fixed location on the drive). - -\section sectPass Password encryption and decryption - -This library supports creating and extracting the password protected archives. There are several issues you should be aware of when using this feature. To set the password for the file to be added or extracted call the function CZipArchive::SetPassword with the password as the argument. To clear the password call this function without arguments or with an empty string argument. The function has no effect on a closed archive and on the currently opened file (whether new or existing) inside archive. During opening the archive the password is cleared. You can set different passwords for different files inside the same archive, but remember to set it BEFORE opening the file. You cannot use ASCII characters with codes above 127 in the password, if you do so, the function CZipArchive::SetPassword returns false and the password is cleared. -You can find out what files are password encrypted by calling CZipArchive::GetFileInfo, which fills the structure CZipFileHeader with data, and then call the method ZipFileHeader::IsEncrypted. If it returns true, the file needs a password to extract. -The successful extraction of the encrypted file doesn't always mean that the password is correct. You also need to check the return value of CZipArchive::CloseFile. You could also check the size of the extracted file since it can be smaller than it should be in case of the bad password. - -\section sectSE Self extract support - -The library is capable of extracting and modifying self-extracting archives. You can create your own SFX archive as well. This is the simplest code responsible for the self-extracting: - -\code -//Windows code - -int APIENTRY WinMain(HINSTANCE hInstance, -HINSTANCE hPrevInstance, -LPSTR lpCmdLine, -int nCmdShow) -{ - CZipArchive zip; - - // get the path of the executable - TCHAR szBuff[_MAX_PATH]; - if (!::GetModuleFileName(hInstance, szBuff, _MAX_PATH)) - return -1; - - CZipString szDest; - // ... - // add some code here to get the destination directory from the user - // for example: - // CBrowseForFolder bf; - // bf.strTitle = _T("Select directory to extract files"); - // if (!bf.GetFolder(szDest)) - // return -1; - // - // class CBrowseForFolder is included in the sample application project - // remember about including the header! - zip.Open(szBuff, CZipArchive::zipOpenReadOnly); - // zipOpenReadOnly mode is necessary for self extract archives - for (WORD i = 0; i < zip.GetCount(); i++) - zip.ExtractFile(i, szDest); - - zip.Close(); - return 0; - // this code will not work for the encrypted archives since it is needed - // to get the password from the user ( a small addition to the - // existing code I suppose ) -} - -\endcode - -After compiling it and appending a zip archive to it (e.g. with the DOS command: copy /b SelfExtract.exe + ZipFile.zip FinalFile.exe ) you have a self extracting archive. - - -\section sectExc Exceptions - -The ZipArchive library mostly uses exceptions to notify about the error occured. The library throws CZipException to notify about errors specific to the internal zip file processing. In the MFC version CZipException class is derived from CException whereas in the STL version it is derived from std::exception. - -\subsection excmfc MFC version -The library throws the following exceptions inherited from \c CException: \c CMemoryException*, \c CFileExeption* and \c CZipException* (be sure to delete the object when you done with it). Handling them may be done in the following way: - -\code - -try -{ - // ... - // some operations on the ZipArchive library -} -catch (CException* e) -{ - if (e->IsKindOf( RUNTIME_CLASS( CZipException ))) - { - CZipException* p = (CZipException*) e; - //... and so on - } - else if (e->IsKindOf( RUNTIME_CLASS( CFileException ))) - { - CFileException* p = (CFileException*) e; - //... and so on - } - else - { - // the only possibility is a memory exception I suppose - //... and so on - } - e->Delete(); -} - - -\endcode - -\subsection excstl STL version -The library throws exceptions inherited from \c std::exception. In this case you should catch \c std::exception object (not a pointer to it). - -\section sectMemory Creating and extracting archives from/in memory - -With the function CZipArchive::Open(CZipMemFile&, int) you can create the archive in memory and then write to disk, e.g.: - -\code - -CZipArchive zip; -CZipMemFile mf; -// create archive in memory -zip.Open(mf, CZipArchive::zipCreate); -// ... -// add some files to archive here e.g. by calling CZipArchive::AddNewFile -// ... -zip.Close(); -// write the archive to disk -CZipFile f; -if (f.Open("c:\\temp.zip", CZipFile::modeWrite|CZipFile::modeCreate, false) -{ - int iLen = mf.GetLength(); - BYTE* b = mf.Detach(); - f.Write(b, iLen); - f.Close(); - // we must free the detached memory - free(b); -} -\endcode - -You can as well read the archive from disk and then extract files, e.g.: - -\code -CZipFile f; -if (f.Open("c:\\temp.zip", CZipFile::modeRead, false) -{ - int iLen = f.GetLength(); - BYTE* b = (BYTE*)malloc((UINT)iLen); - f.Read(b, iLen); - f.Close(); - CZipMemFile mf; - mf.Attach(b, iLen); - CZipArchive zip; - zip.Open(mf); - // ... - // extract files here from the archive e.g. by calling CZipArchive::ExtractFile - // ... - zip.Close(); -} -\endcode - -With functions CZipArchive::AddNewFile(CZipMemFile&, LPCTSTR, int, int, unsigned long) and -CZipArchive::ExtractFile(WORD, CZipMemFile&, DWORD) you can add files to archive from memory -and extract them to a memory file. Now a bit larger example: - -\code -// create the archive in memory with two files inside -CZipMemFile mf; -CZipArchive zip; -zip.Open(mf, CZipArchive::zipCreate); -zip.AddNewFile("c:\\testfile1.txt"); -zip.AddNewFile("c:\\testfile2.txt"); -zip.Close(); -//create the archive on disk and add a previously zipped file from memory -zip.Open("c:\\test.zip", CZipArchive::zipCreate); -zip.AddNewFile(mf, "File1.zip"); -zip.Close(); -// we have now zip-in-zip file on the disk, -// let's extract the embedded zip file back to memory -zip.Open("c:\\test.zip"); -// reset the contents of the CZipMemFile object -mf.SetLength(0); -zip.ExtractFile(0, mf); -zip.Close(); -// write the file from memory to disk -CZipFile f; -if (f.Open("c:\\File1.zip", CZipFile::modeWrite|CZipFile::modeCreate, false)) -{ - int iLen = mf.GetLength(); - BYTE* b = mf.Detach(); - f.Write(b, iLen); - f.Close(); - // we must free the detached memory - free(b); -} -\endcode - - -One important thing: when you operate on the archive in memory, you must ensure -that CZipMemory object will not be destroyed before calling CZipArchive::Close. -In some cases you'll need to construct the object using the \c new operator, e.g.: -\code -// ... -CZipMemFile* pmf = new CZipMemFile; -zip.Open(*pmf, CZipArchive::zipCreate); -// ... -zip.Close(); -delete pmf; -\endcode - -\section sectCallb Action progress notifications (callbacks) - -The library has the possibility to notify about the progress of the various actions (see CZipArchive::CallbackType). -To use this feature you need to define a new class derived from CZipActionCallback or from CZipSpanCallback and override -CZipCallback::Callback function. Then you need to declare an object of your class and pass its address to -function CZipArchive::SetCallback or CZipArchive::SetSpanCallback. Make sure that the object exists while the library -performs the action the functor was assigned to. -or tell the library not to use the callback (use the same functions). - - -\section sectHelp Integrating with MSDN - -If you wish to integrate the ZipArchive help system with the MSDN library you need to: -- download from -\htmlonly -the Artpol Software site -\endhtmlonly -ZipArchive HTML Help documentation or ZipArchive HTML documentation if you don't have it. -- in the latter case you need to compile the html files to the HTML Help format -with HTML Web Workshop by Microsoft (at the moment of writing available i.a. -\htmlonly -here) -\endhtmlonly -and using provided \e index.hhp file (it is at the same location as ZipArchive html help files) -- now you should have \e index.chm and \e index.chi files, rename them if you want to and put them -to the directory of your choice -- you need to download a free MSDN Integration Utility by Kirk Stowell; you can download it from -\htmlonly -the Code Project site -or from the Artpol Software site -\endhtmlonly -(Download->ZipArchive) -- use the MSDN Integration Utility for the files you have prepared -- now pressing the F1 key on the ZipArchive library method or class in the Visual Studio brings up the MSDN help; -you have also a searchable ZipArchive collection inside MSDN -\note After integrating the ZipArchive help system with the MSDN library, you need -to be patient when you use the Index for the first time, because it'll be rebuilt then which can -be a lengthy process. -*/ - -/** -\page pageSubsc ZipArchive Newsletter - -To be notified about ZipArchive library updates, enter your -e-mail into the input field below and press \e Subscribe! button. -You should receive a confirmation message then. - -\htmlonly - -
- - - - -
- - -

Privacy Policy of the ZipArchvie library Newsletter List

-
    -
  • The information you provide, will never be made available to any third party company. -
  • Only the Web Master of the Artpol Software site will have an access to the mailing list. -
  • If at anytime you wish to be removed from the mailing list, you can do it by -following the link that you will receive with every newsletter. -
- -\endhtmlonly - -*/ - \ No newline at end of file diff --git a/src/smpackagee/ZipArchive/StdAfx.cpp b/src/smpackagee/ZipArchive/StdAfx.cpp deleted file mode 100644 index fb36433f05..0000000000 --- a/src/smpackagee/ZipArchive/StdAfx.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: stdafx.cpp $ -// $Archive: /ZipArchive/stdafx.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" diff --git a/src/smpackagee/ZipArchive/StdAfx.h b/src/smpackagee/ZipArchive/StdAfx.h deleted file mode 100644 index 3048192819..0000000000 --- a/src/smpackagee/ZipArchive/StdAfx.h +++ /dev/null @@ -1,48 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: stdafx.h $ -// $Archive: /ZipArchive/stdafx.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_) -#define AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#if _MSC_VER < 1300 && !defined __BORLANDC__ -#define ZIPINLINE inline -#else -#define ZIPINLINE -#endif - -#if _MSC_VER >= 1300 -#define ZIP_ULONGLONG ULONGLONG -#define ZIP_LONGLONG LONGLONG -#else -#define ZIP_ULONGLONG DWORD -#define ZIP_LONGLONG LONG -#endif - -#define ZIP_ARCHIVE_MFC - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#include -#include - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/Windows/ZipFileMapping.h b/src/smpackagee/ZipArchive/Windows/ZipFileMapping.h deleted file mode 100644 index cb261b84cd..0000000000 --- a/src/smpackagee/ZipArchive/Windows/ZipFileMapping.h +++ /dev/null @@ -1,69 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFileMapping.h $ -// $Archive: /ZipArchive/ZipFileMapping.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -// -// Check the site http://www.artpol-software.com for the updated version of the -// library. -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_) -#define AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "ZipFile.h" -namespace ziparchv { - -struct CZipFileMapping -{ - CZipFileMapping() - { - m_hFileMap = NULL; - m_pFileMap = NULL; - } - bool CreateMapping(CZipFile* pFile) - { - if (!pFile) - return false; - m_hFileMap = CreateFileMapping( - (*pFile), NULL, PAGE_READWRITE, 0, 0, _T("ZipArchive Mapping File")); - if (!m_hFileMap) - return false; - // Get pointer to memory representing file - m_pFileMap = MapViewOfFile(m_hFileMap, FILE_MAP_WRITE, 0, 0, 0); - return (m_pFileMap != NULL); - } - void RemoveMapping() - { - if (m_pFileMap) { - UnmapViewOfFile(m_pFileMap); - m_pFileMap = NULL; - } - if (m_hFileMap) { - CloseHandle(m_hFileMap); - m_hFileMap = NULL; - } - } - ~CZipFileMapping() { RemoveMapping(); } - char* GetMappedMemory() { return reinterpret_cast(m_pFileMap); } - - protected: - HANDLE m_hFileMap; - LPVOID m_pFileMap; -}; -} - -#endif // !defined(AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/Windows/ZipPathComponent.cpp b/src/smpackagee/ZipArchive/Windows/ZipPathComponent.cpp deleted file mode 100644 index abbaaada45..0000000000 --- a/src/smpackagee/ZipArchive/Windows/ZipPathComponent.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPathComponent.cpp $ -// $Archive: /ZipArchive/ZipPathComponent.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipPathComponent.h" -#include "stdafx.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CZipPathComponent::~CZipPathComponent() {} - -void -CZipPathComponent::SetFullPath(LPCTSTR lpszFullPath) -{ - - TCHAR szDrive[_MAX_DRIVE]; - TCHAR szDir[_MAX_DIR]; - TCHAR szFname[_MAX_FNAME]; - TCHAR szExt[_MAX_EXT]; - - CZipString szTempPath(lpszFullPath); - const CZipString szPrefix = _T("\\\\?\\unc\\"); - int i = -1, iLen = szPrefix.GetLength(); - if (iLen > szTempPath.GetLength()) - iLen = szTempPath.GetLength(); - CZipString szPossiblePrefix = szTempPath.Left(iLen); - szPossiblePrefix.MakeLower(); // must perform case insensitive comparison - while (++i < iLen && szPossiblePrefix[i] == szPrefix[i]) - ; - if (i == 2 || i == 4 || i == 8) // unc path, unicode path or unc path - // meeting windows file name conventions - { - m_szPrefix = szTempPath.Left(i); - szTempPath = szTempPath.Mid(i); - } else - m_szPrefix.Empty(); - - _tsplitpath(szTempPath, szDrive, szDir, szFname, szExt); - m_szDrive = szDrive; - m_szDirectory = szDir; - - m_szDirectory.TrimLeft(m_cSeparator); - m_szDirectory.TrimRight(m_cSeparator); - SetExtension(szExt); - m_szFileTitle = szFname; -} - -CZipString -CZipPathComponent::GetNoDrive() const -{ - CZipString szPath = m_szDirectory; - CZipString szFileName = GetFileName(); - if (!szFileName.IsEmpty() && !szPath.IsEmpty()) - szPath += m_cSeparator; - - szPath += szFileName; - return szPath; -} diff --git a/src/smpackagee/ZipArchive/Windows/ZipPlatform.cpp b/src/smpackagee/ZipArchive/Windows/ZipPlatform.cpp deleted file mode 100644 index 03d1259351..0000000000 --- a/src/smpackagee/ZipArchive/Windows/ZipPlatform.cpp +++ /dev/null @@ -1,370 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPlatform.cpp $ -// $Archive: /ZipArchive/ZipPlatform.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipPlatform.h" -#include "ZipAutoBuffer.h" -#include "ZipException.h" -#include "ZipFileHeader.h" -#include "stdafx.h" -#include - -#if defined _MSC_VER && !defined __BORLANDC__ -#include -#else -#include -#endif - -#include "ZipCompatibility.h" -#include "ZipPathComponent.h" -#include -#include -#include - -const TCHAR CZipPathComponent::m_cSeparator = _T('\\'); - -#ifndef _UTIMBUF_DEFINED -#define _utimbuf utimbuf -#endif - -DWORD -ZipPlatform::GetDeviceFreeSpace(LPCTSTR lpszPath) -{ - DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, - TotalNumberOfClusters; - CZipPathComponent zpc(lpszPath); - CZipString szDrive = zpc.GetFileDrive(); - if (!GetDiskFreeSpace(szDrive, - &SectorsPerCluster, - &BytesPerSector, - &NumberOfFreeClusters, - &TotalNumberOfClusters)) { - CZipPathComponent::AppendSeparator(szDrive); // in spite of what is - // written in MSDN it is - // sometimes needed (on - // fixed disks) - if (!GetDiskFreeSpace(szDrive, - &SectorsPerCluster, - &BytesPerSector, - &NumberOfFreeClusters, - &TotalNumberOfClusters)) - - return 0; - } - __int64 total = SectorsPerCluster * BytesPerSector * NumberOfFreeClusters; - return (DWORD)total; -} - -bool -ZipPlatform::GetFileSize(LPCTSTR lpszFileName, DWORD& dSize) -{ - HANDLE f = CreateFile(lpszFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - 0, - NULL); - if (!f) - return false; - DWORD dwSize; - dwSize = ::GetFileSize(f, NULL); - CloseHandle(f); - if (dwSize == 0xFFFFFFFF) - return false; - dSize = dwSize; - return true; -} - -CZipString -ZipPlatform::GetTmpFileName(LPCTSTR lpszPath, DWORD iSizeNeeded) -{ - TCHAR empty[] = _T(""); - CZipString tempPath; - bool bCheckTemp = true; - if (lpszPath) { - tempPath = lpszPath; - bCheckTemp = GetDeviceFreeSpace(tempPath) < iSizeNeeded; - } - if (bCheckTemp) { - DWORD size = GetTempPath(0, NULL); - if (size == 0) - return empty; - - GetTempPath(size, tempPath.GetBuffer(size)); - tempPath.ReleaseBuffer(); - if (GetDeviceFreeSpace(tempPath) < iSizeNeeded) { - if (!GetCurrentDirectory(tempPath) || - GetDeviceFreeSpace(tempPath) < iSizeNeeded) - return empty; - } - } - CZipString tempName; - if (!GetTempFileName(tempPath, _T("ZAR"), 0, tempName.GetBuffer(_MAX_PATH))) - return empty; - tempName.ReleaseBuffer(); - return tempName; -} - -bool -ZipPlatform::GetCurrentDirectory(CZipString& sz) -{ - DWORD i = ::GetCurrentDirectory(0, NULL); - if (!i) - return false; - TCHAR* pBuf = new TCHAR[i]; - bool b = true; - if (!::GetCurrentDirectory(i, pBuf)) - b = false; - else - sz = pBuf; - delete[] pBuf; - return b; -} - -bool -ZipPlatform::SetFileAttr(LPCTSTR lpFileName, DWORD uAttr) -{ - return ::SetFileAttributes(lpFileName, uAttr) != 0; -} - -bool -ZipPlatform::GetFileAttr(LPCTSTR lpFileName, DWORD& uAttr) -{ - // not using MFC due to MFC bug (attr is one byte there) - DWORD temp = ::GetFileAttributes(lpFileName); - if (temp == -1) - return false; - uAttr = temp; - return true; -} - -bool -ZipPlatform::GetFileModTime(LPCTSTR lpFileName, time_t& ttime) -{ -#if defined _MSC_VER && !defined __BORLANDC__ - struct _stat st; - if (_tstat(lpFileName, &st) != 0) -#else - struct stat st; - if (stat(lpFileName, &st) != 0) -#endif - return false; - - ttime = st.st_mtime; - return ttime != -1; -} - -bool -ZipPlatform::SetFileModTime(LPCTSTR lpFileName, time_t ttime) -{ - struct _utimbuf ub; - ub.actime = time(NULL); - ub.modtime = ttime == -1 - ? time(NULL) - : ttime; // if wrong file time, set it to the current - return _tutime(lpFileName, &ub) == 0; -} - -bool -ZipPlatform::ChangeDirectory(LPCTSTR lpDirectory) -{ - return _tchdir(lpDirectory) == 0; // returns 0 if ok -} -int -ZipPlatform::FileExists(LPCTSTR lpszName) -{ - if (_taccess(lpszName, 0) == 0) { - if (DirectoryExists(lpszName)) - return -1; - return 1; - } else - return 0; -} - -ZIPINLINE bool -ZipPlatform::IsDriveRemovable(LPCTSTR lpszFilePath) -{ - CZipPathComponent zpc(lpszFilePath); - return ::GetDriveType(zpc.GetFileDrive()) == DRIVE_REMOVABLE; -} - -ZIPINLINE bool -ZipPlatform::SetVolLabel(LPCTSTR lpszPath, LPCTSTR lpszLabel) -{ - CZipPathComponent zpc(lpszPath); - CZipString szDrive = zpc.GetFileDrive(); - CZipPathComponent::AppendSeparator(szDrive); - return ::SetVolumeLabel(szDrive, lpszLabel) != 0; -} - -ZIPINLINE void -ZipPlatform::AnsiOem(CZipAutoBuffer& buffer, bool bAnsiToOem) -{ - if (bAnsiToOem) - CharToOemBuffA(buffer, buffer, buffer.GetSize()); - else - OemToCharBuffA(buffer, buffer, buffer.GetSize()); -} - -ZIPINLINE bool -ZipPlatform::RemoveFile(LPCTSTR lpszFileName, bool bThrow) -{ - if (!::DeleteFile((LPTSTR)lpszFileName)) - if (bThrow) - CZipException::Throw(CZipException::notRemoved, lpszFileName); - else - return false; - return true; -} -ZIPINLINE bool -ZipPlatform::RenameFile(LPCTSTR lpszOldName, LPCTSTR lpszNewName, bool bThrow) -{ - if (!::MoveFile((LPTSTR)lpszOldName, (LPTSTR)lpszNewName)) - if (bThrow) - CZipException::Throw(CZipException::notRenamed, lpszOldName); - else - return false; - return true; -} -ZIPINLINE bool -ZipPlatform::IsDirectory(DWORD uAttr) -{ - return (uAttr & FILE_ATTRIBUTE_DIRECTORY) != 0; -} -ZIPINLINE bool -ZipPlatform::CreateDirectory(LPCTSTR lpDirectory) -{ - return ::CreateDirectory(lpDirectory, NULL) != 0; -} - -ZIPINLINE DWORD -ZipPlatform::GetDefaultAttributes() -{ - return 0x81a40020; // make it readable under Unix -} - -ZIPINLINE DWORD -ZipPlatform::GetDefaultDirAttributes() -{ - return 0x41ff0010; // make it readable under Unix -} - -ZIPINLINE int -ZipPlatform::GetSystemID() -{ - return ZipCompatibility::zcDosFat; -} - -ZIPINLINE bool -ZipPlatform::GetSystemCaseSensitivity() -{ - return false; -} - -#ifdef _UNICODE -int -ZipPlatform::WideToSingle(LPCTSTR lpWide, CZipAutoBuffer& szSingle) -{ - size_t wideLen = wcslen(lpWide); - if (wideLen == 0) { - szSingle.Release(); - return 0; - } - - // iLen does not include terminating character - int iLen = - WideCharToMultiByte(CP_ACP, 0, lpWide, wideLen, szSingle, 0, NULL, NULL); - if (iLen > 0) { - szSingle.Allocate(iLen, true); - iLen = WideCharToMultiByte( - CP_ACP, 0, lpWide, wideLen, szSingle, iLen, NULL, NULL); - ASSERT(iLen != 0); - } else // here it means error - { - szSingle.Release(); - iLen--; - } - return iLen; -} -int -ZipPlatform::SingleToWide(const CZipAutoBuffer& szSingle, CZipString& szWide) -{ - int singleLen = szSingle.GetSize(); - // iLen doesn't include terminating character - int iLen = MultiByteToWideChar( - CP_ACP, MB_PRECOMPOSED, szSingle.GetBuffer(), singleLen, NULL, 0); - if (iLen > 0) { - iLen = MultiByteToWideChar(CP_ACP, - MB_PRECOMPOSED, - szSingle.GetBuffer(), - singleLen, - szWide.GetBuffer(iLen), - iLen); - szWide.ReleaseBuffer(iLen); - ASSERT(iLen != 0); - } else { - szWide.Empty(); - iLen--; // return -1 - } - return iLen; -} -#endif - -#ifndef _MFC_VER -#include -#include -bool -ZipPlatform::TruncateFile(int iDes, DWORD iSize) -{ - int ret = chsize(iDes, iSize); - return ret != -1; -} - -int -ZipPlatform::OpenFile(LPCTSTR lpszFileName, UINT iMode, int iShareMode) -{ - switch (iShareMode) { - case (CZipFile::shareDenyWrite & CZipFile::shareDenyRead): - iShareMode = SH_DENYRW; - break; - case (CZipFile::shareDenyRead): - iShareMode = SH_DENYRD; - break; - case (CZipFile::shareDenyWrite): - iShareMode = SH_DENYWR; - break; - default: - iShareMode = SH_DENYNO; - } - return _tsopen(lpszFileName, - iMode, - iShareMode, - S_IREAD | S_IWRITE /*required only when O_CREAT mode*/); -} - -bool -ZipPlatform::FlushFile(int iDes) -{ - return _commit(iDes) == 0; -} - -int -ZipPlatform::GetFileSystemHandle(int iDes) -{ - return _get_osfhandle(iDes); -} - -#endif //_MFC_VER diff --git a/src/smpackagee/ZipArchive/ZipAbstractFile.h b/src/smpackagee/ZipArchive/ZipAbstractFile.h deleted file mode 100644 index 548674b793..0000000000 --- a/src/smpackagee/ZipArchive/ZipAbstractFile.h +++ /dev/null @@ -1,54 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipAbstractFile.h $ -// $Archive: /ZipArchive/ZipAbstractFile.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#if !defined( \ - AFX_ZIPABSTRACTFILE_H__46F247DE_21A6_4D12_AF64_B5A6B3CF4D57__INCLUDED_) -#define AFX_ZIPABSTRACTFILE_H__46F247DE_21A6_4D12_AF64_B5A6B3CF4D57__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#include "ZipExport.h" -#include "ZipString.h" -#include "global.h" - -class ZIP_API CZipAbstractFile -{ - public: - enum - { - begin = SEEK_SET, // 0 - current = SEEK_CUR, // 1 - end = SEEK_END // 2 - }; - CZipAbstractFile() {} - virtual bool Open(LPCTSTR, UINT, bool) { return true; } - virtual void Close() = 0; - virtual void Flush() = 0; - virtual ZIP_ULONGLONG GetPosition() const = 0; - virtual ZIP_ULONGLONG Seek(ZIP_LONGLONG lOff, int nFrom) = 0; - virtual ZIP_ULONGLONG GetLength() const = 0; - virtual void SetLength(ZIP_ULONGLONG nNewLen) = 0; - virtual ZIP_ULONGLONG SeekToBegin() { return Seek(0, begin); } - virtual ZIP_ULONGLONG SeekToEnd() { return Seek(0, end); } - virtual CZipString GetFilePath() const = 0; - virtual UINT Read(void* lpBuf, UINT nCount) = 0; - virtual void Write(const void* lpBuf, UINT nCount) = 0; - virtual bool IsClosed() const = 0; - virtual ~CZipAbstractFile(){}; -}; - -#endif // !defined(AFX_ZIPABSTRACTFILE_H__46F247DE_21A6_4D12_AF64_B5A6B3CF4D57__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipArchive-net2003.vcproj b/src/smpackagee/ZipArchive/ZipArchive-net2003.vcproj deleted file mode 100644 index 174388a48a..0000000000 --- a/src/smpackagee/ZipArchive/ZipArchive-net2003.vcproj +++ /dev/null @@ -1,1285 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/smpackagee/ZipArchive/ZipArchive-net2008.vcproj b/src/smpackagee/ZipArchive/ZipArchive-net2008.vcproj deleted file mode 100644 index 1874a384db..0000000000 --- a/src/smpackagee/ZipArchive/ZipArchive-net2008.vcproj +++ /dev/null @@ -1,1686 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/smpackagee/ZipArchive/ZipArchive.cpp b/src/smpackagee/ZipArchive/ZipArchive.cpp deleted file mode 100644 index ad30d0c2f6..0000000000 --- a/src/smpackagee/ZipArchive/ZipArchive.cpp +++ /dev/null @@ -1,2908 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipArchive.cpp $ -// $Archive: /ZipArchive/ZipArchive.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipArchive.h" -#include "stdafx.h" -// #include "ZipPathComponent.h" -#include "ZipCompatibility.h" -#include "ZipPlatform.h" - -#include - -#ifndef DEF_MEM_LEVEL -#if MAX_MEM_LEVEL >= 8 -#define DEF_MEM_LEVEL 8 -#else -#define DEF_MEM_LEVEL MAX_MEM_LEVEL -#endif -#endif - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define ZIP_COMPR_REPL_MASK 0xffffff00 -#define ZIP_COMPR_REPL_SIGN \ - 0x0100 // first 8 bits should be 00 (reserved for compression level), next 8 - // should be different from ff (to distinguish from -1) - -const TCHAR CZipArchive::m_gszCopyright[] = { - _T("ZipArchive library Copyright 2000 - 2003 Tadeusz Dracz") -}; - -void -CZipAddNewFileInfo::Defaults() -{ - m_iSmartLevel = CZipArchive::zipsmSafeSmart; - m_iReplaceIndex = -1; - m_nBufSize = 65536; - m_iComprLevel = -1; // default -} - -CZipArchive::CZipArchive() -{ - - m_bRemoveDriveLetter = m_bDetectZlibMemoryLeaks = true; - m_bIgnoreCRC = m_bAutoFlush = false; - m_centralDir.m_pStorage = &m_storage; - m_info.m_stream.zalloc = (alloc_func)_zliballoc; - m_info.m_stream.zfree = (free_func)_zlibfree; - m_iFileOpened = nothing; - SetCaseSensitivity(ZipPlatform::GetSystemCaseSensitivity()); -} - -CZipArchive::~CZipArchive() -{ - // Close(); // cannot be here: if an exception is thrown strange things can - // happen - EmptyPtrList(); -} - -void -CZipArchive::Open(LPCTSTR szPathName, int iMode, int iVolumeSize) -{ - if (!IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive already opened.\n"), __FILE__, __LINE__); - return; - } - m_storage.Open(szPathName, iMode, iVolumeSize); - OpenInternal(iMode); -} - -void -CZipArchive::Open(CZipMemFile& mf, int iMode) -{ - if (!IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive already opened.\n"), __FILE__, __LINE__); - return; - } - if (iMode != zipOpen && iMode != zipOpenReadOnly && iMode != zipCreate) { - TRACE(_T("%s(%i) : Mode not supported.\n"), __FILE__, __LINE__); - return; - } - m_storage.Open(mf, iMode); - OpenInternal(iMode); -} - -void -CZipArchive::OpenInternal(int iMode) -{ - m_pszPassword.Release(); - m_iFileOpened = nothing; - m_centralDir.Init(); - m_iArchiveSystCompatib = ZipPlatform::GetSystemID(); - m_szRootPath.Empty(); - if ((iMode == zipOpen) || (iMode == zipOpenReadOnly)) { - m_centralDir.Read(); - // if there is at least one file, get system comp. from the first one - if (m_centralDir.IsValidIndex(0)) { - int iSystemComp = m_centralDir[0]->GetSystemCompatibility(); - if (ZipCompatibility::IsPlatformSupported(iSystemComp)) - m_iArchiveSystCompatib = iSystemComp; - } - } -} - -bool -CZipArchive::IsClosed(bool bArchive) const -{ - return bArchive ? (m_storage.GetCurrentDisk() == -1) - : (!m_storage.m_pFile || m_storage.m_pFile->IsClosed()); -} - -void -CZipArchive::ThrowError(int err, bool bZlib) -{ - if (bZlib) - err = CZipException::ZlibErrToZip(err); - CZipException::Throw( - err, IsClosed() ? _T("") : (LPCTSTR)m_storage.m_pFile->GetFilePath()); -} - -bool -CZipArchive::GetFileInfo(CZipFileHeader& fhInfo, WORD uIndex) const -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return false; - } - - if (!m_centralDir.IsValidIndex(uIndex)) - return false; - - fhInfo = *(m_centralDir[uIndex]); - m_centralDir.ConvertFileName(true, false, &fhInfo); - return true; -} - -int -CZipArchive::FindFile(LPCTSTR lpszFileName, - int iCaseSensitive, - bool bFileNameOnly) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return (int)-1; - } - bool bCS; - bool bSporadically; - switch (iCaseSensitive) { - case ffCaseSens: - bCS = true; - bSporadically = true; - break; - case ffNoCaseSens: - bCS = false; - bSporadically = true; - break; - default: - bCS = m_bCaseSensitive; - bSporadically = false; - } - return m_centralDir.FindFile( - lpszFileName, bCS, bSporadically, bFileNameOnly); -} - -bool -CZipArchive::OpenFile(WORD uIndex) -{ - if (!m_centralDir.IsValidIndex(uIndex)) { - ASSERT(FALSE); - return false; - } - if (m_storage.IsSpanMode() == 1) { - TRACE(_T("%s(%i) : You cannot extract from the span in creation.\n"), - __FILE__, - __LINE__); - return false; - } - - if (m_iFileOpened) { - TRACE(_T("%s(%i) : A file already opened.\n"), __FILE__, __LINE__); - return false; - } - - m_info.Init(); - m_centralDir.OpenFile(uIndex); - if (CurrentFile()->IsEncrypted()) { - - if (m_pszPassword.GetSize() == 0) { - TRACE(_T("%s(%i) : Password not set for the encrypted file.\n"), - __FILE__, - __LINE__); - ThrowError(CZipException::badPassword); - } - CryptInitKeys(); - if (!CryptCheck()) - ThrowError(CZipException::badPassword); - } else if (m_pszPassword.GetSize() != 0) { - TRACE(_T("%s(%i) : Password set for a not encrypted file. Ignoring ") - _T("password.\n"), - __FILE__, - __LINE__); - } - - WORD uMethod = CurrentFile()->m_uMethod; - - if ((uMethod != 0) && (uMethod != Z_DEFLATED)) - ThrowError(CZipException::badZipFile); - - if (uMethod == Z_DEFLATED) { - m_info.m_stream.opaque = m_bDetectZlibMemoryLeaks ? &m_list : 0; - int err = inflateInit2(&m_info.m_stream, -MAX_WBITS); - // * windowBits is passed < 0 to tell that there is no zlib - // header. - // * Note that in this case inflate *requires* an extra "dummy" - // byte - // * after the compressed stream in order to complete - // decompression and - // * return Z_STREAM_END. - CheckForError(err); - } - m_info.m_uComprLeft = CurrentFile()->m_uComprSize; - if (CurrentFile()->IsEncrypted()) - m_info.m_uComprLeft -= ZIPARCHIVE_ENCR_HEADER_LEN; - m_info.m_uUncomprLeft = CurrentFile()->m_uUncomprSize; - m_info.m_uCrc32 = 0; - m_info.m_stream.total_out = 0; - m_info.m_stream.avail_in = 0; - - m_iFileOpened = extract; - return true; -} - -int -CZipArchive::GetLocalExtraField(char* pBuf, int iSize) const -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return -1; - } - - if (m_iFileOpened != extract) { - TRACE( - _T("%s(%i) : A file must be opened to get the local extra field.\n"), - __FILE__, - __LINE__); - return -1; - } - - int size = m_centralDir.m_pLocalExtraField.GetSize(); - if (!pBuf || !size) - return size; - - if (iSize < size) - size = iSize; - - memcpy(pBuf, m_centralDir.m_pLocalExtraField, size); - return size; -} - -void* -CZipArchive::_zliballoc(void* opaque, UINT items, UINT size) -{ - void* p = new char[size * items]; - if (opaque) { - CZipPtrList* list = (CZipPtrList*)opaque; - list->AddTail(p); - } - return p; -} - -void -CZipArchive::_zlibfree(void* opaque, void* address) -{ - if (opaque) { - CZipPtrList* list = (CZipPtrList*)opaque; - CZipPtrListIter iter = list->Find(address); - if (list->IteratorValid(iter)) - list->RemoveAt(iter); - } - delete[](char*) address; -} - -void -CZipArchive::CheckForError(int iErr) -{ - if ((iErr == Z_OK) || (iErr == Z_NEED_DICT)) - return; - - ThrowError(iErr, true); -} - -CZipFileHeader* -CZipArchive::CurrentFile() -{ - ASSERT(m_centralDir.m_pOpenedFile); - return m_centralDir.m_pOpenedFile; -} - -DWORD -CZipArchive::ReadFile(void* pBuf, DWORD iSize) -{ - if (m_iFileOpened != extract) { - TRACE( - _T("%s(%i) : Current file must be opened.\n"), __FILE__, __LINE__); - return 0; - } - - if (!pBuf || !iSize) - return 0; - - m_info.m_stream.next_out = (Bytef*)pBuf; - m_info.m_stream.avail_out = - iSize > m_info.m_uUncomprLeft ? m_info.m_uUncomprLeft : iSize; - - DWORD iRead = 0; - - // may happen when the file is 0 sized - bool bForce = m_info.m_stream.avail_out == 0 && m_info.m_uComprLeft > 0; - while (m_info.m_stream.avail_out > 0 || - (bForce && m_info.m_uComprLeft > 0)) { - if ((m_info.m_stream.avail_in == 0) && - (m_info.m_uComprLeft >= 0)) // Also when there are zero bytes left! - { - DWORD uToRead = m_info.m_pBuffer.GetSize(); - if (m_info.m_uComprLeft < uToRead) - uToRead = m_info.m_uComprLeft; - - if (uToRead == 0) { - uToRead = 1; // Add dummy byte at end of compressed data. - } else { - m_storage.Read(m_info.m_pBuffer, uToRead, false); - CryptDecodeBuffer(uToRead); - } - - m_info.m_uComprLeft -= uToRead; - - m_info.m_stream.next_in = (Bytef*)(char*)m_info.m_pBuffer; - m_info.m_stream.avail_in = uToRead; - } - - if (CurrentFile()->m_uMethod == 0) { - DWORD uToCopy = m_info.m_stream.avail_out < m_info.m_stream.avail_in - ? m_info.m_stream.avail_out - : m_info.m_stream.avail_in; - - memcpy(m_info.m_stream.next_out, m_info.m_stream.next_in, uToCopy); - - m_info.m_uCrc32 = - crc32(m_info.m_uCrc32, m_info.m_stream.next_out, uToCopy); - - m_info.m_uUncomprLeft -= uToCopy; - m_info.m_stream.avail_in -= uToCopy; - m_info.m_stream.avail_out -= uToCopy; - m_info.m_stream.next_out += uToCopy; - m_info.m_stream.next_in += uToCopy; - m_info.m_stream.total_out += uToCopy; - iRead += uToCopy; - } else { - DWORD uTotal = m_info.m_stream.total_out; - Bytef* pOldBuf = m_info.m_stream.next_out; - int err = inflate(&m_info.m_stream, Z_SYNC_FLUSH); - DWORD uToCopy = m_info.m_stream.total_out - uTotal; - - m_info.m_uCrc32 = crc32(m_info.m_uCrc32, pOldBuf, uToCopy); - - m_info.m_uUncomprLeft -= uToCopy; - iRead += uToCopy; - - if (err == Z_STREAM_END) - return iRead; - - CheckForError(err); - } - } - - return iRead; -} - -void -CZipArchive::Close(int iAfterException, bool bUpdateTimeStamp) -{ - // if after an exception - the archive may be closed, but the file may be - // opened - if (IsClosed() && (!iAfterException || IsClosed(false))) { - TRACE( - _T("%s(%i) : ZipArchive is already closed.\n"), __FILE__, __LINE__); - return; - } - - if (m_iFileOpened == extract) - CloseFile(NULL, iAfterException != afNoException); - - if (m_iFileOpened == compress) - CloseNewFile(iAfterException != afNoException); - - if (iAfterException != afAfterException && - !IsClosed(false)) // in disk spanning when user aborts - WriteCentralDirectory(false); // we will flush in CZipStorage::Close - - time_t tNewestTime = 0; - - if (bUpdateTimeStamp) { - int iSize = m_centralDir.m_headers.GetSize(); - for (int i = 0; i < iSize; i++) { - time_t tFileInZipTime = m_centralDir[i]->GetTime(); - if (tFileInZipTime > tNewestTime) - tNewestTime = tFileInZipTime; - } - } - m_centralDir.Clear(); - CZipString szFileName = - m_storage.Close(iAfterException == afAfterException); - if (bUpdateTimeStamp && !szFileName.IsEmpty()) - ZipPlatform::SetFileModTime(szFileName, tNewestTime); -} - -void -CZipArchive::WriteCentralDirectory(bool bFlush) -{ - m_centralDir.Write(GetCallback(cbSave)); - if (bFlush) - m_storage.Flush(); -} - -void -CZipArchive::SetCallback(CZipActionCallback* pCallback, int iWhich) -{ - CallbackType cbs[] = { cbAdd, cbAddTmp, cbAddStore, - cbExtract, cbDeleteCnt, cbDelete, - cbTest, cbSave, cbGetFromArchive, - cbRename, cbReplace }; - int iCount = sizeof(cbs) / sizeof(CallbackType); - for (int i = 0; i < iCount; i++) { - CallbackType iCallback = cbs[i]; - if (iWhich & iCallback) - m_callbacks.Set(pCallback, iCallback); - } -} - -void -CZipArchive::SetAdvanced(int iWriteBuffer, - int iGeneralBuffer, - int iSearchBuffer) -{ - if (!IsClosed()) { - TRACE(_T("%s(%i) : Set this options before opening the archive.\n"), - __FILE__, - __LINE__); - return; - } - - m_storage.m_iWriteBufferSize = iWriteBuffer < 1024 ? 1024 : iWriteBuffer; - m_info.m_iBufferSize = iGeneralBuffer < 1024 ? 1024 : iGeneralBuffer; - m_centralDir.m_iBufferSize = iSearchBuffer < 1024 ? 1024 : iSearchBuffer; -} - -int -CZipArchive::CloseFile(CZipFile& file) -{ - CZipString temp = file.GetFilePath(); - file.Close(); - return CloseFile(temp); -} - -int -CZipArchive::CloseFile(LPCTSTR lpszFilePath, bool bAfterException) -{ - if (m_iFileOpened != extract) { - TRACE(_T("%s(%i) : No opened file.\n"), __FILE__, __LINE__); - return false; - } - - int iRet = 1; - if (!bAfterException) { - if (m_info.m_uUncomprLeft == 0) { - if (!m_bIgnoreCRC && m_info.m_uCrc32 != CurrentFile()->m_uCrc32) - ThrowError(CZipException::badCrc); - } else - iRet = -1; - - if (CurrentFile()->m_uMethod == Z_DEFLATED) - inflateEnd(&m_info.m_stream); - - if (lpszFilePath) { - - if (!ZipPlatform::SetFileModTime(lpszFilePath, - CurrentFile()->GetTime()) || - !ZipPlatform::SetFileAttr(lpszFilePath, - CurrentFile()->GetSystemAttr())) - iRet = -2; - } - } - - m_centralDir.CloseFile(bAfterException); - - m_iFileOpened = nothing; - m_info.ReleaseBuf(); - EmptyPtrList(); - return iRet; -} - -bool -CZipArchive::OpenNewFile(CZipFileHeader& header, - int iLevel, - LPCTSTR lpszFilePath, - DWORD uInternal) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return false; - } - - if (m_iFileOpened) { - TRACE(_T("%s(%i) : A file already opened.\n"), __FILE__, __LINE__); - return false; - } - - if (m_storage.IsSpanMode() == -1) { - TRACE(_T("%s(%i) : You cannot add files to the existing disk spannig ") - _T("archive.\n"), - __FILE__, - __LINE__); - return false; - } - - if (GetCount() == (WORD)USHRT_MAX) { - TRACE(_T("%s(%i) : Maximum file count inside archive reached.\n"), - __FILE__, - __LINE__); - return false; - } - - DWORD uAttr = 0; // ..compiler - time_t ttime; - if (lpszFilePath) { - - if (!ZipPlatform::GetFileAttr(lpszFilePath, uAttr)) - // do not continue - if the file was a directory then not - // recognizing it will cause serious errors (need uAttr to recognize - // it) - return false; - if (!ZipPlatform::GetFileModTime(lpszFilePath, ttime)) - ttime = time(NULL); - } - - m_info.Init(); - - if (lpszFilePath) { - header.SetTime(ttime); - SetFileHeaderAttr(header, uAttr); // set system compatibility as well - } else - header.SetSystemCompatibility(m_iArchiveSystCompatib); - - CZipString szFileName = header.GetFileName(); - - bool bIsDirectory = header.IsDirectory(); - if (bIsDirectory) { - int iNameLen = szFileName.GetLength(); - if (!iNameLen || - !CZipPathComponent::IsSeparator(szFileName[iNameLen - 1])) { - szFileName += CZipPathComponent::m_cSeparator; - header.SetFileName(szFileName); - } - } - - if (szFileName.IsEmpty()) { - szFileName.Format(_T("file%i"), GetCount()); - header.SetFileName(szFileName); - } - - // make sure that all slashes are correct (as the current system default) - // because AddNewFile calls InsertFindFastElement if necessary and - // the find array keeps all the files already converted to the current - // system standards we do not perform Oem->Ansi here, because who would pass - // oem values here? - // - ZipCompatibility::SlashBackslashChg(header.m_pszFileName, true); - - bool bEncrypted = m_pszPassword.GetSize() != 0; - -#ifdef _DEBUG - if (bIsDirectory && bEncrypted) - TRACE(_T("%s(%i) : Encrypting a directory. It's pointless.\n\ - Clear the password before adding a directory.\n"), - __FILE__, - __LINE__); -#endif - - int iReplaceIndex = -1; - bool bReplace = (iLevel & 0xffff) == ZIP_COMPR_REPL_SIGN; - if (bReplace) { - int iMask = ZIP_COMPR_REPL_MASK; - iReplaceIndex = (iLevel & iMask) >> 16; - iLevel = (char)(iLevel & ~iMask); - ASSERT(iLevel == 0); - } else - uInternal = 0; - - if (iLevel < -1 || iLevel > 9) - iLevel = -1; - - if (!header.PrepareData(iLevel, m_storage.IsSpanMode() == 1, bEncrypted)) - ThrowError(CZipException::tooLongFileName); - - if (bReplace) { - uInternal += header.GetSize(true); - if (header.IsEncrypted()) - uInternal += ZIPARCHIVE_ENCR_HEADER_LEN; - if (header.IsDataDescr()) - uInternal += - ZIPARCHIVE_DATADESCRIPTOR_LEN + 4; // CZipCentralDir::CloseNewFile - } - m_centralDir.AddNewFile(header, iReplaceIndex); - if (bReplace) - MakeSpaceForReplace(iReplaceIndex, uInternal, szFileName); - - // this ensures the conversion will take place anyway (must take because we - // are going to write the local header in a moment - m_centralDir.ConvertFileName(false, m_centralDir.m_bConvertAfterOpen); - - CurrentFile()->WriteLocal(m_storage); - - // we have written the local header, but if we keep filenames not converted - // in memory , we have to restore the non-converted value - if (m_centralDir.m_bConvertAfterOpen) - CurrentFile()->SetFileName(szFileName); - - if (bEncrypted) { - CZipAutoBuffer buf(ZIPARCHIVE_ENCR_HEADER_LEN); - // use pseudo-crc since we don't know it yet - CryptCryptHeader((long)header.m_uModTime << 16, buf); - m_storage.Write(buf, ZIPARCHIVE_ENCR_HEADER_LEN, false); - } - - m_info.m_uComprLeft = 0; - m_info.m_stream.avail_in = (uInt)0; - m_info.m_stream.avail_out = (uInt)m_info.m_pBuffer.GetSize(); - m_info.m_stream.next_out = (Bytef*)(char*)m_info.m_pBuffer; - m_info.m_stream.total_in = 0; - m_info.m_stream.total_out = 0; - - if (bIsDirectory && (CurrentFile()->m_uMethod != 0)) - CurrentFile()->m_uMethod = 0; - - if (CurrentFile()->m_uMethod == Z_DEFLATED) { - m_info.m_stream.opaque = m_bDetectZlibMemoryLeaks ? &m_list : 0; - - int err = deflateInit2(&m_info.m_stream, - iLevel, - Z_DEFLATED, - -MAX_WBITS, - DEF_MEM_LEVEL, - Z_DEFAULT_STRATEGY); - - CheckForError(err); - } - m_iFileOpened = compress; - return true; -} - -bool -CZipArchive::ExtractFile(WORD uIndex, - LPCTSTR lpszPath, - bool bFullPath, - LPCTSTR lpszNewName, - DWORD nBufSize) -{ - - if (!nBufSize && !lpszPath) - return false; - - CZipFileHeader header; - GetFileInfo(header, - uIndex); // to ensure that slash and oem conversions take place - CZipString szFileNameInZip = (LPCTSTR)header.GetFileName(); - CZipString szFile = PredictExtractedFileName( - szFileNameInZip, lpszPath, bFullPath, lpszNewName); - CZipActionCallback* pCallback = GetCallback(cbExtract); - if (pCallback) - pCallback->Init(szFileNameInZip, szFile); - - if (header.IsDirectory()) { - if (pCallback) - pCallback->SetTotal(0); // in case of calling LeftToDo afterwards - - ZipPlatform::ForceDirectory(szFile); - ZipPlatform::SetFileAttr(szFile, header.GetSystemAttr()); - - if (pCallback) - pCallback->CallbackEnd(); - return true; - } else { - if (pCallback) - pCallback->SetTotal(header.m_uUncomprSize); - - if (!OpenFile(uIndex)) - return false; - - CZipPathComponent zpc(szFile); - ZipPlatform::ForceDirectory(zpc.GetFilePath()); - CZipFile f(szFile, - CZipFile::modeWrite | CZipFile::modeCreate | - CZipFile::shareDenyWrite); - DWORD iRead; - CZipAutoBuffer buf(nBufSize); - int iAborted = 0; - do { - iRead = ReadFile(buf, buf.GetSize()); - if (iRead) { - f.Write(buf, iRead); - if (pCallback) - if (!(*pCallback)(iRead)) { - if (iRead == buf.GetSize() && - ReadFile(buf, 1) != - 0) // test one byte if there is something left - iAborted = CZipException::abortedAction; - else - iAborted = - CZipException::abortedSafely; // we did it! - break; - } - } - } while (iRead == buf.GetSize()); - bool bRet = CloseFile(f) == 1; - if (!bRet && iAborted == CZipException::abortedSafely) - iAborted = CZipException::abortedAction; // sorry, finished, but not - // successfull - - if (pCallback) - pCallback->CallbackEnd(); - - if (iAborted) - CZipException::Throw( - iAborted, - szFile); // throw to distuingiush from other return codes - return bRet; - } -} - -bool -CZipArchive::ExtractFile(WORD uIndex, CZipMemFile& mf, DWORD nBufSize) -{ - if (!nBufSize) - return false; - - CZipFileHeader header; - GetFileInfo(header, - uIndex); // to ensure that slash and oem conversions take place - CZipActionCallback* pCallback = GetCallback(cbExtract); - if (pCallback) { - pCallback->Init(header.GetFileName()); - pCallback->SetTotal(header.m_uUncomprSize); - } - - if (header.IsDirectory() || !OpenFile(uIndex)) - return false; - - CZipAutoBuffer buf(nBufSize); - mf.SeekToEnd(); - DWORD iRead; - int iAborted = 0; - do { - iRead = ReadFile(buf, buf.GetSize()); - if (iRead) { - mf.Write(buf, iRead); - if (pCallback) - if (!(*pCallback)(iRead)) { - if (iRead == buf.GetSize() && - ReadFile(buf, 1) != - 0) // test one byte if there is something left - iAborted = CZipException::abortedAction; - else - iAborted = CZipException::abortedSafely; // we did it! - break; - } - } - } while (iRead == buf.GetSize()); - bool bRet = CloseFile() == 1; - if (!bRet && iAborted == CZipException::abortedSafely) - iAborted = - CZipException::abortedAction; // sorry, finished, but not successfull - - if (pCallback) - pCallback->CallbackEnd(); - - if (iAborted) - CZipException::Throw( - iAborted); // throw to distuingiush from other return codes - return bRet; -} - -void -CZipArchive::SetExtraField(const char* pBuf, WORD iSize) -{ - if (m_iFileOpened != compress) { - TRACE(_T("%s(%i) : A new file must be opened.\n"), __FILE__, __LINE__); - return; - } - if (!pBuf || !iSize) - return; - - CurrentFile()->m_pExtraField.Allocate(iSize); - memcpy(CurrentFile()->m_pExtraField, pBuf, iSize); -} - -bool -CZipArchive::WriteNewFile(const void* pBuf, DWORD iSize) -{ - if (m_iFileOpened != compress) { - TRACE(_T("%s(%i) : A new file must be opened.\n"), __FILE__, __LINE__); - return false; - } - - m_info.m_stream.next_in = (Bytef*)pBuf; - m_info.m_stream.avail_in = iSize; - CurrentFile()->m_uCrc32 = - crc32(CurrentFile()->m_uCrc32, (Bytef*)pBuf, iSize); - - while (m_info.m_stream.avail_in > 0) { - if (m_info.m_stream.avail_out == 0) { - CryptEncodeBuffer(); - m_storage.Write(m_info.m_pBuffer, m_info.m_uComprLeft, false); - m_info.m_uComprLeft = 0; - m_info.m_stream.avail_out = m_info.m_pBuffer.GetSize(); - m_info.m_stream.next_out = (Bytef*)(char*)m_info.m_pBuffer; - } - - if (CurrentFile()->m_uMethod == Z_DEFLATED) { - DWORD uTotal = m_info.m_stream.total_out; - int err = deflate(&m_info.m_stream, Z_NO_FLUSH); - CheckForError(err); - m_info.m_uComprLeft += m_info.m_stream.total_out - uTotal; - } else { - DWORD uToCopy = - (m_info.m_stream.avail_in < m_info.m_stream.avail_out) - ? m_info.m_stream.avail_in - : m_info.m_stream.avail_out; - - memcpy(m_info.m_stream.next_out, m_info.m_stream.next_in, uToCopy); - - m_info.m_stream.avail_in -= uToCopy; - m_info.m_stream.avail_out -= uToCopy; - m_info.m_stream.next_in += uToCopy; - m_info.m_stream.next_out += uToCopy; - m_info.m_stream.total_in += uToCopy; - m_info.m_stream.total_out += uToCopy; - m_info.m_uComprLeft += uToCopy; - } - } - - return true; -} - -bool -CZipArchive::CloseNewFile(bool bAfterException) -{ - if (m_iFileOpened != compress) { - TRACE(_T("%s(%i) : A new file must be opened.\n"), __FILE__, __LINE__); - return false; - } - - m_info.m_stream.avail_in = 0; - if (!bAfterException) { - int err = Z_OK; - if (CurrentFile()->m_uMethod == Z_DEFLATED) - while (err == Z_OK) { - if (m_info.m_stream.avail_out == 0) { - CryptEncodeBuffer(); - m_storage.Write( - m_info.m_pBuffer, m_info.m_uComprLeft, false); - m_info.m_uComprLeft = 0; - m_info.m_stream.avail_out = m_info.m_pBuffer.GetSize(); - m_info.m_stream.next_out = (Bytef*)(char*)m_info.m_pBuffer; - } - DWORD uTotal = m_info.m_stream.total_out; - err = deflate(&m_info.m_stream, Z_FINISH); - m_info.m_uComprLeft += m_info.m_stream.total_out - uTotal; - } - - if (err == Z_STREAM_END) - err = Z_OK; - CheckForError(err); - - if (m_info.m_uComprLeft > 0) { - CryptEncodeBuffer(); - m_storage.Write(m_info.m_pBuffer, m_info.m_uComprLeft, false); - } - - if (CurrentFile()->m_uMethod == Z_DEFLATED) { - err = deflateEnd(&m_info.m_stream); - CheckForError(err); - } - - // it may be increased by the encrypted header size - CurrentFile()->m_uComprSize += m_info.m_stream.total_out; - CurrentFile()->m_uUncomprSize = m_info.m_stream.total_in; - - m_centralDir.CloseNewFile(); - } else - m_centralDir.m_pOpenedFile = NULL; - - m_iFileOpened = nothing; - m_info.ReleaseBuf(); - EmptyPtrList(); - - if (m_bAutoFlush && !bAfterException) - Flush(); - - return true; -} - -void -CZipArchive::DeleteFile(WORD uIndex) -{ - CZipWordArray indexes; - indexes.Add(uIndex); - DeleteFiles(indexes); -} - -void -CZipArchive::GetIndexes(const CZipStringArray& aNames, CZipWordArray& aIndexes) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return; - } - int iSize = aNames.GetSize(); - for (WORD i = 0; i < iSize; i++) { - int idx = FindFile(aNames[i], ffDefault, false); - if (idx != -1) - aIndexes.Add((WORD)idx); - } -} - -void -CZipArchive::DeleteFiles(const CZipStringArray& aNames) -{ - CZipWordArray indexes; - GetIndexes(aNames, indexes); - DeleteFiles(indexes); -} - -void -CZipArchive::DeleteFiles(CZipWordArray& aIndexes) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return; - } - - if (m_storage.IsSpanMode()) { - TRACE(_T("%s(%i) : You cannot delete files from the disk spannig ") - _T("archive.\n"), - __FILE__, - __LINE__); - return; - } - - if (m_iFileOpened) { - TRACE( - _T("%s(%i) : You cannot delete files if there is a file opened.\n"), - __FILE__, - __LINE__); - return; - } - - CZipActionCallback* pCallback = GetCallback(cbDeleteCnt); - if (pCallback) - pCallback->Init(); - - int uSize = aIndexes.GetSize(); - if (!uSize) { - TRACE( - _T("%s(%i) : The indekses array is empty.\n"), __FILE__, __LINE__); - return; - } - - // remove all - that's easy so don't waste the time - if (uSize == GetCount()) { - pCallback = GetCallback(cbDelete); - if (pCallback) { - // do it right and sent the notification - pCallback->Init(); - pCallback->SetTotal(uSize); - } - - m_centralDir.RemoveFromDisk(); - m_storage.m_pFile->SetLength(m_centralDir.GetBytesBefore()); - m_centralDir.RemoveAll(); - if (m_bAutoFlush) - Flush(); - if (pCallback) - pCallback->CallbackEnd(); - return; - } - - aIndexes.Sort(true); - - CZipArray aInfo; - - int iDelIndex = 0; - - int iStep = 0; // for the compiler - if (pCallback) { - pCallback->SetTotal(GetCount()); - iStep = CZipActionCallback::m_iStep; // we don't want to wait forever - } - - int i; - int uMaxDelIndex = aIndexes[uSize - 1]; - for (i = aIndexes[0]; i < GetCount(); i++) { - CZipFileHeader* pHeader = m_centralDir[i]; - bool bDelete; - if (i <= uMaxDelIndex && i == aIndexes[iDelIndex]) { - iDelIndex++; - bDelete = true; - } else - bDelete = false; - aInfo.Add(CZipDeleteInfo(pHeader, bDelete)); - if (pCallback && (!(i % iStep))) - if (!(*pCallback)(iStep)) - ThrowError(CZipException::abortedSafely); - } - ASSERT(iDelIndex == uSize); - - uSize = aInfo.GetSize(); - if (!uSize) // it is possible - return; - - // now we start deleting (not safe to break) - pCallback = GetCallback(cbDelete); - if (pCallback) - pCallback->Init(); - - m_centralDir.RemoveFromDisk(); - - DWORD uTotalToMoveBytes = 0, uLastOffset = m_storage.m_pFile->GetLength() - - m_centralDir.GetBytesBefore(); - // count the number of bytes to move - for (i = uSize - 1; i >= 0; i--) { - const CZipDeleteInfo& di = aInfo[i]; - if (!di.m_bDelete) - uTotalToMoveBytes += uLastOffset - di.m_pHeader->m_uOffset; - uLastOffset = di.m_pHeader->m_uOffset; - } - if (pCallback) - pCallback->CallbackEnd(); - - if (pCallback) - pCallback->SetTotal(uTotalToMoveBytes); - - m_info.Init(); - - DWORD uMoveBy = 0, uOffsetStart = 0; - for (i = 0; i < uSize; i++) { - const CZipDeleteInfo& di = aInfo[i]; - - if (di.m_bDelete) { - // next hole - DWORD uTemp = di.m_pHeader->m_uOffset; - m_centralDir.RemoveFile(di.m_pHeader); // first remove - if (uOffsetStart) { - // copy the files over a previous holes - MovePackedFiles(uOffsetStart, uTemp, uMoveBy, pCallback); - uOffsetStart = 0; // never be at the beginning, because the - // first file is always to be deleted - } - if (i == uSize - 1) - uTemp = (m_storage.m_pFile->GetLength() - - m_centralDir.GetBytesBefore()) - - uTemp; - else - uTemp = aInfo[i + 1].m_pHeader->m_uOffset - uTemp; - - uMoveBy += uTemp; - } else { - if (uOffsetStart == 0) // find contiuos area to move - uOffsetStart = di.m_pHeader->m_uOffset; - di.m_pHeader->m_uOffset -= uMoveBy; - } - } - if (uOffsetStart) - MovePackedFiles(uOffsetStart, - m_storage.m_pFile->GetLength() - - m_centralDir.GetBytesBefore(), - uMoveBy, - pCallback); - - m_info.ReleaseBuf(); - if (uMoveBy) // just in case - m_storage.m_pFile->SetLength(m_storage.m_pFile->GetLength() - uMoveBy); - - if (pCallback) - pCallback->CallbackEnd(); - - if (m_bAutoFlush) - Flush(); -} - -bool -CZipArchive::AddNewFile(LPCTSTR lpszFilePath, - int iComprLevel, - bool bFullPath, - int iSmartLevel, - unsigned long nBufSize) -{ - - CZipAddNewFileInfo zanfi(lpszFilePath, bFullPath); - zanfi.m_iComprLevel = iComprLevel; - zanfi.m_iSmartLevel = zipsmSafeSmart; - zanfi.m_nBufSize = nBufSize; - return AddNewFile(zanfi); -} - -bool -CZipArchive::AddNewFile(LPCTSTR lpszFilePath, - LPCTSTR lpszFileNameInZip, - int iComprLevel, - int iSmartLevel, - unsigned long nBufSize) -{ - CZipAddNewFileInfo zanfi(lpszFilePath, lpszFileNameInZip); - zanfi.m_iComprLevel = iComprLevel; - zanfi.m_iSmartLevel = zipsmSafeSmart; - zanfi.m_nBufSize = nBufSize; - return AddNewFile(zanfi); -} - -bool -CZipArchive::AddNewFile(CZipMemFile& mf, - LPCTSTR lpszFileNameInZip, - int iComprLevel, - int iSmartLevel, - unsigned long nBufSize) -{ - CZipAddNewFileInfo zanfi(&mf, lpszFileNameInZip); - zanfi.m_iComprLevel = iComprLevel; - zanfi.m_iSmartLevel = zipsmSafeSmart; - zanfi.m_nBufSize = nBufSize; - return AddNewFile(zanfi); -} - -bool -CZipArchive::AddNewFile(CZipAddNewFileInfo& info) -{ - // no need for ASSERT and TRACE here - it will be done by OpenNewFile - - if (!m_info.m_iBufferSize) - return false; - CZipPathComponent::RemoveSeparators(info.m_szFilePath); - if (!info.m_szFilePath.IsEmpty()) // it may be empty after removing sep. - { - if (info.m_szFileNameInZip.IsEmpty()) { - CZipPathComponent zpc(info.m_szFilePath); - if (info.m_bFullPath) { - if (m_bRemoveDriveLetter) - info.m_szFileNameInZip = zpc.GetNoDrive(); - } else - info.m_szFileNameInZip = TrimRootPath(zpc); - } - } else if (!info.m_pFile) - return false; - - bool bSpan = GetSpanMode() != 0; - - // checking the iReplace index - if (!UpdateReplaceIndex(info.m_iReplaceIndex, info.m_szFileNameInZip)) - return false; - - bool bReplace = info.m_iReplaceIndex >= 0; - - DWORD uAttr; - time_t ttime; - if (info.m_pFile) { - uAttr = ZipPlatform::GetDefaultAttributes(); - ttime = time(NULL); - } else { - if (!ZipPlatform::GetFileAttr(info.m_szFilePath, uAttr)) - return false; // we don't know whether it is a file or a directory - if (!ZipPlatform::GetFileModTime(info.m_szFilePath, ttime)) - ttime = time(NULL); - } - CZipFileHeader header; - header.SetFileName(info.m_szFileNameInZip); - if (ZipPlatform::GetSystemID() != ZipCompatibility::zcUnix) - uAttr |= ZipCompatibility::ConvertToSystem( - uAttr, - ZipPlatform::GetSystemID(), - ZipCompatibility::zcUnix); // make it readable under Unix as well, - // since it stores its attributes in - // HIWORD(uAttr) - SetFileHeaderAttr(header, uAttr); - header.SetTime(ttime); - bool bInternal = (info.m_iSmartLevel & zipsmInternal01) != 0; - CZipActionCallback* pCallback = NULL; - if (!bInternal) { - pCallback = GetCallback(cbAdd); - if (pCallback) - pCallback->Init(info.m_szFileNameInZip, info.m_szFilePath); - } - - if (header.IsDirectory()) // will never be when m_pFile is not NULL, so we - // don't check it - { - ASSERT(!info.m_pFile); // should never happened - ASSERT(!bInternal); - - if (pCallback) - pCallback->SetTotal(0); // in case of calling LeftToDo afterwards - - // clear password for a directory - bool bRet = false; - CZipSmClrPass smcp; - if (info.m_iSmartLevel & zipsmCPassDir) - smcp.ClearPasswordSmartly(this); - - bRet = OpenNewFile( - header, - bReplace ? (info.m_iReplaceIndex << 16) | ZIP_COMPR_REPL_SIGN : 0); - - CloseNewFile(); - if (pCallback) - pCallback->CallbackEnd(); - - return bRet; - } - - CZipSmClrPass smcp; - bool bIsCompression = info.m_iComprLevel != 0; - bool bEff = (info.m_iSmartLevel & zipsmCheckForEff) && bIsCompression; - bool bCheckForZeroSized = - (info.m_iSmartLevel & zipsmCPFile0) && !GetPassword().IsEmpty(); - bool bCheckForSmallFiles = - (info.m_iSmartLevel & zipsmNotCompSmall) && bIsCompression; - DWORD iFileSize = DWORD(-1); - bool bNeedTempArchive = (bEff && bSpan) || (bReplace && bIsCompression); - if (bCheckForSmallFiles || bCheckForZeroSized || bNeedTempArchive) { - - if (info.m_pFile) - iFileSize = info.m_pFile->GetLength(); - else { - if (!ZipPlatform::GetFileSize(info.m_szFilePath, iFileSize) && bEff) - bEff = - false; // the file size is needed only when eff. in span mode - } - if (iFileSize != DWORD(-1)) { - if (bCheckForZeroSized && iFileSize == 0) - smcp.ClearPasswordSmartly(this); - if (bCheckForSmallFiles && iFileSize < 5) - info.m_iComprLevel = 0; - } - } - bool bEffInMem = bEff && (info.m_iSmartLevel & zipsmMemoryFlag); - CZipString szTempFileName; - if (bNeedTempArchive && - (bEffInMem || - !(szTempFileName = ZipPlatform::GetTmpFileName( - m_szTempPath.IsEmpty() ? NULL : (LPCTSTR)m_szTempPath, iFileSize)) - .IsEmpty())) { - CZipMemFile* pmf = NULL; - CZipArchive zip; - try { - // compress first to a temporary file, if ok - copy the data, if not - // - add storing - - if (bEffInMem) { - pmf = new CZipMemFile; - zip.Open(*pmf, zipCreate); - } else - zip.Open(szTempFileName, zipCreate); - zip.SetRootPath(m_szRootPath); - zip.SetPassword(GetPassword()); - zip.SetSystemCompatibility(m_iArchiveSystCompatib); - zip.SetCallback(pCallback, cbAdd); - // create a temporary file - int iTempReplaceIndex = info.m_iReplaceIndex; - info.m_iSmartLevel = zipsmLazy; - info.m_iReplaceIndex = -1; - if (!zip.AddNewFile(info)) - throw false; - info.m_iReplaceIndex = iTempReplaceIndex; - - // this may also happen when bReplace, but not in span mode - if (bEff) { - CZipFileHeader fh; - zip.GetFileInfo(fh, 0); - if (!fh.CompressionEfficient()) { - info.m_iComprLevel = 0; - info.m_iSmartLevel = zipsmInternal01; - // compression is pointless, store instead - throw AddNewFile(info); - } - } - - m_info.Init(); - throw GetFromArchive( - zip, 0, info.m_iReplaceIndex, true, GetCallback(cbAddTmp)); - } catch (bool bRet) { - - zip.Close( - !bRet); // that doesn't really matter how it will be closed - if (pmf) - delete pmf; - if (!bEffInMem) - ZipPlatform::RemoveFile(szTempFileName, false); - m_info.ReleaseBuf(); - return bRet; - } catch (...) { - zip.Close(true); - if (pmf) - delete pmf; - if (!bEffInMem) - ZipPlatform::RemoveFile(szTempFileName, false); - m_info.ReleaseBuf(); - throw; - } - } - - // try to open before adding - CZipFile f; - CZipAbstractFile* pf; - if (info.m_pFile) - pf = info.m_pFile; - else { - // cannot be shareDenyWrite - // from - // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/creating_and_opening_files.asp - // : If you specify the GENERIC_READ and GENERIC_WRITE access modes - // along with the FILE_SHARE_READ and FILE_SHARE_WRITE sharing modes in - // your first call to CreateFile. If you specify the GENERIC_READ and - // GENERIC_WRITE access modes and the FILE_SHARE_READ sharing mode only - // in your second call to CreateFile, the function will fail with a - // sharing violation because the read-only sharing mode specified in the - // second call conflicts with the read/write access that has been - // granted in the first call. - if (!f.Open(info.m_szFilePath, - CZipFile::modeRead | CZipFile::shareDenyNone, - false)) { - if (pCallback) - pCallback->CallbackEnd(); - return false; - } - pf = &f; - } - - ASSERT(pf); - // call init before opening (in case of exception we have the names) - iFileSize = pf->GetLength(); - - bool bRet; - if (bReplace) { - ASSERT(!bIsCompression); - bRet = OpenNewFile(header, - (info.m_iReplaceIndex << 16) | ZIP_COMPR_REPL_SIGN, - NULL, - iFileSize); - } else - bRet = OpenNewFile(header, info.m_iComprLevel); - if (!bRet) { - if (pCallback) - pCallback->CallbackEnd(); - - return false; - } - if (bInternal) { - // we do it here, because if in OpenNewFile is replacing - // then we get called cbReplace callback before and it would - // overwrite callback information written in pCallback->Init - pCallback = GetCallback(cbAddStore); - if (pCallback) - pCallback->Init(info.m_szFileNameInZip, info.m_szFilePath); - } - if (pCallback) - pCallback->SetTotal(iFileSize); - - CZipAutoBuffer buf(info.m_nBufSize); - DWORD iRead; - int iAborted = 0; - do { - iRead = pf->Read(buf, info.m_nBufSize); - if (iRead) { - WriteNewFile(buf, iRead); - if (pCallback) - if (!(*pCallback)(iRead)) { - // todo: we could remove here the bytes of the file - // partially added if not disk-spanning - if (iRead == buf.GetSize() && - pf->Read(buf, 1) != - 0) // test one byte if there is something left - { - if (!m_storage.IsSpanMode() && !bReplace) { - RemoveLast(true); - CloseNewFile(true); - iAborted = CZipException::abortedSafely; - } else - iAborted = CZipException::abortedAction; - } else { - iAborted = CZipException::abortedSafely; // we did it! - CloseNewFile(); - } - break; - } - } - - } while (iRead == buf.GetSize()); - if (!iAborted) - CloseNewFile(); - - if (pCallback) - pCallback->CallbackEnd(); - - if (iAborted) - CZipException::Throw( - iAborted); // throw to distuinguish from other return codes - - if (bEff) { - // remove the last file and add it without the compression if needed - if (!info.m_pFile) - f.Close(); - - buf.Release(); - if (RemoveLast()) { - info.m_iComprLevel = 0; - info.m_iSmartLevel = zipsmInternal01; - return AddNewFile(info); - } - } - return true; -} - -bool -CZipArchive::RemoveLast(bool bRemoveAnyway) -{ - int iIndex = GetCount() - 1; - if (iIndex < 0) - return false; - CZipFileHeader* pHeader = m_centralDir[iIndex]; - - if (!bRemoveAnyway && pHeader->CompressionEfficient()) - return false; - - m_centralDir.RemoveLastFile(pHeader, iIndex); - return true; -} - -CZipString -CZipArchive::GetArchivePath() const -{ - if (IsClosed(false)) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return _T(""); - } - return m_storage.m_pFile->GetFilePath(); -} - -CZipString -CZipArchive::GetGlobalComment() const -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return _T(""); - } - CZipString temp; - return SingleToWide(m_centralDir.m_pszComment, temp) != -1 ? (LPCTSTR)temp - : _T(""); -} - -bool -CZipArchive::SetGlobalComment(LPCTSTR lpszComment) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return false; - } - if (m_storage.IsSpanMode() == -1) { - TRACE(_T("%s(%i) : You cannot modify the global comment of the ") - _T("existing disk spanning archive.\n"), - __FILE__, - __LINE__); - return false; - } - - WideToSingle(lpszComment, m_centralDir.m_pszComment); - m_centralDir.RemoveFromDisk(); - if (m_bAutoFlush) - Flush(); - - return true; -} - -int -CZipArchive::GetCurrentDisk() const -{ - return m_storage.GetCurrentDisk() + 1; -} - -bool -CZipArchive::SetFileComment(WORD uIndex, LPCTSTR lpszComment) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return false; - } - if (m_storage.IsSpanMode() == -1) { - TRACE(_T("%s(%i) : You cannot modify the file comment in the existing ") - _T("disk spanning archive.\n"), - __FILE__, - __LINE__); - return false; - } - - if (!m_centralDir.IsValidIndex(uIndex)) { - ASSERT(FALSE); - return false; - } - m_centralDir[uIndex]->SetComment(lpszComment); - m_centralDir.RemoveFromDisk(); - if (m_bAutoFlush) - Flush(); - return true; -} - -void -CZipArchive::CryptInitKeys() -{ - ASSERT(m_pszPassword.GetSize()); - m_keys[0] = 305419896L; - m_keys[1] = 591751049L; - m_keys[2] = 878082192L; - for (DWORD i = 0; i < m_pszPassword.GetSize(); i++) - CryptUpdateKeys(m_pszPassword[i]); -} - -void -CZipArchive::CryptUpdateKeys(char c) -{ - - m_keys[0] = CryptCRC32(m_keys[0], c); - m_keys[1] += m_keys[0] & 0xff; - m_keys[1] = m_keys[1] * 134775813L + 1; - c = char(m_keys[1] >> 24); - m_keys[2] = CryptCRC32(m_keys[2], c); -} - -bool -CZipArchive::CryptCheck() -{ - CZipAutoBuffer buf(ZIPARCHIVE_ENCR_HEADER_LEN); - m_storage.Read(buf, ZIPARCHIVE_ENCR_HEADER_LEN, false); - BYTE b = 0; - for (int i = 0; i < ZIPARCHIVE_ENCR_HEADER_LEN; i++) { - b = buf[i]; // only temporary - CryptDecode((char&)b); - } - // check the last byte - return CurrentFile()->IsDataDescr() - ? (BYTE(CurrentFile()->m_uModTime >> 8) == b) - : (BYTE(CurrentFile()->m_uCrc32 >> 24) == b); -} - -char -CZipArchive::CryptDecryptByte() -{ - int temp = (m_keys[2] & 0xffff) | 2; - return (char)(((temp * (temp ^ 1)) >> 8) & 0xff); -} - -void -CZipArchive::CryptDecode(char& c) -{ - c ^= CryptDecryptByte(); - CryptUpdateKeys(c); -} - -bool -CZipArchive::SetPassword(LPCTSTR lpszPassword) -{ - if (m_iFileOpened != nothing) { - TRACE(_T("%s(%i) : You cannot change the password when the file is ") - _T("opened.\n"), - __FILE__, - __LINE__); - return false; // it's important not to change the password when the file - // inside archive is opened - } - if (IsClosed()) { - TRACE(_T("%s(%i) : Setting the password for a closed archive has no ") - _T("effect.\n"), - __FILE__, - __LINE__); - } - if (lpszPassword) { - int iLen = WideToSingle(lpszPassword, m_pszPassword); - if (iLen == -1) - return false; - for (size_t i = 0; (int)i < iLen; i++) - if (m_pszPassword[i] <= 0) { - m_pszPassword.Release(); - TRACE(_T("%s(%i) : The password contains forbidden ") - _T("characters. Password cleared.\n"), - __FILE__, - __LINE__); - return false; - } - } else - m_pszPassword.Release(); - return true; -} - -CZipString -CZipArchive::GetPassword() const -{ - CZipString temp; - CZipArchive::SingleToWide(m_pszPassword, temp); - return temp; -} - -DWORD -CZipArchive::CryptCRC32(DWORD l, char c) -{ - const DWORD* CRC_TABLE = get_crc_table(); - return CRC_TABLE[(l ^ c) & 0xff] ^ (l >> 8); -} - -void -CZipArchive::CryptCryptHeader(long iCrc, CZipAutoBuffer& buf) -{ - CryptInitKeys(); - srand(UINT(time(NULL))); - // genereate pseudo-random sequence - char c; - for (int i = 0; i < ZIPARCHIVE_ENCR_HEADER_LEN - 2; i++) { - int t1 = rand(); - c = (char)(t1 >> 6); - if (!c) - c = (char)t1; - CryptEncode(c); - buf[i] = c; - } - c = (char)((iCrc >> 16) & 0xff); - CryptEncode(c); - buf[ZIPARCHIVE_ENCR_HEADER_LEN - 2] = c; - c = (char)((iCrc >> 24) & 0xff); - CryptEncode(c); - buf[ZIPARCHIVE_ENCR_HEADER_LEN - 1] = c; -} - -void -CZipArchive::CryptEncode(char& c) -{ - char t = CryptDecryptByte(); - CryptUpdateKeys(c); - c ^= t; -} - -void -CZipArchive::CryptEncodeBuffer() -{ - if (CurrentFile()->IsEncrypted()) - for (DWORD i = 0; i < m_info.m_uComprLeft; i++) - CryptEncode(m_info.m_pBuffer[i]); -} - -void -CZipArchive::CloseFileAfterTestFailed() -{ - if (m_iFileOpened != extract) { - TRACE(_T("%s(%i) : No file opened.\n"), __FILE__, __LINE__); - return; - } - m_info.ReleaseBuf(); - m_centralDir.Clear(false); - m_iFileOpened = nothing; -} - -bool -CZipArchive::TestFile(WORD uIndex, DWORD uBufSize) -{ - if (m_storage.IsSpanMode() == 1) { - TRACE( - _T("%s(%i) : You cannot test the spanning archive in creation.\n"), - __FILE__, - __LINE__); - return false; - } - if (!uBufSize) - return false; - - CZipFileHeader* pHeader = m_centralDir[uIndex]; - CZipActionCallback* pCallback = GetCallback(cbTest); - if (pCallback) { - pCallback->Init(m_centralDir.GetProperHeaderFileName(pHeader)); - } - - if (pHeader->IsDirectory()) { - if (pCallback) - pCallback->SetTotal(0); - - // we do not test whether the password for the encrypted directory - // is correct, since it seems to be senseless (anyway password - // encrypted directories should be avoided - it adds 12 bytes) - DWORD iSize = pHeader->m_uComprSize; - if ((iSize != 0 || iSize != pHeader->m_uUncomprSize) - // different treating compressed directories - && !(pHeader->IsEncrypted() && iSize == 12 && - !pHeader->m_uUncomprSize)) - CZipException::Throw(CZipException::dirWithSize); - - if (pCallback) - pCallback->CallbackEnd(); - - return true; - } else { - try { - if (pCallback) - pCallback->SetTotal(pHeader->m_uUncomprSize); - - if (!OpenFile(uIndex)) - return false; - CZipAutoBuffer buf(uBufSize); - DWORD iRead; - int iAborted = 0; - do { - iRead = ReadFile(buf, buf.GetSize()); - if (pCallback && iRead) - if (!(*pCallback)(iRead)) { - if (iRead == buf.GetSize() && - ReadFile(buf, 1) != - 0) // test one byte if there is something left - iAborted = CZipException::abortedAction; - else - iAborted = - CZipException::abortedSafely; // we did it! - break; - } - } while (iRead == buf.GetSize()); - bool bRet = CloseFile() != -1; - if (!bRet && iAborted == CZipException::abortedSafely) - iAborted = CZipException::abortedAction; // sorry, finished, but - // not successfull - - if (pCallback) - pCallback->CallbackEnd(); - - if (iAborted) - CZipException::Throw( - iAborted); // throw to distuingiush from other return codes - if (bRet) - return true; - else - CZipException::Throw(CZipException::badZipFile); - return false; // to satisfy the compiler and eliminate warning - } catch (...) { - CloseFileAfterTestFailed(); - throw; - } - } -} - -int -CZipArchive::WideToSingle(LPCTSTR lpWide, CZipAutoBuffer& szSingle) -{ -#ifdef _UNICODE - return ZipPlatform::WideToSingle(lpWide, szSingle); -#else - - size_t iLen = strlen(lpWide); - // if not UNICODE just copy - // iLen does not include the NULL character - szSingle.Allocate(iLen); - memcpy(szSingle, lpWide, iLen); - return iLen; -#endif -} - -int -CZipArchive::SingleToWide(const CZipAutoBuffer& szSingle, CZipString& szWide) -{ - -#ifdef _UNICODE - return ZipPlatform::SingleToWide(szSingle, szWide); -#else // if not UNICODE just copy - int singleLen = szSingle.GetSize(); - // iLen does not include the NULL character - memcpy(szWide.GetBuffer(singleLen), szSingle.GetBuffer(), singleLen); - szWide.ReleaseBuffer(singleLen); - return singleLen; -#endif -} - -void -CZipArchive::CryptDecodeBuffer(DWORD uCount) -{ - if (CurrentFile()->IsEncrypted()) - for (DWORD i = 0; i < uCount; i++) - CryptDecode(m_info.m_pBuffer[i]); -} - -void -CZipArchive::EmptyPtrList() -{ - if (m_list.GetCount()) { - // if some memory hasn't been freed due to an error in zlib, so free it - // now - CZipPtrListIter iter = m_list.GetHeadPosition(); - while (m_list.IteratorValid(iter)) - delete[](char*) m_list.GetNext(iter); - } - m_list.RemoveAll(); -} - -void -CZipArchive::SetFileHeaderAttr(CZipFileHeader& header, DWORD uAttr) -{ - header.SetSystemCompatibility(m_iArchiveSystCompatib); - header.SetSystemAttr(uAttr); -} - -void -CZipArchive::EnableFindFast(bool bEnable) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : Set it after opening the archive.\n"), - __FILE__, - __LINE__); - return; - } - m_centralDir.EnableFindFast(bEnable, m_bCaseSensitive); -} - -bool -CZipArchive::SetSystemCompatibility(int iSystemComp) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : Set it after opening the archive.\n"), - __FILE__, - __LINE__); - return false; - } - - if (m_iFileOpened == compress) { - TRACE(_T("%s(%i) : Set it before opening a file inside archive.\n"), - __FILE__, - __LINE__); - return false; - } - - if (!ZipCompatibility::IsPlatformSupported(iSystemComp)) - return false; - m_iArchiveSystCompatib = iSystemComp; - return true; -} - -void -CZipArchive::SetRootPath(LPCTSTR szPath) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : Set it after opening the archive.\n"), - __FILE__, - __LINE__); - return; - } - - if (m_iFileOpened != nothing) { - TRACE(_T("%s(%i) : Set it before opening a file inside archive.\n"), - __FILE__, - __LINE__); - return; - } - - if (szPath) { - m_szRootPath = szPath; - CZipPathComponent::RemoveSeparators(m_szRootPath); - } else - m_szRootPath.Empty(); -} - -CZipString -CZipArchive::TrimRootPath(CZipPathComponent& zpc) const -{ - if (m_szRootPath.IsEmpty()) - return zpc.GetFileName(); - CZipString szPath = zpc.GetFullPath(); - return RemovePathBeginning(m_szRootPath, szPath, m_pZipCompare) - ? szPath - : zpc.GetFileName(); -} - -bool -CZipArchive::RemovePathBeginning(LPCTSTR lpszBeginning, - CZipString& szPath, - ZIPSTRINGCOMPARE pCompareFunction) -{ - CZipString szBeginning(lpszBeginning); - CZipPathComponent::RemoveSeparators(szBeginning); - int iRootPathLength = szBeginning.GetLength(); - if (iRootPathLength && szPath.GetLength() >= iRootPathLength && - (szPath.Left(iRootPathLength).*pCompareFunction)(szBeginning) == 0) { - // the beginning is the same - if (szPath.GetLength() == iRootPathLength) { - szPath.Empty(); - return true; - } - // is the end of m_szPathRoot only a beginning of a directory name? - // check for a separator - // we know the length is larger, so we can write: - if (CZipPathComponent::IsSeparator(szPath[iRootPathLength])) { - szPath = szPath.Mid(iRootPathLength); - CZipPathComponent::RemoveSeparatorsLeft(szPath); - return true; - } - } - return false; -} - -void -CZipArchive::SetTempPath(LPCTSTR lpszPath, bool bForce) -{ - m_szTempPath = lpszPath; - if (lpszPath && bForce) - ZipPlatform::ForceDirectory(lpszPath); - CZipPathComponent::RemoveSeparators(m_szTempPath); -} - -CZipString -CZipArchive::PredictFileNameInZip(LPCTSTR lpszFilePath, - bool bFullPath, - int iWhat, - bool bExactly) const -{ - CZipString sz = lpszFilePath; - if (sz.IsEmpty()) - return _T(""); - bool bAppend; - switch (iWhat) { - case prFile: - bAppend = false; - break; - case prDir: - bAppend = true; - break; - default: - bAppend = CZipPathComponent::IsSeparator(sz[sz.GetLength() - 1]); - } - - // remove for CZipPathComponent treating last name as a file even if dir - CZipPathComponent::RemoveSeparators(sz); - CZipPathComponent zpc(sz); - - if (bFullPath) { - if (m_bRemoveDriveLetter) - sz = zpc.GetNoDrive(); - } else - sz = TrimRootPath(zpc); - - if (bAppend && !sz.IsEmpty()) - CZipPathComponent::AppendSeparator(sz); - CZipFileHeader fh; // create a temporary object to convert - fh.SetFileName(sz); - if (bExactly) { - fh.SetSystemCompatibility(m_iArchiveSystCompatib); - ZipCompatibility::FileNameUpdate(fh, false); - } else { - fh.SetSystemCompatibility( - -1); // non existing system to prevent ansi oem conversion - ZipCompatibility::FileNameUpdate(fh, - true); // update only path separators - } - - return fh.GetFileName(); -} - -CZipString -CZipArchive::PredictExtractedFileName(LPCTSTR lpszFileNameInZip, - LPCTSTR lpszPath, - bool bFullPath, - LPCTSTR lpszNewName) const -{ - CZipString szFile = lpszPath; - CZipString sz = lpszNewName ? lpszNewName : lpszFileNameInZip; - if (sz.IsEmpty()) - return szFile; - if (!szFile.IsEmpty()) - CZipPathComponent::AppendSeparator(szFile); - - // remove for CZipPathComponent treating last name as a file even if dir - CZipPathComponent::RemoveSeparators(sz); - CZipPathComponent zpc(sz); - szFile += bFullPath ? (m_bRemoveDriveLetter ? zpc.GetNoDrive() : sz) - : TrimRootPath(zpc); - return szFile; -} - -void -CZipArchive::SetAutoFlush(bool bAutoFlush) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive not yet opened.\n"), __FILE__, __LINE__); - return; - } - if (m_storage.IsSpanMode() != 0) { - TRACE( - _T("%s(%i) : Cannot set auto-flush for the disk spanning archive.\n"), - __FILE__, - __LINE__); - return; - } - m_bAutoFlush = bAutoFlush; -} - -void -CZipArchive::Flush() -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive not yet opened.\n"), __FILE__, __LINE__); - return; - } - - if (m_storage.IsSpanMode() < 0) { - TRACE(_T("%s(%i) : Cannot flush an existing disk spanning archive.\n"), - __FILE__, - __LINE__); - return; - } - WriteCentralDirectory(); - m_storage.FlushFile(); - if (m_storage.IsSpanMode() > - 0) // try to finalize disk-spanning archive without closing it - m_storage.FinalizeSpan(); -} - -void -CZipArchive::GetCentralDirInfo(CZipCentralDir::Info& info) const -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive not yet opened.\n"), __FILE__, __LINE__); - return; - } - m_centralDir.GetInfo(info); - if (GetSpanMode() > 0) - info.m_uDiskEntriesNo = m_storage.GetCurrentDisk(); -} - -bool -CZipArchive::CWildcard::IsPatternValid(LPCTSTR lpszPattern, int* iErrorType) -{ - try { - /* loop through pattern to EOS */ - while (*lpszPattern) { - /* determine pattern type */ - switch (*lpszPattern) { - /* check literal escape, it cannot be at end of pattern */ - case _T('\\'): - if (!*++lpszPattern) - throw patternEsc; - lpszPattern++; - break; - - /* the [..] construct must be well formed */ - case _T('['): - lpszPattern++; - - /* if the next character is ']' then bad pattern */ - if (*lpszPattern == _T(']')) - throw patternEmpty; - - /* if end of pattern here then bad pattern */ - if (!*lpszPattern) - throw patternClose; - - /* loop to end of [..] construct */ - while (*lpszPattern != _T(']')) { - /* check for literal escape */ - if (*lpszPattern == _T('\\')) { - lpszPattern++; - - /* if end of pattern here then bad pattern */ - if (!*lpszPattern++) - throw patternEsc; - } else - lpszPattern++; - - /* if end of pattern here then bad pattern */ - if (!*lpszPattern) - throw patternClose; - - /* if this a range */ - if (*lpszPattern == _T('-')) { - /* we must have an end of range */ - if (!*++lpszPattern || *lpszPattern == ']') - throw patternRange; - else { - - /* check for literal escape */ - if (*lpszPattern == _T('\\')) - lpszPattern++; - - /* if end of pattern here - then bad pattern */ - if (!*lpszPattern++) - throw patternEsc; - } - } - } - break; - - /* all other characters are valid pattern elements */ - case '*': - case '?': - default: - lpszPattern++; /* "normal" character */ - break; - } - } - throw patternValid; - } catch (int i) { - if (iErrorType) - *iErrorType = i; - return i == patternValid; - } -} - -bool -CZipArchive::CWildcard::IsPattern(LPCTSTR lpszPattern) -{ - while (*lpszPattern) { - switch (*lpszPattern++) { - case _T('?'): - case _T('*'): - case _T('['): - case _T('\\'): - return true; - } - } - return false; -} - -bool -CZipArchive::CWildcard::IsMatch(LPCTSTR lpszText, int* iRetCode) -{ - CZipString sz; - if (!m_bCaseSensitive) { - sz = lpszText; - sz.MakeLower(); - lpszText = (LPCTSTR)sz; - } - int i = Match((LPCTSTR)m_szPattern, lpszText); - if (iRetCode) - *iRetCode = i; - return i == matchValid; -} - -int -CZipArchive::CWildcard::MatchAfterStar(LPCTSTR p, LPCTSTR t) -{ - int iMatch = matchNone; - TCHAR nextp; - - /* pass over existing ? and * in pattern */ - - while (*p == _T('?') || *p == _T('*')) { - /* take one char for each ? and + */ - - if (*p == _T('?')) { - /* if end of text then no match */ - if (!*t++) - return matchAbort; - } - - /* move to next char in pattern */ - - p++; - } - - /* if end of pattern we have matched regardless of text left */ - - if (!*p) - return matchValid; - - /* get the next character to match which must be a literal or '[' */ - - nextp = *p; - if (nextp == _T('\\')) { - nextp = p[1]; - - /* if end of text then we have a bad pattern */ - - if (!nextp) - return matchPattern; - } - - /* Continue until we run out of text or definite result seen */ - - do { - /* a precondition for matching is that the next character - in the pattern match the next character in the text or that - the next pattern char is the beginning of a range. Increment - text pointer as we go here */ - - if (nextp == *t || nextp == _T('[')) - iMatch = Match(p, t); - - /* if the end of text is reached then no iMatch */ - - if (!*t++) - iMatch = matchAbort; - - } while (iMatch != matchValid && iMatch != matchAbort && - iMatch != matchPattern); - - /* return result */ - - return iMatch; -} - -int -CZipArchive::CWildcard::Match(LPCTSTR lpszPattern, LPCTSTR lpszText) -{ - - TCHAR range_start, range_end; /* start and end in range */ - - bool bInvert; /* is this [..] or [!..] */ - bool bMemberMatch; /* have I matched the [..] construct? */ - bool bLoop; /* should I terminate? */ - - for (; *lpszPattern; lpszPattern++, lpszText++) { - /* if this is the end of the text - then this is the end of the match */ - - if (!*lpszText) { - if (*lpszPattern == _T('*') && *++lpszPattern == _T('\0')) - return matchValid; - else - return matchAbort; - } - - /* determine and react to pattern type */ - - switch (*lpszPattern) { - case _T('?'): /* single any character match */ - break; - - case _T('*'): /* multiple any character match */ - return MatchAfterStar(lpszPattern, lpszText); - - /* [..] construct, single member/exclusion character match */ - case _T('['): { - /* move to beginning of range */ - - lpszPattern++; - - /* check if this is a member match or exclusion match */ - - bInvert = false; - if (*lpszPattern == _T('!') || *lpszPattern == _T('^')) { - bInvert = true; - lpszPattern++; - } - - /* if closing bracket here or at range start then we have a - malformed pattern */ - - if (*lpszPattern == _T(']')) - return matchPattern; - - bMemberMatch = false; - bLoop = true; - - while (bLoop) { - /* if end of construct then bLoop is done */ - - if (*lpszPattern == _T(']')) { - bLoop = false; - continue; - } - - /* matching a '!', '^', '-', '\' or a ']' */ - - if (*lpszPattern == _T('\\')) - range_start = range_end = *++lpszPattern; - else - range_start = range_end = *lpszPattern; - - /* if end of pattern then bad pattern (Missing ']') */ - - if (!*lpszPattern) - return matchPattern; - - /* check for range bar */ - if (*++lpszPattern == _T('-')) { - /* get the range end */ - - range_end = *++lpszPattern; - - /* if end of pattern or construct - then bad pattern */ - - if (range_end == _T('\0') || range_end == _T(']')) - return matchPattern; - /* special character range end */ - if (range_end == _T('\\')) { - range_end = *++lpszPattern; - - /* if end of text then - we have a bad pattern */ - if (!range_end) - return matchPattern; - } - - /* move just beyond this range */ - lpszPattern++; - } - - /* if the text character is in range then match found. - make sure the range letters have the proper - relationship to one another before comparison */ - - if (range_start < range_end) { - if (*lpszText >= range_start && - *lpszText <= range_end) { - bMemberMatch = true; - bLoop = false; - } - } else { - if (*lpszText >= range_end && - *lpszText <= range_start) { - bMemberMatch = true; - bLoop = false; - } - } - } - - /* if there was a match in an exclusion set then no match */ - /* if there was no match in a member set then no match */ - - if ((bInvert && bMemberMatch) || !(bInvert || bMemberMatch)) - return matchRange; - - /* if this is not an exclusion then skip the rest of - the [...] construct that already matched. */ - - if (bMemberMatch) { - while (*lpszPattern != _T(']')) { - /* bad pattern (Missing ']') */ - if (!*lpszPattern) - return matchPattern; - - /* skip exact match */ - if (*lpszPattern == _T('\\')) { - lpszPattern++; - - /* if end of text then - we have a bad pattern */ - - if (!*lpszPattern) - return matchPattern; - } - - /* move to next pattern char */ - - lpszPattern++; - } - } - break; - } - case _T('\\'): /* next character is quoted and must match exactly */ - - /* move pattern pointer to quoted char and fall through */ - - lpszPattern++; - - /* if end of text then we have a bad pattern */ - - if (!*lpszPattern) - return matchPattern; - - /* must match this character exactly */ - - default: - if (*lpszPattern != *lpszText) - return matchPattern; - } - } - /* if end of text not reached then the pattern fails */ - - if (*lpszText) - return matchEnd; - else - return matchValid; -} - -void -CZipArchive::FindMatches(LPCTSTR lpszPattern, - CZipWordArray& ar, - bool bFullPath) const -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return; - } - - // ar.RemoveAll(); don't do this - int iCount = GetCount(); - CWildcard wc(lpszPattern, m_bCaseSensitive); - for (int i = 0; i < iCount; i++) { - const CZipFileHeader* pHeader = m_centralDir[i]; - CZipString sz = m_centralDir.GetProperHeaderFileName(pHeader); - if (!bFullPath) { - CZipPathComponent::RemoveSeparators(sz); - CZipPathComponent zpc(sz); - sz = zpc.GetFileName(); - } - if (wc.IsMatch(sz)) - ar.Add(i); - } -} - -int -CZipArchive::WillBeDuplicated(LPCTSTR lpszFilePath, - bool bFullPath, - bool bFileNameOnly, - int iWhat) -{ - CZipString szFile; - // we predict with bExactly set to false, because FindFile converts all - // filanames anyway - if (bFileNameOnly) { - CZipPathComponent zpc(lpszFilePath); - szFile = PredictFileNameInZip(zpc.GetFileName(), false, iWhat); - } else - szFile = PredictFileNameInZip(lpszFilePath, bFullPath, iWhat); - return FindFile(szFile, ffDefault, bFileNameOnly); -} - -// it'll get up to the next file or to the end of file (bad if zip corrupted or -// not-ordered by offsett or redundant bytes added) -bool -CZipArchive::GetFromArchive(CZipArchive& zip, - WORD uIndex, - int iReplaceIndex, - bool bKeepSystComp, - CZipActionCallback* pCallback) -{ - - if (IsClosed() || zip.IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return false; - } - - if (m_iFileOpened || zip.m_iFileOpened) { - TRACE(_T("%s(%i) : You cannot get files from another archive if there ") - _T("is a file opened.\n"), - __FILE__, - __LINE__); - return false; - } - - if (zip.m_storage.IsSpanMode()) { - TRACE( - _T("%s(%i) : You cannot get files from the disk spannig archive.\n"), - __FILE__, - __LINE__); - return false; - } - - if (m_storage.IsSpanMode() == -1) { - TRACE(_T("%s(%i) : You cannot add files to the existing disk spannig ") - _T("archive.\n"), - __FILE__, - __LINE__); - return false; - } - - ASSERT(m_info.m_pBuffer.GetSize() > 0); - - bool bIsSpan = m_storage.IsSpanMode() == 1; - - CZipFileHeader fh; - if (!zip.GetFileInfo(fh, uIndex)) - return false; - CZipAbstractFile* pFile = zip.m_storage.m_pFile; - - DWORD uEndOffset; - if (uIndex < zip.GetCount() - 1) { - CZipFileHeader fhTemp; - if (!zip.GetFileInfo(fhTemp, uIndex + 1)) - return false; - uEndOffset = fhTemp.m_uOffset; - } else { - CZipCentralDir::Info info; - zip.m_centralDir.GetInfo(info); - if (info.m_bOnDisk) - uEndOffset = info.m_uOffset; - else - uEndOffset = pFile->GetLength(); - } - uEndOffset += zip.m_centralDir.GetBytesBefore(); - DWORD uStartOffset = - zip.m_centralDir.GetBytesBefore() + fh.m_uOffset + fh.GetSize(true); - DWORD uTotalToMove = uEndOffset - uStartOffset, uTotalMoved = 0; - - DWORD uPredictedSize = - fh.m_uComprSize + (fh.IsDataDescr() ? ZIPARCHIVE_DATADESCRIPTOR_LEN : 0); - if (uTotalToMove > uPredictedSize + 4 /* may be or may be not a signature*/) - uTotalToMove = uPredictedSize + 4; - else if (uTotalToMove < uPredictedSize) - ThrowError(CZipException::badZipFile); - - // conversion stuff - CZipString szFileNameConverted, szFileName; - bool bConvertSystem = - !bKeepSystComp && fh.GetSystemCompatibility() != m_iArchiveSystCompatib; - - // GetFileInfo always converts the filename regardless of - // zip.m_centralDir.m_bConvertAfterOpen value - szFileNameConverted = fh.GetFileName(); - if (bConvertSystem) { - DWORD uAttr = fh.GetSystemAttr(); - fh.SetSystemCompatibility(m_iArchiveSystCompatib); - fh.SetSystemAttr(uAttr); - } - - ZipCompatibility::FileNameUpdate(fh, false); - szFileName = fh.GetFileName(); - - bool bNeedDataDescr = bIsSpan && !fh.IsDataDescr(); - if (bNeedDataDescr) - fh.m_uFlag |= 8; // data descriptor present - - // needed by InsertFindFastElement - if (m_centralDir.IsFindFastEnabled()) - fh.SetFileName(szFileNameConverted); - - if (!UpdateReplaceIndex(iReplaceIndex, szFileNameConverted)) - return false; - - bool bReplace = iReplaceIndex >= 0; - int iCallbackType = 0; - if (pCallback) - iCallbackType = pCallback->m_iType; - - // if the same callback is applied to cbReplace, then the previous - // information about the type will be lost - CZipFileHeader* pHeader = - m_centralDir.AddNewFile(fh, iReplaceIndex); // must be converted when - // adding because of - // InsertFastElement - if (bReplace) - MakeSpaceForReplace( - iReplaceIndex, uTotalToMove + fh.GetSize(true), szFileNameConverted); - - if (pCallback) { - pCallback->m_iType = iCallbackType; - pCallback->Init(szFileNameConverted, zip.GetArchivePath()); - pCallback->SetTotal(fh.m_uComprSize); - } - - if (m_centralDir.IsFindFastEnabled()) - pHeader->SetFileName(szFileName); - - // must be written as not converted - pHeader->WriteLocal(m_storage); - - // made a correction to what was set in WriteLocal - pHeader->m_uOffset -= m_centralDir.GetBytesBefore(); - - // we keep in converted in memory - if (m_centralDir.m_bConvertAfterOpen) - pHeader->SetFileName(szFileNameConverted); - - // skip reading the local file header - - pFile->Seek(uStartOffset, CZipAbstractFile::begin); - - DWORD uPack = uTotalToMove > m_info.m_pBuffer.GetSize() - ? m_info.m_pBuffer.GetSize() - : uTotalToMove; - char* buf = (char*)m_info.m_pBuffer; - - DWORD size_read; - - int iAborted = 0; - bool bBreak = false; - if (uPack) - do { - size_read = pFile->Read(buf, uPack); - if (!size_read) - break; - if (uTotalMoved + size_read > uTotalToMove) { - size_read = uTotalToMove - uTotalMoved; - if (!size_read) // this is for protection - break; - bBreak = true; - } - - m_storage.Write(buf, size_read, false); - uTotalMoved += size_read; - if (pCallback) - if (!(*pCallback)(size_read)) { - if (uTotalToMove != uTotalMoved) { - if (!bIsSpan && !bReplace) { - m_centralDir.RemoveLastFile(); - iAborted = CZipException::abortedSafely; - } else - iAborted = CZipException::abortedAction; - } else - iAborted = CZipException::abortedSafely; // we did it! - break; - } - } while (!bBreak); - - if (iAborted) - CZipException::Throw( - iAborted); // throw to distuingiush from other return codes - - // copying from non-span to span or from span without data description to - // span so add the data descriptor - - m_centralDir.m_pOpenedFile = NULL; - if (bNeedDataDescr && uTotalMoved == uTotalToMove) { - const int iToWrite = ZIPARCHIVE_DATADESCRIPTOR_LEN + 4; - CZipAutoBuffer buf(iToWrite); - memcpy(buf, m_storage.m_gszExtHeaderSignat, 4); - pHeader->GetCrcAndSizes(buf + 4); - m_storage.Write(buf, iToWrite, true); - } - m_storage.Flush(); - if (uTotalMoved < uTotalToMove) - ThrowError(CZipException::badZipFile); - - if (pCallback) - pCallback->CallbackEnd(); - - return true; -} - -bool -CZipArchive::GetFromArchive(CZipArchive& zip, - CZipWordArray& aIndexes, - bool bKeepSystComp) -{ - aIndexes.Sort(true); - int iFiles = aIndexes.GetSize(); - m_info.Init(); - try { - for (int i = 0; i < iFiles; i++) { - int iFileIndex = aIndexes[i]; - if (!m_centralDir.IsValidIndex(iFileIndex)) - if (!GetFromArchive(zip, - iFileIndex, - -1, - bKeepSystComp, - GetCallback(cbGetFromArchive))) { - m_info.ReleaseBuf(); - return false; - } - } - } catch (...) { - m_info.ReleaseBuf(); - throw; - } - m_info.ReleaseBuf(); - if (m_bAutoFlush) - Flush(); - return true; -} -bool -CZipArchive::RenameFile(WORD uIndex, LPCTSTR lpszNewName) -{ - if (IsClosed()) { - TRACE(_T("%s(%i) : ZipArchive is closed.\n"), __FILE__, __LINE__); - return false; - } - - if (m_storage.IsSpanMode()) { - TRACE( - _T("%s(%i) : You cannot rename files in the disk spannig archive.\n"), - __FILE__, - __LINE__); - return false; - } - - if (m_iFileOpened) { - TRACE( - _T("%s(%i) : You cannot rename a file if there is a file opened.\n"), - __FILE__, - __LINE__); - return false; - } - CZipFileHeader fh, fhNew; - if (!GetFileInfo(fh, uIndex)) - return false; - CZipString szNewName(lpszNewName); - if (fh.IsDirectory()) - CZipPathComponent::AppendSeparator(szNewName); - else - CZipPathComponent::RemoveSeparators(szNewName); - if (fh.GetFileName().Collate(szNewName) == 0) - return true; - fhNew.SetSystemCompatibility(m_iArchiveSystCompatib); - - fhNew.SetFileName(szNewName); - ZipCompatibility::FileNameUpdate(fhNew, false); - ZipCompatibility::FileNameUpdate( - fh, false); // in case the conversion changes the filename size - WORD uFileNameLen = fh.GetFileNameSize(); - WORD uNewFileNameLen = fhNew.GetFileNameSize(); - int iDelta = uNewFileNameLen - uFileNameLen; - int iOffset = 0; - CZipAutoBuffer buf, *pBuf; - m_centralDir.RemoveFromDisk(); // does m_storage.Flush(); - if (iDelta != 0) { - // we need to make more or less space - - m_info.Init(); - DWORD uStartOffset = fh.m_uOffset + 30 + uFileNameLen; - DWORD uFileLen = m_storage.m_pFile->GetLength(); - DWORD uEndOffset = uFileLen - m_centralDir.GetBytesBefore(); - CZipActionCallback* pCallback = GetCallback(cbRename); - if (pCallback) { - // do it right and sent the notification - pCallback->Init(fh.GetFileName(), GetArchivePath()); - pCallback->SetTotal(uEndOffset - uStartOffset); - } - bool bForward = iDelta > 0; - if (bForward) - m_storage.m_pFile->SetLength(uFileLen + - iDelta); // ensure the seek is correct - - MovePackedFiles( - uStartOffset, uEndOffset, abs(iDelta), pCallback, bForward); - if (pCallback) - pCallback->CallbackEnd(); - - if (!bForward) - m_storage.m_pFile->SetLength(uFileLen + - iDelta); // delta < 0; shrink the file - - m_info.ReleaseBuf(); - - int iSize = GetCount(); - for (int i = uIndex + 1; i < iSize; i++) - m_centralDir[i]->m_uOffset += iDelta; - buf.Allocate(4 + uNewFileNameLen); - WORD uExtraFieldSize = fh.GetExtraFieldSize(); - memcpy(buf, &uNewFileNameLen, 2); - memcpy(buf + 2, &uExtraFieldSize, 2); // to write everything at once - memcpy(buf + 4, fhNew.m_pszFileName, uNewFileNameLen); - pBuf = &buf; - iOffset = -4; - } else - pBuf = &fhNew.m_pszFileName; - - m_storage.m_pFile->Seek(m_centralDir.GetBytesBefore() + fh.m_uOffset + 30 + - iOffset, - CZipAbstractFile::begin); - m_storage.m_pFile->Write(buf, buf.GetSize()); - m_centralDir.RenameFile(uIndex, szNewName); - if (m_bAutoFlush) - Flush(); - - return true; -} - -bool -CZipArchive::UpdateReplaceIndex(int& iReplaceIndex, LPCTSTR lpszNewFileName) -{ - if (iReplaceIndex == -2) - iReplaceIndex = FindFile(lpszNewFileName); - if (iReplaceIndex < 0) { - if (iReplaceIndex != -1) - iReplaceIndex = -1; - return true; - } - - if (GetSpanMode() != 0) { - TRACE( - _T("%s(%i) : You cannot replace files in a disk-spanning archive.\n"), - __FILE__, - __LINE__); - return false; - } - - if (!m_centralDir.IsValidIndex(iReplaceIndex)) { - TRACE(_T("%s(%i) : Not valid replace index.\n"), __FILE__, __LINE__); - return false; - } - if (iReplaceIndex == GetCount() - 1) // replacing last file in the archive - { - RemoveLast(true); - iReplaceIndex = -1; - } - return true; -} - -void -CZipArchive::MakeSpaceForReplace(int iReplaceIndex, - DWORD uTotal, - LPCTSTR lpszFileName) -{ - - ASSERT(iReplaceIndex < GetCount() - 1); - DWORD uReplaceStart = - m_storage.m_pFile->GetPosition() - m_centralDir.GetBytesBefore(); - DWORD uReplaceEnd = m_centralDir.m_headers[iReplaceIndex + 1]->m_uOffset; - DWORD uReplaceTotal = uReplaceEnd - uReplaceStart; - int iDelta = uTotal - uReplaceTotal; - - if (iDelta != 0) { - - // m_info.Init(); don't - the calling functions will - CZipActionCallback* pCallback = GetCallback(CZipArchive::cbReplace); - DWORD uFileLen = m_storage.m_pFile->GetLength(); - DWORD uUpperLimit = - uFileLen - - m_centralDir.GetBytesBefore(); // will be added in MovePackedFiles - if (pCallback) { - pCallback->Init(lpszFileName, GetArchivePath()); - pCallback->SetTotal(uUpperLimit - uReplaceEnd); - } - - bool bForward = iDelta > 0; - if (bForward) - m_storage.m_pFile->SetLength(uFileLen + - iDelta); // ensure the seek is correct - - MovePackedFiles( - uReplaceEnd, uUpperLimit, abs(iDelta), pCallback, bForward); - - if (!bForward) - m_storage.m_pFile->SetLength(uFileLen + - iDelta); // delta < 0; shrink the file - - m_storage.m_pFile->Seek(uReplaceStart, CZipAbstractFile::begin); - int iSize = m_centralDir.m_headers.GetSize(); - for (int i = iReplaceIndex + 1; i < iSize; i++) - m_centralDir.m_headers[i]->m_uOffset += iDelta; - if (pCallback) - pCallback->CallbackEnd(); - } -} - -void -CZipArchive::MovePackedFiles(DWORD uStartOffset, - DWORD uEndOffset, - DWORD uMoveBy, - CZipActionCallback* pCallback, - bool bForward) -{ - ASSERT(m_info.m_pBuffer.GetSize() > 0); - uStartOffset += m_centralDir.GetBytesBefore(); - uEndOffset += m_centralDir.GetBytesBefore(); - - DWORD uTotalToMove = uEndOffset - uStartOffset; - DWORD uPack = uTotalToMove > m_info.m_pBuffer.GetSize() - ? m_info.m_pBuffer.GetSize() - : uTotalToMove; - char* buf = (char*)m_info.m_pBuffer; - - DWORD size_read; - bool bBreak = false; - do { - - if (uEndOffset - uStartOffset < uPack) { - uPack = uEndOffset - uStartOffset; - if (!uPack) - break; - bBreak = true; - } - DWORD uPosition = bForward ? uEndOffset - uPack : uStartOffset; - - m_storage.m_pFile->Seek(uPosition, CZipAbstractFile::begin); - size_read = m_storage.m_pFile->Read(buf, uPack); - if (!size_read) - break; - - if (bForward) - uPosition += uMoveBy; - else - uPosition -= uMoveBy; - m_storage.m_pFile->Seek(uPosition, CZipAbstractFile::begin); - m_storage.m_pFile->Write(buf, size_read); - if (bForward) - uEndOffset -= size_read; - else - uStartOffset += size_read; - if (pCallback) - if (!(*pCallback)(size_read)) - ThrowError(CZipException::abortedAction); - } while (!bBreak); - - if (uEndOffset != uStartOffset) - ThrowError(CZipException::internal); -} \ No newline at end of file diff --git a/src/smpackagee/ZipArchive/ZipArchive.dox b/src/smpackagee/ZipArchive/ZipArchive.dox deleted file mode 100644 index 394c02ddcb..0000000000 --- a/src/smpackagee/ZipArchive/ZipArchive.dox +++ /dev/null @@ -1,221 +0,0 @@ -# Doxyfile 1.3.2 - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = ZipArchive -PROJECT_NUMBER = -OUTPUT_DIRECTORY = .\Doc -OUTPUT_LANGUAGE = English -USE_WINDOWS_ENCODING = YES -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO -EXTRACT_LOCAL_CLASSES = YES -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -HIDE_FRIEND_COMPOUNDS = NO -HIDE_IN_BODY_DOCS = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = $(PWD)/ -INTERNAL_DOCS = NO -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = YES -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 1 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -GENERATE_DEPRECATEDLIST= YES -ALIASES = -ENABLED_SECTIONS = YES -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = NO -OPTIMIZE_OUTPUT_JAVA = NO -SHOW_USED_FILES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = NO -WARNINGS = YES -WARN_IF_UNDOCUMENTED = NO -WARN_IF_DOC_ERROR = YES -WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = .\ZipArchive.h \ - .\ZipAutoBuffer.h \ - .\ZipCentralDir.h \ - .\ZipCompatibility.h \ - .\ZipException.h \ - .\ZipFileHeader.h \ - .\ZipPlatform.h \ - .\ZipMemFile.h \ - .\ZipPathComponent.h \ - .\ZipStorage.h \ - .\changelog.txt \ - .\faq.txt \ - .\License.txt \ - .\gpl.txt \ - .\Readme.txt -FILE_PATTERNS = -RECURSIVE = NO -EXCLUDE = -EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -STRIP_CODE_COMMENTS = YES -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -VERBATIM_HEADERS = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = CZip -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = . -HTML_FILE_EXTENSION = .html -HTML_HEADER = "c:\Program Files\Doxygen\header.html" -HTML_FOOTER = "c:\Program Files\Doxygen\footer.html" -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = YES -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = YES -BINARY_TOC = YES -TOC_EXPAND = YES -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = -LATEX_CMD_NAME = latex -MAKEINDEX_CMD_NAME = makeindex -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -LATEX_HIDE_INDICES = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = NO -MAN_OUTPUT = -MAN_EXTENSION = .3 -MAN_LINKS = NO -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -XML_OUTPUT = xml -XML_SCHEMA = -XML_DTD = -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- -GENERATE_AUTOGEN_DEF = NO -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- -GENERATE_PERLMOD = NO -PERLMOD_LATEX = NO -PERLMOD_PRETTY = YES -PERLMOD_MAKEVAR_PREFIX = -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = NO -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = YES -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = NO -ALLEXTERNALS = YES -EXTERNAL_GROUPS = YES -PERL_PATH = /usr/bin/perl -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -CLASS_GRAPH = YES -COLLABORATION_GRAPH = NO -UML_LOOK = YES -TEMPLATE_RELATIONS = YES -INCLUDE_GRAPH = NO -INCLUDED_BY_GRAPH = NO -CALL_GRAPH = NO -GRAPHICAL_HIERARCHY = YES -DOT_IMAGE_FORMAT = gif -DOT_PATH = "c:/Program Files/ATT/Graphviz/bin/" -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 1024 -MAX_DOT_GRAPH_HEIGHT = 1024 -MAX_DOT_GRAPH_DEPTH = 0 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO -CGI_NAME = search.cgi -CGI_URL = -DOC_URL = -DOC_ABSPATH = -BIN_ABSPATH = /usr/local/bin/ -EXT_DOC_PATHS = diff --git a/src/smpackagee/ZipArchive/ZipArchive.h b/src/smpackagee/ZipArchive/ZipArchive.h deleted file mode 100644 index 9a34c3d5cc..0000000000 --- a/src/smpackagee/ZipArchive/ZipArchive.h +++ /dev/null @@ -1,2070 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipArchive.h $ -// $Archive: /ZipArchive/ZipArchive.h $ -// $Date: 2003-12-11 00:09:22 -0600 (Thu, 11 Dec 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -// -// Check the site http://www.artpol-software.com for the updated version of the -// library. -//////////////////////////////////////////////////////////////////////////////// -// -// The following information files are distributed along with this library: -// License.txt - licensing information -// gpl.txt - General Public License text -// Readme.txt - general information -// ChangeLog.txt - revision history -// faq.txt - frequently asked questions -// Appnote.txt - details on the zip format -// ( also available at -// ftp://ftp.pkware.com/appnote.zip) -// -// - -/** - * \file ZipArchive.h - * Interface for the CZipArchive class. - * - */ - -#if !defined(AFX_ZIPARCHIVE_H__A7F528A6_1872_4071_BE66_D56CC2DDE0E6__INCLUDED_) -#define AFX_ZIPARCHIVE_H__A7F528A6_1872_4071_BE66_D56CC2DDE0E6__INCLUDED_ - -/** - \namespace ziparchv - A helper namespace. - \par Members - - CZipFileMapping - -*/ - -/** - \struct CZipFileMapping ZipFileMapping.h - - Maps a file to the memory. A system-specific implementation. - Stored in ziparchv namespace. - - \c #include "ZipFileMapping.h" -*/ - -// to ensure that the correct files are copied -// (see "Compatibility" chapter in the documentation). -// Rebuild the project after copying the files. -#ifdef ZIP_ARCHIVE_MFC_PROJ -#ifndef ZIP_ARCHIVE_MFC -#error You need to copy files from the MFC subdirectory\ - to the ZipArchive root directory and rebuild the project -#endif -#elif defined ZIP_ARCHIVE_STL_PROJ -#ifndef ZIP_ARCHIVE_STL -#error You need to copy files from the STL subdirectory\ - to the ZipArchive root directory and rebuild the project -#endif -#endif // - -#if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL) -#pragma warning(disable : 4251) // needs to have dll-interface to be used by - // clients of class -#pragma warning( \ - disable : 4275) // non dll-interface class used as base for dll-interface -#endif - -#ifdef __GNUC__ -#include "zlib.h" -#else -#include "../../../extern/zlib/zlib.h" -#endif - -#include "global.h" -#include "ZipAutoBuffer.h" -#include "ZipCentralDir.h" -#include "ZipException.h" -#include "ZipExport.h" -#include "ZipPathComponent.h" -#include "ZipStorage.h" -#include "ZipString.h" - -/** - Structure used as a parameter in CZipArchive::AddNewFile(CZipAddNewFileInfo& - ); Use one of constructors provided and then adjust the member variables that - are set to default values by #Defaults method. -*/ -struct ZIP_API CZipAddNewFileInfo -{ - CZipAddNewFileInfo(LPCTSTR lpszFilePath, bool bFullPath = true) - : m_szFilePath(lpszFilePath) - , m_bFullPath(bFullPath) - { - m_pFile = NULL; - Defaults(); - } - CZipAddNewFileInfo(LPCTSTR lpszFilePath, LPCTSTR lpszFileNameInZip) - : m_szFilePath(lpszFilePath) - , m_szFileNameInZip(lpszFileNameInZip) - { - m_pFile = NULL; - Defaults(); - } - CZipAddNewFileInfo(CZipAbstractFile* pFile, LPCTSTR lpszFileNameInZip) - : m_pFile(pFile) - , m_szFileNameInZip(lpszFileNameInZip) - { - Defaults(); - } - /** - the full path to the file to be added; if it is empty you need to set - #m_pFile - */ - CZipString m_szFilePath; - - /** - the file name that will be stored in the archive (if the file is a - directory, there is a path separator automatically added at the end); - #SetRootPath function has no effect on this parameter - */ - CZipString m_szFileNameInZip; - - /* - It has only the meaning when #m_szFileNameInZip is not specified and - #m_szFilePath is not empty. - - if \c true, include full path of the file inside the archive (even if - #m_szRootPath is set)
- - if \c false only the filename without a path is stored in the archive
- in this case if #m_szRootPath is set previously with #SetRootPath - and if the beginning of #m_szFilePath equals #m_szRootPath - then the filename is set to the remaining part of m_szFilePath - (you can say to m_lpszFilePath minus #m_szRootPath) - */ - bool m_bFullPath; - - /* - the compression level, see #OpenNewFile - */ - int m_iComprLevel; - - /** - the smartness level of of the library; can be one or more #Smartness - values (you can OR them);
- if zipsmCheckForEff is specified and due to it the file needs to be - reinserted into the archive without a compression and the callback - functor is specified, the callback functor's method Callback is called - with the first argument set to - DWORD (-1) (you need to remember the last argument if you need the - size of the file) - */ - int m_iSmartLevel; - - /* - the index of the existing file in the archive to be replaced by the file -being added (the new file goes into the same physical place as the old file - -the archive may of course grow or shrink as a result) - -- >= 0 the index of the file to be replaced -- -1 do not replace any file and add the new file at the end of the archive -(default) -- -2 if the new file has the same name as a file already in the archive then -replace it or add at the end of the archive if it's filename is unique; it uses -CZipArchive::FindFile with the arguments \e iCaseSensitive and \e bFileNameOnly -set to default values - - \note - - you replace files in disk-spanning archives (i.e. use a value -different from -1) - - if the space size taken by the old file is different from the space -size needed by the new file, the callback is called while moving data (see -CZipArchive::cbReplace) - - this replaces the file physically, so no information from the file -being replaced is retained (such as attributes, modification time, etc.) - - if you use an invalid index, the function will fail; if you specify -the last file in the archive to be replaced, it'll be removed and the usual -action taken - - the new file encryption does not depend on the old file encryption but -only on the current password settings (see CZipArchive::SetPassword) - - if #m_iComprLevel is not 0 then a temporary archive is created in the -temporary directory (see CZipArchive::SetTempPath) or in the memory (if you use -CZipArchive::zipsmMemoryFlag in #m_iSmartLevel) - - the most complicated scenario is when you try to replace the -file and use CZipArchive::zipsmCheckForEff flag in #m_iSmartLevel and the file -compression proves to be inefficient (you can use the sample application \e -ZipArc to observe the following process): - - first you get CZipArchive::cbAdd callback - the file is being -compressed to a temporary archive, - - then the file compression proves to be inefficient and the file -needs to be stored instead of compressed, but first the space inside archive -must be adjusted to fit the file being added in the place of file being replaced -- you get CZipArchive::cbReplace, - - then, at the end, the file is being stored - you get -CZipArchive::cbAddStore callback - \see SetAdvanced - \see CZipArchive::WillBeDuplicated - */ - int m_iReplaceIndex; - - /** - the size of the buffer used while file operations - */ - unsigned long m_nBufSize; - - /* - instead of from a physical file, the data for compression is taken from - the CZipAbstractFile object (e.g. from CZipMemFile) - "\note" - - you have to leave #m_szFilePath empty if you set #m_pFile to not NULL - - the time of the file in zip is set to the current time, and the - attributes to the default file attributes (depending on the system) - - you cannot add directories this way - */ - CZipAbstractFile* m_pFile; - - /* - Set default values for #m_iSmartLevel, #m_iReplaceIndex, #m_nBufSize and - #m_iComprLevel - */ - void Defaults(); -}; - -/** - The representation of the zip archive file. - This class provides all the operations on the zip archive. - -*/ -class ZIP_API CZipArchive -{ - - public: - /** - The purpose of this structure is to hold the data that allow communication - with the zlib library - */ - struct ZIP_API CZipInternalInfo - { - - CZipInternalInfo() { m_iBufferSize = 65536; } - virtual ~CZipInternalInfo() {} - - /** - Allocate internal buffer of m_iBufferSize size - */ - void Init() { m_pBuffer.Allocate(m_iBufferSize); } - void ReleaseBuf() { m_pBuffer.Release(); } - z_stream m_stream; ///< zlib library data stream - DWORD m_uUncomprLeft; ///< bytes left to uncompress - DWORD m_uComprLeft; ///< bytes left to decompress - DWORD m_uCrc32; ///< crc32 file control value - - /** - The size of the buffer used in decompressing data. - Set before opening the archive. - It is usually set with CZipArchive::SetAdvanced - (specify this value as the second argument). - \see CZipArchive::SetAdvanced - */ - DWORD m_iBufferSize; - - /** - This buffer caches data during compression and decompression. - */ - CZipAutoBuffer m_pBuffer; - }; - - CZipArchive(); - virtual ~CZipArchive(); - - /* - In non-UNICODE version just copy \e szSingle to \e szWide. - In UNICODE version works the same way as ZipPlatform::SingleToWide - \param szSingle - \param szWide - \return (in non-UNICODE version the number of characters copied) - \see ZipPlatform::SingleToWide -*/ - static int SingleToWide(const CZipAutoBuffer& szSingle, CZipString& szWide); - - /** - In non-UNICODE version just copy \e lpWide to \e szSingle. - In UNICODE version works the same way as ZipPlatform::WideToSingle - \param lpWide - \param szSingle - \return (in non-UNICODE version the number of characters copied) - \see ZipPlatform::WideToSingle - -*/ - static int WideToSingle(LPCTSTR lpWide, CZipAutoBuffer& szSingle); - - /** - Set the password for the file to be opened or created. - Use this method BEFORE opening or adding a file, but AFTER opening an - archive \param lpszPassword set it to NULL to clear password \return \c - false if the password contains ASCII characters with values 128 or higher or - the file inside archive is opened - -*/ - bool SetPassword(LPCTSTR lpszPassword = NULL); - - /** - \return the current archive password or an empty string if there is no - password -*/ - CZipString GetPassword() const; - - /** - Set the buffer sizes. No buffer can be set smaller than 1024. - Use this method before opening the archive. The optimal size for - the write buffer in the disk spanning archive is the size of the volume. - - \param iWriteBuffer - the write cache size used - \see CZipStorage::m_iWriteBufferSize - \param iGeneralBuffer - buffer used in extracting, compressing, deleting, getting - (#GetFromArchive) files, renaming and replacing \see - CZipInternalInfo::m_iBufferSize \param iSearchBuffer the buffer used in - searching for the central dir \see CZipCentralDir::m_iBufferSize \see - GetAdvanced -*/ - void SetAdvanced(int iWriteBuffer = 65536, - int iGeneralBuffer = 65536, - int iSearchBuffer = 32768); - - /** - retreive buffer size as set by #SetAdvanced - */ - void GetAdvanced(int* piWriteBuffer = NULL, - int* piGeneralBuffer = NULL, - int* piSearchBuffer = NULL) - { - if (piWriteBuffer) - *piWriteBuffer = m_storage.m_iWriteBufferSize; - if (piGeneralBuffer) - *piGeneralBuffer = m_info.m_iBufferSize; - if (piSearchBuffer) - *piSearchBuffer = m_centralDir.m_iBufferSize; - } - - /** - Enum values used as \e iWhich parameter in #SetCallback function. - You can assign several values to the same functor (OR them) - \see CZipActionCallback - */ - enum CallbackType - { - cbNothing = 0x0000, ///< you can use it for your own purposes - cbAdd = 0x0001, ///< called when adding a file with one of #AddNewFile - ///< functions - cbAddTmp = 0x0002, ///< called while adding a file (only on a - ///< disk-spanning archive) when the smartness level - ///< contains CZipArchive::zipsmCheckForEff or - ///< CZipArchive::zipsmCheckForEffInMem and if just - ///< compressed file is being moved from a temporary - ///< place (file or memory) to the archive - cbAddStore = 0x0004, ///< called while adding a file and if it's - ///< compressing has proven to be inefficient and - ///< it is now being stored (instead of compressed) - ///< in the archive; smartness level must contain - ///< CZipArchive::zipsmCheckForEff or - ///< CZipArchive::zipsmCheckForEffInMem; the - ///< archive can be disk-spanning or not - - cbExtract = 0x0008, ///< called when extracting a file with one of - ///< #ExtractFile functions - - cbDeleteCnt = 0x0010, ///< called before the actual deletion takes place - ///< and the map of holes and continuous areas is - ///< being created (it safe to break it by - ///< returning \c false from the callback method) - cbDelete = 0x0020, ///< called when moving data while deleting file(s) - ///< with function #DeleteFile or one of #DeleteFiles - ///< functions - - cbTest = 0x0040, ///< called when testing a file with #TestFile function - cbSave = 0x0080, ///< called when saving the central directory with - ///< CZipCentralDir::Write (usually on close or flush); - ///< it is safe to break on non-disk spanning archive - - ///< the saved part of the central directory will be - ///< removed from disk - cbGetFromArchive = - 0x0100, ///< called when using one of #GetFromArchive methods - cbRename = 0x0200, ///< called when during the renaming a file there is - ///< a need to make less or more space for the new - ///< filename - cbReplace = 0x0400, ///< called when moving data while replacing files - ///< to make less or more space for the new file - cbNextValue = 0x0800, ///< for CZipActionCallback overrides and user - ///< defined callbacks - - cbSubActions = cbAddTmp | cbAddStore | cbDeleteCnt | - cbReplace, ///< sub actions - they are part of bigger - ///< actions (#cbAddTmp | #cbAddStore | - ///< #cbDeleteCnt | #cbReplace) - cbActions = - cbAdd | cbExtract | cbDelete | cbTest | cbSave | cbGetFromArchive | - cbRename, ///< main actions (#cbAdd | #cbExtract | #cbDelete | #cbTest - ///< | #cbSave | #cbGetFromArchive | #cbRename) - cbAll = - cbActions | cbSubActions ///< assign all callbacks to the same functor - }; - - /* - Set callback functors for the following operations on the zip archive: - adding, extracting, testing or deleting files. See \ref sectCallb - information on how to use functors. \param pCallback the address of the - functional object which class is derived from CZipActionCallback (you - need to override member function CZipCallback::Callback in the derived - class) Set it to \c NULL to clear callback for the selected actions. - \param iWhich - can be one or more (use logical OR) #CallbackType values. - \see CZipActionCallback - \see GetCallback - */ - void SetCallback(CZipActionCallback* pCallback = NULL, int iWhich = cbAll); - - /** - \return the callback \e iWhich set with #SetCallback - */ - CZipActionCallback* GetCallback(CallbackType iWhich) - { - return m_callbacks.Get(iWhich); - } - - /* - Set the callback functor used during operations on a - PKZIP compatible disk spanning archive to change disks. - Set it before opening the archive. If you open the archive - in the \ref PKSpan "PKZIP compatible mode" and don't set the callback - functor, the exception CZipException::noCallback will be thrown. - - Callback functor's method CZipSpanCallback::Callback is called when - there is a need for a disk change. Calling CZipArchive methods from - inside this method may result in an unexpected behavior. \param pCallback - the address of the functional object which class is derived from - CZipSpanCallback (you need to override member function - CZipCallback::Callback in the derived class) Set it to \c NULL to clear - the callback. - \see CZipSpanCallback - */ - void SetSpanCallback(CZipSpanCallback* pCallback = NULL) - { - m_storage.m_pChangeDiskFunc = pCallback; - } - - /* - Archive open modes used in #Open(LPCTSTR , int , int ) - and #Open(CZipMemFile, int ) - */ - enum OpenMode - { - zipOpen, ///< open an existing archive - /** - Open an existing archive as a read only file. - This mode is intended to use in a self extract code or opening - archive on storage without write access (e.g. CD-ROMS), - If you try to modify the archive in this mode, - an exception will be thrown. - */ - zipOpenReadOnly, - zipCreate, ///< create a new archive - zipCreateSpan ///< create a disk spanning archive - }; - - /* - Open or create a zip archive. - - The archive creation mode depends on \e iMode and \e iVolumesSize values: - - if \e iMode == #zipCreateSpan and \e iVolumeSize <= 0 then create disk - spanning archive in \ref PKSpan "PKZIP compatible mode" (pkzipSpan) - - if \e iMode == #zipCreateSpan and \e iVolumeSize > 0 then create disk - spanning archive in \ref TDSpan "TD compatible mode" (tdSpan) - - if \e iMode == #zipOpen and the existing archive is a spanned archive - then pkzipSpan mode is assumed if the archive is on a removable device - or tdSpan otherwise;
- if you want to open tdSpan archive on a removable device, set \e - iVolumeSize to a value different from 0 - - if \e iMode == #zipCreate then \e iVolumeSize doesn't matter - - \param szPathName - the path to the archive - \param iMode - one of the #OpenMode values - \param iVolumeSize - the volume size in the disk spanning archive; - the size of the volume may be from 1 to INT_MAX , - and the bigger - the faster is creation and extraction (no file changes - between volumes) - but the size of the whole archive is the same. If you're - creating disk-spanning archive in \ref TDSpan "TD span compatible mode" and - plan later to convert it to \ref PKSpan "PKZIP compatible mode" (see \ref - sectSpan), it is good to set this this value to about the size of the - diskette (a little less just in case). - \note Throws exceptions. - \see Open(CZipMemFile&, int); - \see GetSpanMode -*/ - void Open(LPCTSTR szPathName, int iMode = zipOpen, int iVolumeSize = 0); - - /* - Open or create the archive in memory. The CZipMemFile object is not closed - after closing the archive, so that is it possible to work with it - afterwards. \param mf CZipMemFile structure to create archive in or extract - from \note This is important: you shouldn't destroy CZipMemFile object - before closing the archive, because you'll get an error; \param iMode Open - mode. The following modes are valid: #zipOpen, #zipOpenReadOnly, #zipCreate - \note Throws exceptions. - \see Open(LPCTSTR, int, int); -*/ - void Open(CZipMemFile& mf, int iMode = zipOpen); - - /* - Set #m_szRootPath to a specified value. Use it if you don't want to set - \e bFullPath argument in #AddNewFile or #ExtractFile to true and you - don't want to strip the whole path neither, but only a specific beginning. - Use it AFTER opening the archive and before using #AddNewFile or - #ExtractFile. See \ref q9 "the FAQ" for the example of use. \param szPath - Set it to the string that you want to be omitted from the beginning of - the path of the file in the archive
if \c NULL - clears the - #m_szRootPath and no path beginning will be matched against it - - \note Set the case-sensitivity with #SetCaseSensitivity - - \see AddNewFile - \see ExtractFile - \see GetRootPath - -*/ - void SetRootPath(LPCTSTR szPath = NULL); - - /* - Return the current value of #m_szRootPath - \return CZipString - */ - CZipString GetRootPath() const { return m_szRootPath; } - - /* - The levels of smartness of the adding files action (see #AddNewFile) - \note If you wish to use \e zipsmCheckForEff, you should use - \e zipsmNotCompSmall as well, because it will save you the time - ( the small file will be surely larger after compression, so that - we can add it not compressed straight away);the compression level - is always ignored for a directory and set to 0 - */ - - enum Smartness - { - zipsmLazy = - 0x0000, ///< do not bother (you know what you're doing after all) - zipsmCPassDir = 0x0001, ///< clear password for directories - zipsmCPFile0 = 0x0002, ///< clear password for files of 0 size - zipsmNotCompSmall = 0x0004, ///< do not compress files smaller than 5 - ///< bytes (they are always stored larger - ///< than uncompressed) - zipsmCheckForEff = - 0x0008, ///< check whether the compressed file is larger than - ///< uncompressed and if so, remove it and store without the - ///< compression; in the disk spanning mode, the temporary - ///< file is used for that: if the file compression is - ///< efficient, the data is not compressed again, but moved - ///< from the temporary file to the archive; you can use - ///< #SetTempPath() to set the path where the file will be - ///< created or you can let the library figure it out (the - ///< library tries first the system default temporary - ///< directory, if it is not present or there is not enough - ///< space there, it tries the current directory, if it fails, - ///< no temporary file is created and the compression goes the - ///< usual way - - zipsmMemoryFlag = 0x0010, ///< combine it with zipsmCheckForEff or use - ///< zipsmCheckForEffInMem, you can also use - ///< this when replacing files see note at - ///< CZipAddNewFileInfo::m_iReplaceIndex - - zipsmCheckForEffInMem = - zipsmMemoryFlag | - zipsmCheckForEff, ///< the same as #zipsmCheckForEff, but the - ///< temporary file is created created in memory - ///< instead (the temporary directory set with - ///< #SetTempPath() is ignored); has the meaning - ///< only with a disk-spanning archive, non-disk - ///< spanning archives don't need a temporary file - zipsmSmartPass = - zipsmCPassDir | zipsmCPFile0, ///< smart password policy (a - ///< combination of \e zipsmCPassDir and - ///< \e zipsmCPFile0) - zipsmSmartAdd = - zipsmNotCompSmall | zipsmCheckForEff, ///< smart adding (a combination - ///< of \e zipsmNotCompSmall and - ///< \e zipsmCheckForEff) - zipsmSafeSmart = - zipsmSmartPass | zipsmNotCompSmall, ///< safe smart (smartest without - ///< checking for efficiency) - zipsmSmartest = zipsmSmartPass | zipsmSmartAdd, ///< smart at its best - - zipsmInternal01 = 0xf000 ///< for internal use only - - }; - - /* - Add a new file to the archive. You can set the callback functor with - #SetCallback. \param info see CZipAddNewFileInfo \return \c if it - returns false then the file was not added, but the internal state allows - you to add other files (which is not possible after throwing an - exception) - \note - - If you abort while adding a file in a non-disk-spanning archive, the - added data will be removed from the archive - - Throws exceptions. - \see SetCallback - \see AddNewFile(LPCTSTR, LPCTSTR, int, int, unsigned long) - \see AddNewFile(LPCTSTR, int, bool, int, unsigned long) - \see AddNewFile(CZipMemFile&, LPCTSTR, int, int, unsigned - long) - */ - bool AddNewFile(CZipAddNewFileInfo& info); - - // \see AddNewFile(CZipAddNewFileInfo& ); the parameters are equivalent to - // CZipAddNewFileInfo member variablesd - - bool AddNewFile(LPCTSTR lpszFilePath, - int iComprLevel = -1, - bool bFullPath = true, - int iSmartLevel = zipsmSafeSmart, - unsigned long nBufSize = 65536); - - /* - \see AddNewFile(CZipAddNewFileInfo& ); the parameters are equivalent to - CZipAddNewFileInfo member variables - */ - bool AddNewFile(LPCTSTR lpszFilePath, - LPCTSTR lpszFileNameInZip, - int iComprLevel = -1, - int iSmartLevel = zipsmSafeSmart, - unsigned long nBufSize = 65536); - - /* - \see AddNewFile(CZipAddNewFileInfo& ); the parameters are equivalent to - CZipAddNewFileInfo member variables - */ - bool AddNewFile(CZipMemFile& mf, - LPCTSTR lpszFileNameInZip, - int iComprLevel = -1, - int iSmartLevel = zipsmSafeSmart, - unsigned long nBufSize = 65536); - - /* - Add a new file to the opened zip archive. The zip archive cannot be - an existing disk spanning archive (existing at the moment of opening - archive), because modifying such an archive is not possible (at least not - with this version ). - \param header - The structure that provides additional information about the added file. - The following fields are valid: - - \e m_uMethod - file compression method; can be 0 (storing) or - Z_DEFLATE (deflating) otherwise Z_DEFLATE is assumed - - \e m_uModDate, \e m_uModTime - Use CZipFileHeader::SetTime to set - them. If \e lpszFilePath is not NULL this fields are overwritten and updated - automatically. See CZipFileHeader::SetTime - - \e m_uExternalAttr - Attributes of the file. - If \e lpszFilePath is not NULL this field is overwritten and updated - automatically. Use #SetFileHeaderAttr to set them. See #SetFileHeaderAttr. - - \e m_szFileName - A filename (may be with path) to be stored inside - archive to represent this file. See CZipFileHeader::SetFileName - - \e m_szComment - A file comment. See CZipFileHeader::SetComment - - \e m_pExtraField - LOCAL extra field, use #SetExtraField after opening - a new file, but before closing it to set the not local extra field - in the header in the central directory. See #SetExtraField
- Other fields are ignored - they are updated automatically. - If the function returns \c true, \link #GetSystemCompatibility - system compatibility \endlink for this object is - set to the correct value (the same as #m_iArchiveSystCompatib), - additionally if \e lpszFilePath was not NULL, the attributes and - the time fields are filled with information retrieved from - the file pointed by \e lpszFilePath. - \param iLevel - The level of compression (-1, 0 - 9). - The are several preset values for the compression level: - - Z_DEFAULT_COMPRESSION : -1 (equals 6) - - Z_NO_COMPRESSION : 0 - - Z_BEST_SPEED : 1 - - Z_BEST_COMPRESSION : 9 - \param lpszFilePath - The path to the file to retrieve date stamp and attributes from. - These values are stored inside the archive. - \param uInternal - for internal use only - - \return \c false in the following cases: - - the \e lpszFilePath is not NULL and the file attributes and data was not - correctly retrieved - - a file is already opened for extraction or compression - - archive is an existing disk span archive - - maximum file count inside archive already reached (65536) - \note Throws exceptions. - -*/ - bool OpenNewFile(CZipFileHeader& header, - int iLevel = Z_DEFAULT_COMPRESSION, - LPCTSTR lpszFilePath = NULL, - DWORD uInternal = 0); - - /* - Compress the contents of the buffer and write it to a new file. - \param pBuf - the buffer containing the data to be compressed and written - \param iSize - the number of bytes to be written from the buffer - \return \c false if the new file hasn't been opened yet - \note Throws exceptions. - \see OpenNewFile -*/ - bool WriteNewFile(const void* pBuf, DWORD iSize); - - /* - Set the extra field in the central directory of the currently opened file. - Must be used after opening a new file in the archive, but before closing it - To set the local extra field, set it in the CZipFileHeader structure passed - as the argument to the #OpenNewFile - \param pBuf - the bufer with the data to be copied - \param iSize - the size of the extra field in the buffer - \see OpenNewFile -*/ - void SetExtraField(const char* pBuf, WORD iSize); - - /* - Close the new file in the archive. - \return \c false if there is no new file opened - \param bAfterException - it will close the new file without writing anything (call it also - with this parameter set to \c true after an exception other than - CZipException::abortedSafely was thrown from one of #AddNewFile functions) - \note Throws exceptions. - \see OpenNewFile -*/ - bool CloseNewFile(bool bAfterException = false); - - /* - Acquire a file with the given index from another archive. - The compressed data of the file from another archive are copied - without decompressing to the current archive. - You can set the callback functor with #SetCallback. - \param zip - an opened archive to get the file from (must not be multi-disk) - \param uIndex - a zero-based index of the file to get from the \e zip archive - \param iReplaceIndex the same as CZipAddNewFileInfo::m_iReplaceIndex - \param bKeepSystComp - if \c false, which is default, then the file from \e zip archive - system compatibility is converted to the current archive system - compatibility (if they differ) - \return \c false if the operation could not be performed (either of archives - is closed, a file inside either of archives is opened, \e zip archive is - multi-disk or the current archive is an existing multi-disk archive) \note - Throws exceptions
(when an exception is thrown, you may need to call - #CloseNewFile with \e bAfterException set to \c true, to make the archive - reusable). \note it is safe to abort the action (by returning false from the - callback call) in non-disk spanning archive and when no replacing is taking - place (the file not entirely added is removed from the archive) \see - SetCallback \see GetFromArchive(CZipArchive& , CZipWordArray &, bool) \see - GetFromArchive(CZipArchive& , CZipStringArray &, bool) \see FindMatches \see - SetAdvanced -*/ - bool GetFromArchive(CZipArchive& zip, - WORD uIndex, - int iReplaceIndex = -1, - bool bKeepSystComp = false) - { - - m_info.Init(); - bool bRet; - try { - bRet = GetFromArchive(zip, - uIndex, - iReplaceIndex, - bKeepSystComp, - GetCallback(cbGetFromArchive)); - } catch (...) { - m_info.ReleaseBuf(); - throw; - } - m_info.ReleaseBuf(); - if (bRet && m_bAutoFlush) - Flush(); - - return bRet; - } - - /* - Acquire files with the given indexes from another archive. - \param aIndexes - an array of zero-based indexes of the files inside the \e zip archive - - \see GetFromArchive(CZipArchive& , WORD, int, bool) - - \note - - To get files which filenames match a specified pattern, use #FindMatches - function - */ - bool GetFromArchive(CZipArchive& zip, - CZipWordArray& aIndexes, - bool bKeepSystComp = false); - - /* - Acquire files with the given indexes from another archive. - \param aNames - an array of filenames inside the \e zip archive; - \see GetFromArchive(CZipArchive& , WORD, int, bool) - \see EnableFindFast - - \note - - Set the case-sensitivity with #SetCaseSensitivity - - Enables FindFast if not enabled - */ - - bool GetFromArchive(CZipArchive& zip, - CZipStringArray& aNames, - bool bKeepSystComp = false) - { - CZipWordArray indexes; - zip.GetIndexes(aNames, indexes); - return GetFromArchive(zip, indexes, bKeepSystComp); - } - - /* - Get indexes of the files stored int \e aNames array and put them into \e - aIndexes \param aNames an array of filenames inside the archive; \param - aIndexes an array of indexes to be build \note - - Set the case-sensitivity with #SetCaseSensitivity - - Enables FindFast if not enabledd - */ - void GetIndexes(const CZipStringArray& aNames, CZipWordArray& aIndexes); - - /* - Extract the file from the archive. You can set the callback functor with - #SetCallback. The argument \e lpszNewName may point to the full path and is - influenced by \e bFullPath argument (if \e lpszNewName contains drive - specification then it is removed) \param uIndex the index of the file to - extract \param lpszPath \verbatim The PATH only to extract the file to. May - not be NULL. If you wish to use UNC path you need to replace \\\\ at the - beginning of UNC path with \\\\?\UNC\ . \endverbatim \param bFullPath
- - if \c true, then extract with the full path - in this case the - resulting file path is \e lpszPath plus the path stored in the archive or - plus \e lpszNewName if \e lpszNewName is not NULL.
- - if \c false, the destination file path is \e lpszPath + \e the - filename only extracted from the path stored in the archive or from \e - lpszNewName if \e lpszNewName is specified;
if #m_szRootPath is set - previously with #SetRootPath then to \e lpszPath is added the path stored in - the archive (or \e lpszNewName if \e lpszNewName is specified) that has - removed the beginning that equals #m_szRootPath (if there is no common - beginning then is behaves like #m_szRootPath was empty) \param lpszNewName - The new name of the file after extraction. - If NULL the original filename stored in the archive is used. - May point to the full path but, if \e bFullPath is \c false, only - the filename is extracted from this argument, \param nBufSize the size of - the buffer used while file operations \return \c true if successful \note - - To extract files which filenames match a specified pattern, use - #FindMatches function - - Throws exceptions. - \see SetCallback - \see ExtractFile(WORD, CZipMemFile&, DWORD) - \see FindMatches -*/ - bool ExtractFile(WORD uIndex, - LPCTSTR lpszPath, - bool bFullPath = true, - LPCTSTR lpszNewName = NULL, - DWORD nBufSize = 65536); - - /* - The same as #ExtractFile(WORD , LPCTSTR , bool , LPCTSTR , DWORD - ) but instead to a physical file, this function decompress the - data into CZipMemFile object \note - - if you pass CZipMemFile object already with data, its contents are NOT - overwirtten, but the decompressed data is appended at the end - - if you try to extract a directory, the function will return \c false - */ - bool ExtractFile(WORD uIndex, CZipMemFile& mf, DWORD nBufSize = 65536); - - /* - Open the file with the given index in the archive for extracting. - Not successful opening the file doesn't lock the whole archive, so - you can try to open another one (after catching an exception if it was - thrown). Throw exception CZipException::badPassword if the password - was not set for the encrypted file. - \param uIndex - the index of the file - \return \c true if successful - \note Throws exceptions. -*/ - bool OpenFile(WORD uIndex); - - /* - Decompress currently opened file to the buffer. - \param pBuf - buffer to receive data - \param iSize - the size of the buffer - \return the number of bytes read - \see OpenFile - \note Throws exceptions. -*/ - DWORD ReadFile(void* pBuf, DWORD iSize); - - /* - Test the file with the given index for the integrity. You can set the - callback functor with #SetCallback. The method throws exceptions but - performs all the necessary cleanup before, so that the next file can be - tested after catching the exception. \param uIndex index of the file to test - \param uBufSize - the size of the buffer used during extraction - \return \c false if the incorrect action has been taken by - the user or the programmer (it is when #OpenFile or #GetFileInfo returned \c - false or \e uBufSize is 0). If the file didn't passed the test or there was - a disk I/O error or the password supplied was incorrect, an exception is - thrown. \note Throws exceptions. \see SetCallbackd -*/ - bool TestFile(WORD uIndex, DWORD uBufSize = 65536); - - /* - Perform the necessary cleanup after an exception was thrown - while testing the archive so that next files in the archive can be tested. - Called by #TestFile. Does not remove the file headers - information from the central directory. - \see TestFile - \see CZipCentralDir::Clear -*/ - void CloseFileAfterTestFailed(); - - /* - Get the local extra filed of the currently opened - for extraction file in the archive. - \param pBuf - the buffer to receive the data - \param iSize - the size of the buffer - \return If \e pBuf is NULL or iSize is 0, returns the size of the local - extra field. Returns -1 if there is no file opened for the extraction. -*/ - int GetLocalExtraField(char* pBuf, int iSize) const; - - /* - The same as CZipArchive::CloseFile(LPCTSTR), but additionally - closes \e file. - \param file - OPENED CZipFile structure of the extracted file - \return - \note Throws exceptions. - \see CZipArchive::CloseFile(LPCTSTR) -*/ - int CloseFile(CZipFile& file); - - /* - Close the file opened for extraction in the archive and copy its date and - attributes to the file pointed by \e lpszFilePath - \param lpszFilePath - Points to the path of the file to have the date and attributes - information updated. \param bAfterException Set to \c true to close the file - inside archive after an exception has been thrown, to allow futher - operations on the archive. \warning Close the file pointed by \e - lpszFilePath before using this method, because the system may not be able to - retrieve information from it. \return
- - "1" = ok - - "-1" = some bytes left to uncompress - probably due to a bad password or - corrupted archive - - "-2" = setting extracted file date and attributes was not successful - \note Throws exceptions. -*/ - int CloseFile(LPCTSTR lpszFilePath = NULL, bool bAfterException = false); - - /* - Delete the file from the archive with the given index. - You can set the callback functor with #SetCallback. - If you plan to delete more than one file, use one of DeleteFiles - functions rather than calling DeleteFile successively, because these - functions are optimized for deleting multiple files \param uIndex a - zero-based index \note Throws exceptions. \see SetCallback \see - DeleteFiles(CZipWordArray&) \see DeleteFiles(const CZipStringArray&) \see - FindMatches -*/ - void DeleteFile(WORD uIndex); - - /* - Delete files from the archive. - You can set the callback functor with #SetCallback. - Sorts \e aIndexes array in an ascending order. - \param aIndexes - an array of zero-based indexes of the files inside the archive - \note - - To remove files which filenames match a specified pattern, use - #FindMatches function - - Throws exceptions. - \see SetCallback - \see DeleteFile - \see DeleteFiles(const CZipStringArray& ) - \see FindMatches -*/ - void DeleteFiles(CZipWordArray& aIndexes); - - /* - Delete files from the archive. - You can set the callback functor with #SetCallback. - \param aNames - an array of filenames inside the archive; - \note - - Set the case-sensitivity with #SetCaseSensitivity - - Enables FindFast if not enabled - - Throws exceptions. - \see SetCallback - \see DeleteFile - \see DeleteFiles(CZipWordArray&) - \see EnableFindFast -*/ - void DeleteFiles(const CZipStringArray& aNames); - - /** - Set the global comment in the archive. - \param lpszComment - the file comment - \return \c false if the archive is closed or if it is an existing disk - spanning archive \note Throws exceptions. -*/ - bool SetGlobalComment(LPCTSTR lpszComment); - - /** - \return the global comment or an empty string if the archive is closed -*/ - CZipString GetGlobalComment() const; - - /** - Set the comment of the file with the given index inside the archive. - \param uIndex - zero-based index of the file in the archive - \param lpszComment - a comment to add - \return \c false if the comment change is impossible - \note Throws exceptions. -*/ - bool SetFileComment(WORD uIndex, LPCTSTR lpszComment); - - /** - \return the path of the currently opened archive volume -*/ - CZipString GetArchivePath() const; - - /** - \return
- - a one-based number of the current disk - - 0 if there is no current disk (the archive is closed) - \note Useful mostly while working with the disk-spanning archive in creation - to find out how many disks were already created. To find out how many disks - are in an existing disk-spanning archive, use the function - #GetCentralDirInfo -*/ - int GetCurrentDisk() const; - - /* - Return the disk spanning mode of the current archive. - - \return
- - -2 - existing TD mode compatible disk spanning archive - - -1 - existing PKZIP compatible - - 0 - no disk spanning - - 1 - PKZIP compatible in creation - - 2 - TD compatible in creation - - \see \ref PKSpan, \ref TDSpan - -*/ - int GetSpanMode() const - { - return m_storage.m_iSpanMode * m_storage.IsSpanMode(); - } - - /** - case-sensitivity values used as argument \e iCaseSensitive in #FindFile - */ - enum FFCaseSens - { - ffDefault, ///< use the default case-sensitivity as set with - ///< #SetCaseSensitivity function; - ///< if CZipCentralDir::m_findarray was build before with a different - ///< case-sensitivity, it is rebuild again, if it hasn't been build so - ///< far, it is build now with the default case-sensitivity - ffCaseSens, ///< perform a case-sensitive search (if the \c CZipArchive - ///< is non-case-sensitive, - ///< a less effective search is perfomed); does not rebuild - ///< CZipCentralDir::m_findarray, but if the array hasn't been built - ///< yet, it is build now as \b non-case-sensitive (you can use \c - ///< SetCaseSensitivity(true) and then #ffDefault to build it as - ///< case-sensitive) - ffNoCaseSens ///< perform a non-case-sensitive search (if the \c - ///< CZipArchive is case-sensitive, a less effective search - ///< is performed); does not rebuild - ///< CZipCentralDir::m_findarray, but if the array hasn't - ///< been built yet, it is build now as \b case-sensitive - ///< (you can use \c SetCaseSensitivity(false) and then - ///< #ffDefault to build it as non-case-sensitive) - - }; - - /** - Find the file in the archive. - If the archive wasn't opened with CZipCentralDir::m_bConvertAfterOpen set to - \c true, this function automatically convert all the filenames with the - function CZipCentralDir::ConvertAll and set - CZipCentralDir::m_bConvertAfterOpen to \c true. This function requires \link - CZipCentralDir::m_bFindFastEnabled FindFast \endlink feature enabled. \param - lpszFileName the name of the file to be found in the archive; must be with - path unless you set \e bFileNameOnly to \c true. Use path separators the - same as they are for your system - (\e "\" for Windows and \e "/" for Unix/Linux) - \param iCaseSensitive can be one of #FFCaseSens values - \param bFileNameOnly - if \c true, the function tries to find a filename without a path (a less - effective search is performed); if you wish to find a directory name, do not - end it with the path separator, which is required if you set \e bFileName to - \c false \return
- - the index of the file found - - -1 if there is no such a file in the archive - \see CZipCentralDir::FindFileNameIndex - \see EnableFindFast - \see CZipCentralDir::ConvertAll - \see SetConvertAfterOpen -*/ - int FindFile(LPCTSTR lpszFileName, - int iCaseSensitive = ffDefault, - bool bFileNameOnly = false); - - /** - Get the info of the file with the given index. - \param fhInfo - the structure to receive info - \param uIndex - a zero-based index of the file inside the archive - \return \c true if successful -*/ - bool GetFileInfo(CZipFileHeader& fhInfo, WORD uIndex) const; - - /** - \param bOnlyFiles - if \c true, the directories are not inluded in a total count; - default is \c false - \return the number of files in the archive -*/ - int GetCount(bool bOnlyFiles = false) const - { - int iTotalCount = m_centralDir.m_headers.GetSize(); - if (bOnlyFiles) { - int iCount = 0; - for (int i = 0; i < iTotalCount; i++) - if (!m_centralDir.m_headers[i]->IsDirectory()) - iCount++; - return iCount; - } else - return iTotalCount; - } - - /** - values used in #Close function as parameter \e iAfterException - */ - enum CloseAfterException - { - afNoException, ///< normal close, no exception was thrown before by - ///< CZipArchive object - afAfterException, ///< an exception has been thrown, don't write any - ///< data but perform necessary cleaning to reuse - ///< CZipArchive object for another archive - afWriteDir ///< the same as above, but write the central directory end - ///< structure to the archive, so that we can save at least - ///< the files that have been added properly and maybe try to - ///< repair the archive later - }; - - /** - Close the archive. - \param iAfterException - one of #CloseAfterException enum values - \param bUpdateTimeStamp - if \c true, set the modification date of the zip file to the date of the - newest file in the archive; in disk-spanning mode only the last archive file - will have the time stamp updated; you can use this option even without - performing any additional processing on the archive, just open and close it - \note Throws exceptions if \e iAfterException is different from \c - afAfterException -*/ - void Close(int iAfterException = afNoException, - bool bUpdateTimeStamp = false); - - /** - Test if the archive is closed (a whole or the current volume only) - \param bArchive
- - \c true: test for the whole archive - - \c false: test for the volume file only - - \return \c true if closed -*/ - bool IsClosed(bool bArchive = true) const; - - /** - Write the central directory to the archive and flushes the internal - buffers to the disk, so that the archive is finalized on the disk, but - you can still modify it. Use it after opening (or creating) and modifying - the archive if you want to prevent the loss of the data you've compressed - so far in case of the program crash.
If you use it on a disk - spanning archive in creation it will not be closed, but its state will be - changed from "archive in creation" to "an existing span archive". Use it - when you finish adding files to the disk-spanning archive and want to - begin extracting or testing it. It follows that you can call it only - once in this case. However, if after finalizing the disk spanning archive - it turns out that it is one disk only, it is converted to a normal - archive and you can use it as such. If you want to know what is the state - of the archive after using this function call #GetSpanMode. \note - - Cannot be used on existing disk spanning archives (they are not - modifable anyway) - - If you have an archive with a huge central directory, it'll influence - the perfomance calling this function without a reason. - - Throws exceptions. - \see GetSpanMode - \see SetAutoFlush - \see GetAutoFlush - - */ - void Flush(); - - /** - Set the CZipArchive object to call #Flush after each operation that - modifies the archive (adding a new file, deleting file(s), modifying the - global or a file comment). It is useful when we want to prevent the loss - of data in case of the program crash - the zip file will be then - finalized on the disk. Use it after opening the archive. \note - - You can set AutoFlush only for non-disk spanning archives, however you - can call #Flush once for a disk-spanning archive in creation. - - If you have an archive with a huge central directory, setting - Auto-Flush will influence the performance. \see Flush \see GetAutoFlush - */ - void SetAutoFlush(bool bAutoFlush = true); - - /** - return the current #m_bAutoFlush value - \see Flush - \see SetAutoFlush - */ - bool GetAutoFlush() const { return m_bAutoFlush; } - - /** - Return the system compatibility of the current archive. - System compatibility value for the single file in the archive - (represented by CZipFileHeader) influences file attributes conversion - (the file attributes are defined differently across the platforms). - When opening an existing archive CZipArchive assumes the system - compatibility of the whole archive to be the same as of the first file in - the archive (if present). In other cases the current system value is assumed - which is taken from ZipPlatform::GetSystemID during creating or opening an - archive \remark If the existing archive during opening is empty, - ZipPlatform::GetSystemID is assumed to be the default system for the files - that will be added to the archive - \return - one of the enum values defined in \link ZipCompatibility::ZipPlatforms - ZipCompatibility.h \endlink - \see ZipCompatibility::ZipPlatforms - \see ZipPlatform::GetSystemID - \see CZipFileHeader::GetSystemCompatibility -*/ - int GetSystemCompatibility() const { return m_iArchiveSystCompatib; } - - /** - Set the system compatibility of the archive. By default it is set to the - current system value (the one returned by ZipPlatform::GetSystemID() - function). Use it after opening the archive, but before adding a new file or - using SetFileHeaderAttr() function \param iSystemComp can be one of - ZipCompatibility::ZipPlatforms values \return return \c false if the value - \e iSystemComp is not supported (ZipCompatibility::IsPlatformSupported - returns \c false for the value) or it is not possible to set it right now -*/ - bool SetSystemCompatibility(int iSystemComp); - - /** - Set the attributes for CZipFileHeader structure to be used - in #OpenNewFile method as an argument. - This special procedure is taken, because the system compatibility must - be set for CZipFileHeader prior to the value, which must be identical to - the return value of #GetSystemCompatibility method. - \param header - the structure to have attributes set - \param uAttr - attributes to set - \note Throws exceptions if the archive system or the current system - is not supported by the ZipArchive library. - \see GetSystemCompatibility -*/ - void SetFileHeaderAttr(CZipFileHeader& header, DWORD uAttr); - - /** - A helper for a various purposes (needed e.g. by the program that - cracks the zip archives password) - \return the pointer to the static CRC table in the zlib library -*/ - static const DWORD* GetCRCTable() { return get_crc_table(); } - - /** - Return the underlying archive storage medium. - \warning A method for a very advanced use - you normally never need it. - \return the pointer to #m_storage - \see CZipStorage -*/ - CZipStorage* GetStorage() { return &m_storage; } - - /* - Set #m_bDetectZlibMemoryLeaks value. - \param bDetect - \note Use before opening a file in the archive. - \see m_bDetectZlibMemoryLeaks -*/ - void SetDetectZlibMemoryLeaks(bool bDetect) - { - if (m_iFileOpened != nothing) { - TRACE(_T("CZipArchive::SetDetectZlibMemoryLeaks: Set it before ") - _T("opening a file in the archive")); - return; - } - m_bDetectZlibMemoryLeaks = bDetect; - } - - /** - Set CZipCentralDir::m_bConvertAfterOpen value. - The default value is \c true. - Setting this value to \c false is generally not effective and is intended - only for quick and short operations on archives with lots of files inside - e.g. open archive, make an operation on a file which index you already know - and close the archive - using #FindFile function already makes setting this - value to \c false inefficient - \param bConvertAfterOpen - \note Use before opening the archive. - \see CZipCentralDir::m_bConvertAfterOpen -*/ - void SetConvertAfterOpen(bool bConvertAfterOpen) - { - if (!IsClosed()) { - TRACE(_T("CZipArchive::SetConvertAfterOpen: Set it before opening ") - _T("the archive")); - return; - } - m_centralDir.m_bConvertAfterOpen = bConvertAfterOpen; - } - - /** - Enable fast finding by the file name of the files inside the archive. - Set CZipCentralDir::m_bFindFastEnabled to \c true, which is required by - #FindFile. #FindFileIt is called by #FindFileif necessary. It builds - CZipCentralDir::m_findarray with the default case-sensitivity (set with - #SetCaseSensitivity) \note Call it only after opening the archive. \param - bEnable \see CZipCentralDir::m_bFindFastEnabled \see FindFile -*/ - void EnableFindFast(bool bEnable = true); - - /* - After you enable FindFast feature with #EnableFindFast, you can retrieve - how the files are sorted in CZipCentralDir::m_findarray (you can use it - in your own program if you need to display the sorted list and do not - want to duplicate data) - \param iFindFastIndex - index in CZipCentralDir::m_findarray (not necessary the same as the - one you'd pass to #GetFileInfo); the number of items in this array is the - same as the number of files in the archive (you can retrieve it with - #GetCount) - \return - index of the file in central directory (now you can call - #GetFileInfo to get the information); if the value is \c -1 then you have - not called #EnableFindFast before or the archive is closed or the \e - iFindFastIndex is out of range) - */ - int GetFindFastIndex(int iFindFastIndex) const - { - if (IsClosed()) { - TRACE(_T("CZipArchive::GetFindFastIndex: ZipArchive not yet ") - _T("opened.\n")); - return -1; - } - - return m_centralDir.GetFindFastIndex(iFindFastIndex); - } - - /** - Set a temporary path used when compressing files and #zipsmCheckForEff - is specified as an argument in #AddNewFile and the disk spanning archive - is in creation. - \param lpszPath set it to NULL to clear the temporary path and let the - library figure it out (it uses the system temporary directory if - possible) \param bForce if \e lpszPath is not \c NULL and this parameter - set to \c true the directory is created if it doesn't exists (if the - given directory does not exists , the temporary file will not be created) - \see AddNewFile - \see Smartness - \see GetTempPath - */ - void SetTempPath(LPCTSTR lpszPath = NULL, bool bForce = true); - - /** - enum values used in #PredictFileNameInZip - */ - enum Predict - { - - prDir, ///< if an argument is a directory, add a separator at the end - prFile, ///< treat the argument as a common file - prAuto ///< treat the argument as a directory only if it has a path - ///< separator at the end - - }; - - /** - Given the file path in the form it would be passed to #AddNewFile - as \e lpszFilePath argument, the function returns the file name - as it would be stored in the archive.
- The function takes into account the root path set with #SetRootPath. You - can use this function to eliminate duplicates before adding a list of - files.
- \param lpszFilePath - the file path as it would be passed to #AddNewFile function - \param bFullPath - the same as \e bFullPath in #AddNewFile - \param iWhat - one of #Predict values to treat \e lpszFilePath correctly - \param bExactly - if \c true, return the filename exactly as it would look inside the - archive i.e. convert slash to backslash, and perform ANSI->OEM - conversion; otherwise return the filename with the path separators that - are used by default in the system - \return a modified file path - */ - CZipString PredictFileNameInZip(LPCTSTR lpszFilePath, - bool bFullPath, - int iWhat = prAuto, - bool bExactly = false) const; - - /* - Check if the filename will be duplicted in the archive, if added to the - archive in the given form \param bFileNameOnly if \c true, assume that - the filename is duplicated if only the filename (no path) is the same (\e - bFullPath is ignored), otherwise the whole filename with path is taken - into account - \b Default: \c false - The rest of the parameters have the same meaning as in - #PredictFileNameInZip. - \return the zero-based index of the file in the archive that the - filename would be duplicated, or -1, if the filename is unique - */ - int WillBeDuplicated(LPCTSTR lpszFilePath, - bool bFullPath, - bool bFileNameOnly = false, - int iWhat = prAuto); - - /** - Predict the full filename with path after extraction. The parameters - (except for the first) are in the form you'd pass to the - #ExtractFile(WORD , LPCTSTR , bool , LPCTSTR , DWORD ) function. - The function takes into account the root path set with #SetRootPath. - \param lpszFileNameInZip - the filename of the file inside the archive (may be \c NULL if - lpszNewName is not \c NULL) \param lpszPath \param bFullPath \param - lpszNewName \return a predicted file path - */ - CZipString PredictExtractedFileName(LPCTSTR lpszFileNameInZip, - LPCTSTR lpszPath, - bool bFullPath, - LPCTSTR lpszNewName = NULL) const; - - /* - Return the current value of #m_szTempPath - \return CZipString - */ - CZipString GetTempPath() const { return m_szTempPath; } - - /** - Function used in conjunction with #m_szRootPath to trim paths in - #AddNewFile and #ExtractFile \param zpc \see SetRootPath - -*/ - CZipString TrimRootPath(CZipPathComponent& zpc) const; - - /* - Remove \e lpszBeginning from the beginning of the \e szPath. Both - argument are considered to be paths so they matches up to the path - separator. - \param lpszBeginning - \param szPath - \param pCompareFunction (see: #m_pZipCompare) - \return \c true if the path beginning was removed - */ - static bool RemovePathBeginning(LPCTSTR lpszBeginning, - CZipString& szPath, - ZIPSTRINGCOMPARE pCompareFunction); - - /* - Set the default archive case-sensitivity. Affects the following - functions: - - #FindFile - - #FindMatches - - #EnableFindFast - - #TrimRootPath - - #DeleteFiles - \param bCaseSensitive - the default CZipArchive case-sensitivity depends on the system and is - set as follows: - - on Windows: \c false
- - on Linux: \c true - \note Set it before using one of the functions above or leave it as it - is by default; - */ - - void SetCaseSensitivity(bool bCaseSensitive) - { - m_bCaseSensitive = bCaseSensitive; - m_pZipCompare = GetCZipStrCompFunc(bCaseSensitive); - } - - /** - Return the central directory information. - \see GetCentralDirSize - */ - void GetCentralDirInfo(CZipCentralDir::Info& info) const; - - /** - Get the central directory size. - \see CZipCentralDir::GetSize - \see GetCentralDirInfo - */ - DWORD GetCentralDirSize(bool bWhole = true) const - { - return m_centralDir.GetSize(bWhole); - } - - /** - return \c true if the archive cannot be modified, because it is an - existing disk spanning archive or it was opened with #zipOpenReadOnly - */ - bool IsReadOnly() { return m_storage.IsReadOnly(); } - - /* - If you set \e bIgnore to \c true, CRC is not checked for the files being - tested or extracted. This method is useful when working with Java - TM Archives (jar). The CRC is checked by - default. You can use this function on an opened or closed archive. - */ - void SetIgnoreCRC(bool bIgnore = true) { m_bIgnoreCRC = bIgnore; } - - /** - A class used in wildcard pattern matching. - This class is based on code by J. Kercheval, created 01/05/1991 - and available as a public domain at http://www.snippets.org. - */ - class ZIP_API CWildcard - { - public: - enum Match - { - matchNone, ///< for internal use - matchValid, ///< valid match - matchEnd, ///< premature end of pattern string - matchAbort, ///< premature end of text string - matchRange, ///< match failure on [..] construct - matchLiteral, ///< match failure on literal match - matchPattern ///< bad pattern - }; - - enum Pattern - { - patternEmpty = -4, ///< [..] construct is empty - patternClose, ///< no end bracket in [..] construct - patternRange, ///< malformed range in [..] construct - patternEsc, ///< literal escape at end of pattern - patternValid, ///< valid pattern - }; - - /* - Match the pattern against the string \e lpszText - A match means the entire string \e lpszText is used up in matching. - \param lpszText - the string to match against - \param iRetCode - if not \c NULL, set to one of #Match values indicating the - return code \return \c true if \e lpszText matches the pattern. \see - SetPattern - */ - bool IsMatch(LPCTSTR lpszText, int* iRetCode = NULL); - - /* - \param lpszPattern - \return \c true if \e lpszPattern has any special wildcard - characters. - */ - static bool IsPattern(LPCTSTR lpszPattern); - - /* - Test the pattern for validity. - \param lpszPattern - the pattern to test - \param iErrorType - if not \c NULL, set to one of #Pattern values indicating the - return code \return \c true if \e lpszPattern is a well formed - regular expression according to the CWildcard class syntax (see - #SetPattern) - */ - static bool IsPatternValid(LPCTSTR lpszPattern, int* iErrorType = NULL); - - /* - Match the pattern \e lpszPattern against the string \e lpszText - A match means the entire string \e lpszText is used up in matching. - \param lpszPattern - see #SetPattern - \param lpszText - the string to match against - \return - one of #Match values - */ - static int Match(LPCTSTR lpszPattern, LPCTSTR lpszText); - - CWildcard() {} - /* - Initialize the pattern. - \see SetPattern - */ - CWildcard(LPCTSTR lpszPattern, bool bCaseSensitive) - { - SetPattern(lpszPattern, bCaseSensitive); - } - virtual ~CWildcard() {} - - /* - Set the pattern to \e lpszPattern. - \param lpszPattern - In the pattern string: - - * matches any sequence of characters(zero or more) - - ? matches any character - - [SET] matches any character in the specified set, - - [!SET] or[^SET] matches any character not in the specified set. - A set is composed of characters or ranges; a range looks like - character hyphen character(as in 0 - 9 or A - Z).[0 - 9a - zA - - Z_] is the minimal set of characters allowed in the[..] pattern - construct. Other characters are allowed(ie. 8 bit characters) if your - system will support them. - \note To suppress the special syntactic significance of any of - []*?!^-\, - and match the character exactly, precede it with a \ - */ - void SetPattern(LPCTSTR lpszPattern, bool bCaseSensitive) - { - m_szPattern = lpszPattern; - m_bCaseSensitive = bCaseSensitive; - if (!bCaseSensitive) - m_szPattern.MakeLower(); - } - operator LPCTSTR() { return (LPCTSTR)m_szPattern; } - - protected: - bool m_bCaseSensitive; - static int MatchAfterStar(LPCTSTR p, LPCTSTR t); - CZipString m_szPattern; - }; - - /** - This function finds the indexes of the files, which filenames match the - specified pattern and stores these indexes in the array. The indexes can - be used then e.g. in deleting (CZipArchive::DeleteFiles) or extracting - files (CZipArchive::ExtractFile). - \param lpszPattern - the pattern to match (see CWildcard::SetPattern on how to build the - pattern). The case-sensitivity of the pattern is set to the global - archive case-sensitivity (set with #SetCaseSensitivity) \param ar the - array which will contain the indexes of the files which filenames match - the pattern; the contents of the array are NOT clearead, but the indexes - are appended to it \param bFullPath
- - if \c true, match the filename with path (if present) of the file - (if the file is a directory, end it with the path separator or use a - pattern that will recognize it) - - otherwise match only the name of the file (if the file is a - directory, do not end it with the path separator) - */ - void FindMatches(LPCTSTR lpszPattern, - CZipWordArray& ar, - bool bFullPath = true) const; - - /** - Change the name of the file with the given index. - \param uIndex - zero-based index of the file - \param lpszNewName - new name for the file - \return - \note Throws exceptions. - \see SetAdvanced - */ - bool RenameFile(WORD uIndex, LPCTSTR lpszNewName); - - /** - If \c true, the drive letter is removed from the filename stored inside - the archive when adding a new file to the archive. It affects - #AddNewFile, #ExtractFile, #PredictFileNameInZip, - #PredictExtractedFileName, #WillBeDuplicated methods. - - \b Default: \c true - */ - bool m_bRemoveDriveLetter; - - protected: - /** - \param iReplaceIndex index of file to be replaced - \param uTotal the size of the new file to replace existing - \param lpszFileName the filename for callback initialization - */ - void MakeSpaceForReplace(int iReplaceIndex, - DWORD uTotal, - LPCTSTR lpszFileName); - /** - A structure for the internal use only. Clears the password if necessary - and restores it later (also in case of an exception). - */ - struct ZIP_API CZipSmClrPass - { - void ClearPasswordSmartly(CZipArchive* pZip) - { - m_pZip = pZip; - m_szPass = pZip->GetPassword(); - if (!m_szPass.IsEmpty()) - pZip->SetPassword(); - } - ~CZipSmClrPass() - { - if (!m_szPass.IsEmpty()) - m_pZip->SetPassword(m_szPass); - } - CZipString m_szPass; - CZipArchive* m_pZip; - }; - - /** - Holds map of holes and areas to remain when deleting files from the - archive. A structure for the internal use only. - */ - struct ZIP_API CZipDeleteInfo - { - CZipDeleteInfo() - { - m_pHeader = NULL; - m_bDelete = false; - } - CZipDeleteInfo(CZipFileHeader* pHeader, bool bDelete) - : m_pHeader(pHeader) - , m_bDelete(bDelete) - { - } - CZipFileHeader* m_pHeader; - bool m_bDelete; - }; - - /** - Storage for callback functors. A structure for the internal use only. - \see SetCallback - */ - struct ZIP_API CZipClbckStrg - : public CZipMap - { - void Set(CZipActionCallback* pCallback, CallbackType iType) - { - if (pCallback) { - SetAt(iType, pCallback); - } else - RemoveKey(iType); - } - CZipActionCallback* Get(CallbackType iType) - { - CZipActionCallback* pCallback = NULL; - if (Lookup(iType, pCallback)) { - pCallback->m_iType = iType; - return pCallback; - } else - return NULL; - } - }; - - /** - \see CZipClbckStrg - */ - CZipClbckStrg m_callbacks; - - /** - Write central directory calling a callback functor if available - */ - void WriteCentralDirectory(bool bFlush = true); - - /** - Default archive case-sensitivity - \see SetCaseSensitivity - */ - bool m_bCaseSensitive; - - /** - a pointer to the function in CZipString structure, - used to compare elements; can point to Compare, CompareNoCase, - Collate or CollateNoCase function address in CZipString structure - ZIPSTRINGCOMPARE is defined as follows:
typedef int - (CZipString::*ZIPSTRINGCOMPARE)( LPCTSTR ) const; - */ - ZIPSTRINGCOMPARE m_pZipCompare; - - /** - Internal data. - \see CZipInternalInfo - */ - CZipInternalInfo m_info; - - /** - Physical layer of the archive. - \see CZipStorage - */ - CZipStorage m_storage; - - /** - A central directory object. - \see CZipCentralDir - */ - CZipCentralDir m_centralDir; - - /** - The open mode of the current file inside archive. - */ - enum OpenFileType - { - extract = -1, ///< current file opened for extraction - nothing, ///< no file inside archive opened - compress ///< a new file opened for compression - }; - - /** - Takes one of the #OpenFileType enum values. - */ - char m_iFileOpened; - - /** - The current AutoFlush value. - \see Flush - \see SetAutoFlush - \see GetAutoFlush - */ - bool m_bAutoFlush; - - /** - The value set with #SetIgnoreCRC - */ - bool m_bIgnoreCRC; - - /** - The root path to be omitted in #AddNewFile and #ExtractFile functions - from the beginning of the full file path. Set by #SetRootPath - \see TrimRootPath - \see SetRootPath -*/ - CZipString m_szRootPath; - - /** - A temporary path set with #SetTempPath function - \see SetTempPath - \see AddNewFile - \see Smartness - */ - CZipString m_szTempPath; - - /** - Open the archive in the given mode. - Called by #Open(LPCTSTR, int, int) and #Open(CZipMemFile&, int). - \param iMode - an opening mode - \note Throws exceptions. -*/ - void OpenInternal(int iMode); - - /** - The system code of the current archive. All new files in the archive - will be created regarding this value. Can be one of the enum values - defined in \link ZipCompatibility::ZipPlatforms ZipCompatibility.h - \endlink - - \see GetSystemCompatibility - */ - int m_iArchiveSystCompatib; - - /** - Free the memory allocated by the zlib library that hasn't been freed - due to an error in the zlib library (usually never happens). -*/ - void EmptyPtrList(); - - /* - Move the range of data in the archive specified by the \e uStartOffset - and \e uEndOffset by \e uToMove -*/ - void MovePackedFiles(DWORD uStartOffset, - DWORD uEndOffset, - DWORD uMoveBy, - CZipActionCallback* pCallback, - bool bForward = false); - - /** - Remove recently added file (used by AddNewFile) if compressed is larger - than uncompressed or if callback method return \c false. \param - bRemoveAnyway if \c true, do not check for the efficiency, but remove the - file - - */ - bool RemoveLast(bool bRemoveAnyway = false); - - /** - It is used in GetFromArchive public functions and in AddNewFile and the - callback parameter is needed - */ - bool GetFromArchive(CZipArchive& zip, - WORD uIndex, - int iReplaceIndex, - bool bKeepSystComp, - CZipActionCallback* pCallback); - - /** - \return whether the code should continue or not - */ - bool UpdateReplaceIndex(int& iReplaceIndex, LPCTSTR lpszNewFileName); - - /** - \return the currently opened for compression or decompression - file inside the archive NULL if there is no file opened -*/ - CZipFileHeader* CurrentFile(); - - /** - If the parameter \e iErr signalizes a zlib library error, throw - CZipException \param iErr a zlib library error to check \note Throws - exceptions. -*/ - void CheckForError(int iErr); - - /** - Throw a CZipException error. - \param err - the error code - \see CZipException::ZipErrors - \param bZlib - if \c true, treat \e err as a zlib error code and perform the conversion - to the one of CZipException codes. \see CZipException::Throw -*/ - void ThrowError(int err, bool bZlib = false); - - typedef CZipPtrList::iterator CZipPtrListIter; - CZipPtrList m_list; ///< a list holding pointers to the memory areas - ///< allocated by the zlib library - - static void* _zliballoc( - void* opaque, - UINT items, - UINT size); ///< memory allocator called by the zlib library - static void _zlibfree( - void* opaque, - void* address); ///< memory deallocator called by the zlib library - - /* - Specify whether to control memory allocation and freeing by the zlib - library. - \b Default: \c true - \note Set it before opening a file (new or existing) in the archive. - \see SetDetectZlibMemoryLeaks - */ - bool m_bDetectZlibMemoryLeaks; - - /** - Copyright string. - */ - static const TCHAR m_gszCopyright[]; - - /** - \defgroup Cryptography Cryptography - Methods performing data encryption and decryption - and attributes used by them. -*/ - /*@{*/ - - /** - Decode \e uCount bytes from the internal buffer. - \see m_info - \see CZipInternalInfo::m_pBuffer - -*/ - void CryptDecodeBuffer(DWORD uCount); - /** - Encode the internal buffer. - \see m_info - \see CZipInternalInfo::m_pBuffer -*/ - void CryptEncodeBuffer(); - - /** - Encode the character \e c and update \link #m_keys encryption keys \endlink. - -*/ - void CryptEncode(char& c); - /** - Create an encryption header for the new file in the archive. - \param iCrc - A control value. Use the two lower bytes of CZipFileHeader::m_uModTime. - This entails the need for a data description presence at the end of - the compressed data. We cannot use the real CRC now, because we don't - know it yet. \param buf a buffer to receive the header \see CryptCheck -*/ - void CryptCryptHeader(long iCrc, CZipAutoBuffer& buf); - /** - \internal - \return -*/ - DWORD CryptCRC32(DWORD l, char c); - /** - Decode the character \e c and update \link #m_keys encryption keys \endlink. -*/ - void CryptDecode(char& c); - /** - \internal - */ - char CryptDecryptByte(); - - /** - Decrypt the encryption header and check its control value. - The control value depends on the presence of the data descriptor. - \return \c true if the control value is correct - \see CryptCryptHeader -*/ - bool CryptCheck(); - /** - Update \link #m_keys encryption keys \endlink with the given value. -*/ - void CryptUpdateKeys(char c); - /** - Initialize \link #m_keys encryption keys \endlink. -*/ - void CryptInitKeys(); - /** - The archive password. If empty, the new file will not be encrypted. - */ - CZipAutoBuffer m_pszPassword; - - /** - Encryption keys. - The key values are initialized using a supplied encryption password. - \see CryptInitKeys - */ - DWORD m_keys[3]; - - /*@}*/ -}; - -#endif // !defined(AFX_ZIPARCHIVE_H__A7F528A6_1872_4071_BE66_D56CC2DDE0E6__INCLUDED_) \ No newline at end of file diff --git a/src/smpackagee/ZipArchive/ZipArchive.rc b/src/smpackagee/ZipArchive/ZipArchive.rc deleted file mode 100644 index 6d9ca8bc5b..0000000000 --- a/src/smpackagee/ZipArchive/ZipArchive.rc +++ /dev/null @@ -1,109 +0,0 @@ -//Microsoft Developer Studio generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Polish resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_PLK) -#ifdef _WIN32 -LANGUAGE LANG_POLISH, SUBLANG_DEFAULT -#pragma code_page(1250) -#endif //_WIN32 - -#ifndef _MAC -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,3,0,0 - PRODUCTVERSION 2,3,0,0 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "Comments", "http://www.artpol-software.com\0" - VALUE "CompanyName", "Artpol Software\0" - VALUE "FileDescription", "ZipArchive - zip compression library\0" - VALUE "FileVersion", "2.3\0" - VALUE "InternalName", "ZipArchive\0" - VALUE "LegalCopyright", "Copyright © 2000 - 2003 Tadeusz Dracz\0" - VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "ZipArchive.dll\0" - VALUE "PrivateBuild", "\0" - VALUE "ProductName", " ZipArchive library\0" - VALUE "ProductVersion", "2, 3, 0, 0\0" - VALUE "SpecialBuild", "\0" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - -#endif // !_MAC - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE DISCARDABLE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE DISCARDABLE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE DISCARDABLE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // Polish resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/src/smpackagee/ZipArchive/ZipAutoBuffer.cpp b/src/smpackagee/ZipArchive/ZipAutoBuffer.cpp deleted file mode 100644 index 523f61f7d8..0000000000 --- a/src/smpackagee/ZipArchive/ZipAutoBuffer.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipAutoBuffer.cpp $ -// $Archive: /ZipArchive_STL/ZipAutoBuffer.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipAutoBuffer.h" -#include "stdafx.h" -#include - -// #ifdef _DEBUG -// #undef THIS_FILE -// static char THIS_FILE[]=__FILE__; -// #define new DEBUG_NEW -// #endif - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CZipAutoBuffer::CZipAutoBuffer() -{ - m_iSize = 0; - m_pBuffer = NULL; -} - -CZipAutoBuffer::CZipAutoBuffer(DWORD iSize, bool bZeroMemory) -{ - m_iSize = 0; - m_pBuffer = NULL; - Allocate(iSize, bZeroMemory); -} - -CZipAutoBuffer::~CZipAutoBuffer() -{ - Release(); -} - -void -CZipAutoBuffer::Release() -{ - if (m_pBuffer) { - delete[] m_pBuffer; - m_iSize = 0; - m_pBuffer = NULL; - } -} - -char* -CZipAutoBuffer::Allocate(DWORD iSize, bool bZeroMemory) -{ - if (iSize != m_iSize) - Release(); - else { - if (bZeroMemory) - memset(m_pBuffer, 0, iSize); // zerowanie bufora - return m_pBuffer; - } - - if (iSize > 0) { - m_pBuffer = new char[iSize]; - if (bZeroMemory) - memset(m_pBuffer, 0, iSize); // zerowanie bufora - m_iSize = iSize; - } else - m_pBuffer = NULL; - - return m_pBuffer; -} - -CZipAutoBuffer::CZipAutoBuffer(const CZipAutoBuffer& buffer) -{ - m_pBuffer = NULL; - m_iSize = 0; - - if (buffer.m_pBuffer) { - Allocate(buffer.m_iSize); - memcpy(m_pBuffer, buffer.m_pBuffer, buffer.m_iSize); - } -} -CZipAutoBuffer& -CZipAutoBuffer::operator=(const CZipAutoBuffer& buffer) -{ - if (this == &buffer) - return *this; - Release(); - if (buffer.m_pBuffer) { - Allocate(buffer.m_iSize); - memcpy(m_pBuffer, buffer.m_pBuffer, buffer.m_iSize); - } - return *this; -} diff --git a/src/smpackagee/ZipArchive/ZipAutoBuffer.h b/src/smpackagee/ZipArchive/ZipAutoBuffer.h deleted file mode 100644 index 47040792e1..0000000000 --- a/src/smpackagee/ZipArchive/ZipAutoBuffer.h +++ /dev/null @@ -1,67 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipAutoBuffer.h $ -// $Archive: /ZipArchive/ZipAutoBuffer.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipAutoBuffer.h - * Interface for the CZipAutoBuffer class. - * - */ - -#if !defined( \ - AFX_ZIPAUTOBUFFER_H__DEC28C20_83FE_11D3_B7C3_EDEC47A8A86C__INCLUDED_) -#define AFX_ZIPAUTOBUFFER_H__DEC28C20_83FE_11D3_B7C3_EDEC47A8A86C__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "ZipExport.h" -/** - A smart buffer freeing its contents on destruction. -*/ -class ZIP_API CZipAutoBuffer -{ - public: - operator char*() { return m_pBuffer; } -#ifndef __BORLANDC__ - operator const char*() const // Borland seems to have problems with this - { - return m_pBuffer; - } -#endif - - // may produce ambiguity on some compilers - // operator const char*() const - // { - // return m_pBuffer; - // } - const char* GetBuffer() const { return m_pBuffer; } - char* Allocate(DWORD iSize, bool bZeroMemory = false); - void Release(); - DWORD GetSize() const { return m_iSize; } - bool IsAllocated() const { return (m_pBuffer != NULL); } - CZipAutoBuffer(DWORD iSize, bool bZeroMemory = false); - CZipAutoBuffer(); - CZipAutoBuffer(const CZipAutoBuffer& buffer); - virtual ~CZipAutoBuffer(); - CZipAutoBuffer& operator=(const CZipAutoBuffer& buffer); - - protected: - char* m_pBuffer; - DWORD m_iSize; -}; - -#endif // !defined(AFX_ZIPAUTOBUFFER_H__DEC28C20_83FE_11D3_B7C3_EDEC47A8A86C__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipBaseException.h b/src/smpackagee/ZipArchive/ZipBaseException.h deleted file mode 100644 index 3119f0c9d3..0000000000 --- a/src/smpackagee/ZipArchive/ZipBaseException.h +++ /dev/null @@ -1,22 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipBaseException.h $ -// $Archive: /ZipArchive/ZipBaseException.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef __ZIPBASEEXCEPTION_H__ -#define __ZIPBASEEXCEPTION_H__ - -typedef CException CZipBaseException; - -#endif //__ZIPBASEEXCEPTION_H__4 diff --git a/src/smpackagee/ZipArchive/ZipCentralDir.cpp b/src/smpackagee/ZipArchive/ZipCentralDir.cpp deleted file mode 100644 index 3119a2f441..0000000000 --- a/src/smpackagee/ZipArchive/ZipCentralDir.cpp +++ /dev/null @@ -1,836 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipCentralDir.cpp $ -// $Archive: /ZipArchive/ZipCentralDir.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipCentralDir.h" -#include "ZipArchive.h" -#include "ZipFileMapping.h" -#include "ZipPlatform.h" -#include "stdafx.h" - -#define CENTRALDIRSIZE 22 - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -char CZipCentralDir::m_gszSignature[] = { 0x50, 0x4b, 0x05, 0x06 }; -CZipCentralDir::CZipCentralDir() -{ - m_bConvertAfterOpen = true; - m_bFindFastEnabled = false; - m_bCaseSensitive = false; - m_pCompare = GetCZipStrCompFunc(ZipPlatform::GetSystemCaseSensitivity()); - m_pStorage = NULL; - m_pOpenedFile = NULL; - m_iBufferSize = 32768; -} - -void -CZipCentralDir::Init() -{ - m_info.m_bOnDisk = false; - m_info.m_uBytesBeforeZip = m_info.m_uCentrDirPos = 0; - m_pOpenedFile = NULL; - m_pszComment.Release(); -} - -CZipCentralDir::~CZipCentralDir() -{ - Clear(); -} - -void -CZipCentralDir::Read() -{ - ASSERT(m_pStorage); - WORD uCommentSize; - m_info.m_uCentrDirPos = Locate(); - m_pStorage->m_pFile->Seek(m_info.m_uCentrDirPos, CZipAbstractFile::begin); - CZipAutoBuffer buf(CENTRALDIRSIZE); - - int uRead = m_pStorage->m_pFile->Read(buf, CENTRALDIRSIZE); - if (uRead != CENTRALDIRSIZE) - ThrowError(CZipException::badZipFile); - memcpy(&m_szSignature, buf, 4); - memcpy(&m_info.m_uThisDisk, buf + 4, 2); - memcpy(&m_info.m_uDiskWithCD, buf + 6, 2); - memcpy(&m_info.m_uDiskEntriesNo, buf + 8, 2); - memcpy(&m_info.m_uEntriesNumber, buf + 10, 2); - memcpy(&m_info.m_uSize, buf + 12, 4); - memcpy(&m_info.m_uOffset, buf + 16, 4); - memcpy(&uCommentSize, buf + 20, 2); - buf.Release(); - - m_pStorage->UpdateSpanMode(m_info.m_uThisDisk); - // if m_uThisDisk is not zero, it is enough to say that it is a multi disk - // archive - ASSERT((!m_info.m_uThisDisk && - (m_info.m_uEntriesNumber == m_info.m_uDiskEntriesNo) && - !m_info.m_uDiskWithCD) || - m_info.m_uThisDisk); - - if (!m_pStorage->IsSpanMode() && !m_info.CheckIfOK_1()) - ThrowError(CZipException::badZipFile); - - if (uCommentSize) { - m_pszComment.Allocate(uCommentSize); - uRead = m_pStorage->m_pFile->Read(m_pszComment, uCommentSize); - if (uRead != uCommentSize) - ThrowError(CZipException::badZipFile); - } - - m_info.SetBytesBeforeZip(m_pStorage->IsSpanMode() != 0); - - if (!m_info.CheckIfOK_2()) - ThrowError(CZipException::badZipFile); - - m_info.m_bOnDisk = true; - m_pStorage->ChangeDisk(m_info.m_uDiskWithCD); - - if (!m_info.m_uSize) - return; - - ReadHeaders(); -} - -DWORD -CZipCentralDir::Locate() -{ - - // maximum size of end of central dir record - long uMaxRecordSize = 0xffff + CENTRALDIRSIZE; - DWORD uFileSize = m_pStorage->m_pFile->GetLength(); - - if ((DWORD)uMaxRecordSize > uFileSize) - uMaxRecordSize = uFileSize; - - CZipAutoBuffer buf(m_iBufferSize); - - long uPosInFile = 0; - int uRead = 0; - // backward reading - while (uPosInFile < uMaxRecordSize) { - uPosInFile = uRead + m_iBufferSize; - if (uPosInFile > uMaxRecordSize) - uPosInFile = uMaxRecordSize; - - int iToRead = uPosInFile - uRead; - - m_pStorage->m_pFile->Seek(-uPosInFile, CZipAbstractFile::end); - int iActuallyRead = m_pStorage->m_pFile->Read(buf, iToRead); - if (iActuallyRead != iToRead) - ThrowError(CZipException::badZipFile); - // search from the very last bytes to prevent an error if inside archive - // there are packed other arhives - for (int i = iToRead - 4; i >= 0; i--) - if (!memcmp((char*)buf + i, m_gszSignature, 4)) - return uFileSize - (uPosInFile - i); - - uRead += iToRead - 3; - } - - ThrowError(CZipException::cdirNotFound); - return 0; -} - -void -CZipCentralDir::ThrowError(int err) const -{ - CZipException::Throw(err, m_pStorage->m_pFile->GetFilePath()); -} - -void -CZipCentralDir::ReadHeaders() -{ - m_pStorage->m_pFile->Seek(m_info.m_uOffset + m_info.m_uBytesBeforeZip, - CZipAbstractFile::begin); - RemoveHeaders(); // just in case - for (int i = 0; i < m_info.m_uEntriesNumber; i++) { - CZipFileHeader* pHeader = new CZipFileHeader; - m_headers.Add(pHeader); - - if (!pHeader->Read(m_pStorage)) - ThrowError(CZipException::badZipFile); - ConvertFileName(true, true, pHeader); - } - SortHeaders(); // this is necessary when deleting files and removing data - // descriptors - if (m_bFindFastEnabled) - BuildFindFastArray(m_bCaseSensitive); -} - -void -CZipCentralDir::SortHeaders() -{ - // we cannot use the Sort method of the CZipWordArray, - // because we store pointers (and we need to store pointers - // to make sure that the address of the CZipFileHeader structure - // remains the same while working with the library) - int iSize = m_headers.GetSize(); - if (iSize) - qsort((void*)&(m_headers[0]), - iSize, - sizeof(CZipFileHeader*), - CompareHeaders); -} - -void -CZipCentralDir::Clear(bool bEverything) -{ - m_pOpenedFile = NULL; - m_pLocalExtraField.Release(); - if (bEverything) { - RemoveHeaders(); - m_findarray.RemoveAll(); - m_pszComment.Release(); - } -} - -bool -CZipCentralDir::IsValidIndex(int uIndex) const -{ - return uIndex < m_headers.GetSize() && uIndex >= 0; -} - -void -CZipCentralDir::OpenFile(WORD uIndex) -{ - WORD uLocalExtraFieldSize; - m_pOpenedFile = (*this)[uIndex]; - m_pStorage->ChangeDisk(m_pOpenedFile->m_uDiskStart); - m_pStorage->m_pFile->Seek(m_pOpenedFile->m_uOffset + - m_info.m_uBytesBeforeZip, - CZipAbstractFile::begin); - if (!m_pOpenedFile->ReadLocal(m_pStorage, uLocalExtraFieldSize)) - ThrowError(CZipException::badZipFile); - - m_pLocalExtraField.Release(); // just in case - if (uLocalExtraFieldSize) { - int iCurrDsk = m_pStorage->GetCurrentDisk(); - m_pLocalExtraField.Allocate(uLocalExtraFieldSize); - m_pStorage->Read(m_pLocalExtraField, uLocalExtraFieldSize, true); - if (m_pStorage->GetCurrentDisk() != iCurrDsk) - ThrowError(CZipException::badZipFile); - } -} - -void -CZipCentralDir::CloseFile(bool bAfterException) -{ - if (!m_pOpenedFile) - return; - m_pLocalExtraField.Release(); - if (!bAfterException && m_pOpenedFile->IsDataDescr()) { - CZipAutoBuffer buf(12); - m_pStorage->Read(buf, 4, false); - // in span mode, files that are divided between disks have bit 3 of flag - // set which tell about the presence of the data descriptor after the - // compressed data This signature may be in the disk spanning archive - // that is one volume only (it is detected as a non disk spanning - // archive) - if (memcmp(buf, CZipStorage::m_gszExtHeaderSignat, 4) != - 0) // there is no signature - m_pStorage->m_pFile->Seek(-4, CZipAbstractFile::current); - - m_pStorage->Read(buf, 12, false); - if (!m_pOpenedFile->CheckCrcAndSizes(buf)) - ThrowError(CZipException::badZipFile); - } - m_pOpenedFile = NULL; -} - -// add new header using the argument as a template -CZipFileHeader* -CZipCentralDir::AddNewFile(const CZipFileHeader& header, int iReplaceIndex) -{ - CZipFileHeader* pHeader = new CZipFileHeader(header); - m_pOpenedFile = pHeader; - WORD uIndex; - DWORD uOffset = 0; - bool bReplace = IsValidIndex(iReplaceIndex); - if (bReplace) { - CZipFileHeader* pfh = m_headers[iReplaceIndex]; - uOffset = pfh->m_uOffset + m_info.m_uBytesBeforeZip; - RemoveFile(pfh, iReplaceIndex, false); - m_headers.InsertAt(iReplaceIndex, pHeader); - uIndex = (WORD)iReplaceIndex; - } else - uIndex = m_headers.Add(pHeader); - - if (m_bFindFastEnabled) - InsertFindFastElement( - pHeader, uIndex); // GetCount > 0, 'cos we've just added a header - RemoveFromDisk(); - if (bReplace) - m_pStorage->m_pFile->Seek(uOffset, CZipAbstractFile::begin); - else - m_pStorage->m_pFile->SeekToEnd(); - return pHeader; -} - -void -CZipCentralDir::RemoveFromDisk() -{ - if (m_info.m_bOnDisk) { - ASSERT(!m_pStorage->IsSpanMode()); // you can't add files to the - // existing disk span archive or to - // delete them from it - m_pStorage->m_pFile->SetLength(m_info.m_uBytesBeforeZip + - m_info.m_uOffset); - m_info.m_bOnDisk = false; - } else - m_pStorage->Flush(); // if remove from disk is requested, then the - // archive modification will follow, so flush the - // buffers -} - -void -CZipCentralDir::CloseNewFile() -{ - CZipAutoBuffer buf(ZIPARCHIVE_DATADESCRIPTOR_LEN + 4); - short iToWrite = 0; - bool bIsSpan = m_pStorage->IsSpanMode() != 0; - bool bEncrypted = m_pOpenedFile->IsEncrypted(); - if (m_pOpenedFile->IsDataDescr()) { - if (bIsSpan || bEncrypted) { - memcpy(buf, m_pStorage->m_gszExtHeaderSignat, 4); - iToWrite += 4; - } - } else /*if (!IsSpan)*/ - { - ASSERT(!bIsSpan && !bEncrypted); - m_pStorage->Flush(); - // the offset contains bytes before zip (set while writting the local - // header) - m_pStorage->m_pFile->Seek(m_pOpenedFile->m_uOffset + 14, - CZipAbstractFile::begin); - // we don't have to restore the pointer, because before adding a new - // file, the pointer is moved to the end - } - - m_pOpenedFile->GetCrcAndSizes(buf + iToWrite); - iToWrite += ZIPARCHIVE_DATADESCRIPTOR_LEN; - - // offset set during writing the local header - m_pOpenedFile->m_uOffset -= m_info.m_uBytesBeforeZip; - - // write the data descriptor and a disk spanning signature at once - m_pStorage->Write(buf, iToWrite, true); - if (!bIsSpan) { - if (bEncrypted) { - // write the information to the local header too - m_pStorage->Flush(); - m_pStorage->m_pFile->Seek(m_info.m_uBytesBeforeZip + - m_pOpenedFile->m_uOffset + 14, - CZipAbstractFile::begin); - m_pStorage->Write(buf + 4, ZIPARCHIVE_DATADESCRIPTOR_LEN, true); - } - m_pStorage->Flush(); - } - - m_pOpenedFile = NULL; -} - -void -CZipCentralDir::Write(CZipActionCallback* pCallback) -{ - if (m_info.m_bOnDisk) - return; - if (!m_pStorage->IsSpanMode()) { - m_pStorage->Flush(); - m_pStorage->m_pFile->SeekToEnd(); - } - - // else - // // we are at the end already - - m_info.m_uEntriesNumber = (WORD)m_headers.GetSize(); - m_info.m_uSize = 0; - bool bDontAllowDiskChange = false; - // if there is a disk spanning archive in creation and it is only - // one-volume, - // (current disk is 0 so far, no bytes has been written so we know they are - // all in the buffer) make sure that it will be after writing central dir - // and make it a non disk spanning archive - if (m_pStorage->IsSpanMode() && m_pStorage->GetCurrentDisk() == 0) { - DWORD uVolumeFree = m_pStorage->VolumeLeft(); - // calculate the size of data descriptors already in the buffer or on - // the disk (they will be removed in the non disk spanning archive): - // multi span signature at the beginnig (4 bytes) + the size of the data - // descr. for each file (multi span signature + 12 bytes data) - // the number of bytes to add: central dir size - total to remove; - DWORD uToGrow = - GetSize(true) - (4 + m_info.m_uEntriesNumber * (4 + 12)); - if (uVolumeFree >= uToGrow) - // lets make sure it will be one-disk archive - { - // can the operation be done only in the buffer? - if (!m_pStorage->m_iBytesWritten && // no bytes on the disk yet - (m_pStorage->GetFreeInBuffer() >= - uToGrow)) // is the buffer big enough? - { - RemoveDataDescr(true); - bDontAllowDiskChange = true; // if the disk change occurs - // somehow, we'll throw an error - // later - } else { - m_pStorage->Flush(); - if (RemoveDataDescr(false)) - bDontAllowDiskChange = true; // if the disk change occurs - // somehow, we'll throw an - // error later - } - } - } - - try { - WriteHeaders(pCallback, - bDontAllowDiskChange || !m_pStorage->IsSpanMode()); - - m_info.m_uThisDisk = (WORD)m_pStorage->GetCurrentDisk(); - DWORD uSize = WriteCentralEnd(); - if (bDontAllowDiskChange) { - if (m_pStorage->GetCurrentDisk() != 0) - ThrowError(CZipException::badZipFile); - } - // if after adding a central directory there is a disk change, - // update the information and write it again - if (m_info.m_uThisDisk != m_pStorage->GetCurrentDisk()) { - m_info.DiskChange(m_pStorage->GetCurrentDisk()); - - if (m_pStorage->m_uBytesInWriteBuffer >= uSize) - // if the data is still in the buffer, simply remove it - m_pStorage->m_uBytesInWriteBuffer -= uSize; - else { - m_pStorage->Flush(); - m_pStorage->m_iBytesWritten -= uSize; - m_pStorage->m_pFile->SeekToBegin(); - } - - WriteCentralEnd(); - } - } catch (...) { - if (bDontAllowDiskChange) { - m_pStorage->FinalizeSpan(); - m_info.m_uThisDisk = 0; - } - throw; - } - m_info.m_bOnDisk = true; -} - -void -CZipCentralDir::WriteHeaders(CZipActionCallback* pCallback, bool bOneDisk) -{ - m_info.m_uDiskEntriesNo = 0; - m_info.m_uDiskWithCD = (WORD)m_pStorage->GetCurrentDisk(); - m_info.m_uOffset = m_pStorage->GetPosition() - m_info.m_uBytesBeforeZip; - if (!m_info.m_uEntriesNumber) - return; - - WORD iDisk = m_info.m_uDiskWithCD; - int iStep = 0; // for the compiler - - if (pCallback) { - pCallback->Init(); - pCallback->SetTotal(m_info.m_uEntriesNumber); - iStep = CZipActionCallback::m_iStep; // we don't want to wait forever - } - - int iAborted = 0; - for (int i = 0; i < m_info.m_uEntriesNumber; i++) { - CZipFileHeader* pHeader = (*this)[i]; - - CZipString szRemember; - if (m_bConvertAfterOpen) - // if CZipArchive::Flush is called we will be still using the - // archive, so restore changed name - szRemember = pHeader->GetFileName(); - - ConvertFileName(false, true, pHeader); - m_info.m_uSize += pHeader->Write(m_pStorage); - - if (m_bConvertAfterOpen) - pHeader->SetFileName(szRemember); - - if (m_pStorage->GetCurrentDisk() != iDisk) { - m_info.m_uDiskEntriesNo = 1; - iDisk = (WORD)m_pStorage->GetCurrentDisk(); - // update the information about the offset and starting disk if the - // first header was written on the new disk - if (i == 0) { - m_info.m_uOffset = 0; - m_info.m_uDiskWithCD = iDisk; - } - } else - m_info.m_uDiskEntriesNo++; - if (pCallback && !(i % iStep)) - if (!pCallback->Callback(iStep)) { - - if (bOneDisk) { - if (!m_pStorage->IsSpanMode()) - m_pStorage->EmptyWriteBuffer(); - else - m_pStorage->Flush(); // must be flush before - flush was - // not called in span mode - - // remove saved part from the disk - m_pStorage->m_pFile->SetLength(m_info.m_uBytesBeforeZip + - m_info.m_uOffset); - // We can now abort safely - iAborted = CZipException::abortedSafely; - } else - iAborted = CZipException::abortedAction; - break; - } - } - - if (pCallback) - pCallback->CallbackEnd(); - - if (iAborted) - ThrowError(iAborted); -} - -DWORD -CZipCentralDir::WriteCentralEnd() -{ - DWORD uSize = GetSize(); - CZipAutoBuffer buf(uSize); - WORD uCommentSize = (WORD)m_pszComment.GetSize(); - memcpy(buf, m_gszSignature, 4); - memcpy(buf + 4, &m_info.m_uThisDisk, 2); - memcpy(buf + 6, &m_info.m_uDiskWithCD, 2); - memcpy(buf + 8, &m_info.m_uDiskEntriesNo, 2); - memcpy(buf + 10, &m_info.m_uEntriesNumber, 2); - memcpy(buf + 12, &m_info.m_uSize, 4); - memcpy(buf + 16, &m_info.m_uOffset, 4); - memcpy(buf + 20, &uCommentSize, 2); - memcpy(buf + 22, m_pszComment, uCommentSize); - m_pStorage->Write(buf, uSize, true); - return uSize; -} - -void -CZipCentralDir::RemoveAll() -{ - m_findarray.RemoveAll(); - RemoveHeaders(); -} - -void -CZipCentralDir::RemoveFile(CZipFileHeader* pHeader, int iIndex, bool bShift) -{ - - if (iIndex == -1) { - int iCount = m_headers.GetSize(); - for (int i = 0; i < iCount; i++) - if (pHeader == m_headers[i]) { - iIndex = i; - break; - } - } - ASSERT(iIndex != -1 || pHeader); - if (!pHeader) - pHeader = m_headers[iIndex]; - - if (m_bFindFastEnabled) { - int i = FindFileNameIndex(pHeader->GetFileName()); - ASSERT(i != -1); - int uIndex = m_findarray[i].m_uIndex; - m_findarray.RemoveAt(i); - // shift down the indexes - - if (bShift) { - int iSize = m_findarray.GetSize(); - for (int j = 0; j < iSize; j++) { - if (m_findarray[j].m_uIndex > uIndex) - m_findarray[j].m_uIndex--; - } - } - } - - if (iIndex != -1) { - delete pHeader; - m_headers.RemoveAt(iIndex); - } -} - -DWORD -CZipCentralDir::GetSize(bool bWhole) const -{ - DWORD uHeaders = 0; - int iCount = m_headers.GetSize(); - if (bWhole) { - for (int i = 0; i < iCount; i++) { - const CZipFileHeader* pHeader = m_headers[i]; - uHeaders += pHeader->GetSize(); - } - } - return CENTRALDIRSIZE + m_pszComment.GetSize() + uHeaders; -} - -bool -CZipCentralDir::RemoveDataDescr(bool bFromBuffer) -{ - ziparchv::CZipFileMapping fm; - char* pFile; - DWORD uSize; - if (bFromBuffer) { - uSize = m_pStorage->m_uBytesInWriteBuffer; - pFile = m_pStorage->m_pWriteBuffer; - } else { - uSize = m_pStorage->m_pFile->GetLength(); - // we cannot use CZipMemFile in multidisk archive - // so it MUST be CZipFile - if (!fm.CreateMapping(static_cast(m_pStorage->m_pFile))) - return false; - pFile = fm.GetMappedMemory(); - } - - DWORD uOffsetToChange = 4; - DWORD uPosInBuffer = 0; - DWORD uExtraHeaderLen; - int iCount = m_headers.GetSize(); - for (int i = 0; i < iCount; i++) { - // update the flag value in the local and central header - // int uDataDescr = (m_headers[i]->m_uFlag & 8) ? (4 + 12) : 0; - - CZipFileHeader* pHeader = m_headers[i]; - - char* pSour = pFile + pHeader->m_uOffset; - - if (!pHeader->IsEncrypted()) { - // removing data descriptor - pHeader->m_uFlag &= ~8; - // update local header: - // write modified flag in the local header - memcpy(pSour + 6, &pHeader->m_uFlag, 2); - uExtraHeaderLen = - 4 /*ext. header signature*/ + 12 /*data descriptor*/; - } else - // do not remove data descriptors from encrypted files - uExtraHeaderLen = 0; - - // update crc32 and sizes' values - pHeader->GetCrcAndSizes(pSour + 14); - - DWORD uToCopy = - (i == (iCount - 1) ? uSize : m_headers[i + 1]->m_uOffset) - - pHeader->m_uOffset - uExtraHeaderLen; - - memmove(pFile + uPosInBuffer, pSour, uToCopy); - - uPosInBuffer += uToCopy; - pHeader->m_uOffset -= uOffsetToChange; - uOffsetToChange += uExtraHeaderLen; - } - - if (bFromBuffer) - m_pStorage->m_uBytesInWriteBuffer = uPosInBuffer; - else { - m_pStorage->m_iBytesWritten = uPosInBuffer; - fm.RemoveMapping(); - m_pStorage->m_pFile->SetLength(uPosInBuffer); - } - return true; -} - -void -CZipCentralDir::RemoveHeaders() -{ - int iCount = m_headers.GetSize(); - for (int i = 0; i < iCount; i++) - delete m_headers[i]; - m_headers.RemoveAll(); -} - -void -CZipCentralDir::ConvertAll() -{ - ASSERT(!m_bConvertAfterOpen); - int iCount = m_headers.GetSize(); - for (int i = 0; i < iCount; i++) - ConvertFileName(true, false, m_headers[i]); - m_bConvertAfterOpen = true; -} - -void -CZipCentralDir::BuildFindFastArray(bool bCaseSensitive) -{ - m_findarray.RemoveAll(); - m_bCaseSensitive = bCaseSensitive; - m_pCompare = GetCZipStrCompFunc(bCaseSensitive); - int iCount = m_headers.GetSize(); - if (!m_bConvertAfterOpen) { - for (int i = 0; i < iCount; i++) { - CZipFileHeader fh = *m_headers[i]; - ConvertFileName(true, false, &fh); - InsertFindFastElement( - &fh, i); // this method requires the name to be already converted - } - } else - for (int i = 0; i < iCount; i++) - InsertFindFastElement(m_headers[i], i); -} - -void -CZipCentralDir::EnableFindFast(bool bEnable, bool bCaseSensitive) -{ - if (m_bFindFastEnabled == bEnable) - return; - m_bFindFastEnabled = bEnable; - if (bEnable) - BuildFindFastArray(bCaseSensitive); - else - m_findarray.RemoveAll(); -} - -int -CZipCentralDir::FindFile(LPCTSTR lpszFileName, - bool bCaseSensitive, - bool bSporadically, - bool bFileNameOnly) -{ - // this is required for fast finding and is done only once - if (!m_bConvertAfterOpen) { - TRACE( - _T("%s(%i) : Converting all the filenames.\n"), __FILE__, __LINE__); - ConvertAll(); - } - if (!m_bFindFastEnabled) - EnableFindFast(true, bSporadically ? !bCaseSensitive : bCaseSensitive); - int iResult = -1; - if (bFileNameOnly) { - // a non-effective search (treat an array as unsorted) - int iSize = m_findarray.GetSize(); - for (int i = 0; i < iSize; i++) { - CZipString sz = GetProperHeaderFileName(m_findarray[i].m_pHeader); - CZipPathComponent::RemoveSeparators(sz); // to find a dir - CZipPathComponent zpc(sz); - sz = zpc.GetFileName(); - if ((sz.*m_pCompare)(lpszFileName) == 0) { - iResult = i; - break; - } - } - } else if (bCaseSensitive == m_bCaseSensitive) - iResult = FindFileNameIndex(lpszFileName); - else { - if (bSporadically) { - // a non-effective search (treat an array as unsorted) - int iSize = m_findarray.GetSize(); - for (int i = 0; i < iSize; i++) - if (CompareElement(lpszFileName, (WORD)i) == 0) { - iResult = i; - break; - } - } else { - BuildFindFastArray(bCaseSensitive); - iResult = FindFileNameIndex(lpszFileName); - } - } - return iResult == -1 ? -1 : m_findarray[iResult].m_uIndex; -} - -void -CZipCentralDir::InsertFindFastElement(CZipFileHeader* pHeader, WORD uIndex) -{ - CZipString fileName = pHeader->GetFileName(); - int iSize = m_findarray.GetSize(); - - // Our initial binary search range encompasses the entire array of - // filenames: - int start = 0; - int end = iSize; - - // Keep halving our search range until we find the right place - // to insert the new element: - while (start < end) { - // Find the midpoint of the search range: - int midpoint = (start + end) / 2; - - // Compare the filename with the filename at the midpoint of the - // current search range: - int result = CompareElement(fileName, (WORD)midpoint); - - // If our filename is larger, it must fall in the first half of the - // search range: - if (result > 0) { - end = midpoint; - } - - // If it's smaller, it must fall in the last half: - else if (result < 0) { - start = midpoint + 1; - } - - // If they're equal, we can go ahead and insert here: - else { - start = midpoint; - break; - } - } - m_findarray.InsertAt( - start, - CZipFindFast( - pHeader, WORD(uIndex == WORD(-1) ? iSize : uIndex /* just in case */))); -} - -int -CZipCentralDir::FindFileNameIndex(LPCTSTR lpszFileName) const -{ - int start = 0; - int end = m_findarray.GetUpperBound(); - - // Keep halving our search range until we find the given element: - while (start <= end) { - // Find the midpoint of the search range: - int midpoint = (start + end) / 2; - - // Compare the given filename with the filename at the midpoint of the - // search range: - int result = CompareElement(lpszFileName, (WORD)midpoint); - - // If our filename is smaller, it must fall in the first half of the - // search range: - if (result > 0) { - end = midpoint - 1; - } - - // If it's larger, it must fall in the last half: - else if (result < 0) { - start = midpoint + 1; - } - - // If they're equal, return the result: - else { - return midpoint; - } - } - - // Signal failure: - return -1; -} - -void -CZipCentralDir::RenameFile(WORD uIndex, LPCTSTR lpszNewName) -{ - CZipFileHeader* pHeader = m_headers[uIndex]; - pHeader->SetFileName(lpszNewName); - if (!m_bConvertAfterOpen) - ZipCompatibility::FileNameUpdate(*pHeader, false); - if (m_bFindFastEnabled) - BuildFindFastArray(m_bCaseSensitive); -} \ No newline at end of file diff --git a/src/smpackagee/ZipArchive/ZipCentralDir.h b/src/smpackagee/ZipArchive/ZipCentralDir.h deleted file mode 100644 index 839ea80280..0000000000 --- a/src/smpackagee/ZipArchive/ZipCentralDir.h +++ /dev/null @@ -1,558 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipCentralDir.h $ -// $Archive: /ZipArchive/ZipCentralDir.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipCentralDir.h - * Interface for the CZipCentralDir class. - * - */ - -#if !defined(AFX_CENTRALDIR_H__859029E8_8927_4717_9D4B_E26E5DA12BAE__INCLUDED_) -#define AFX_CENTRALDIR_H__859029E8_8927_4717_9D4B_E26E5DA12BAE__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#if (_MSC_VER > 1000) && (defined ZIP_HAS_DLL) -#pragma warning(disable : 4251) // needs to have dll-interface to be used by - // clients of class -#endif - -#include "ZipAutoBuffer.h" -#include "ZipCollections.h" -#include "ZipCompatibility.h" -#include "ZipException.h" -#include "ZipExport.h" -#include "ZipFileHeader.h" -#define ZIPARCHIVE_DATADESCRIPTOR_LEN 12 - -/** - A class representing the central directory record in the archive. -*/ -class ZIP_API CZipCentralDir -{ - public: - /** - Used in fast finding files by the filename. - A structure for the internal use only. - \see CZipCentralDir::m_findarray - \see CZipArchive::GetFindFastElement - \see CZipArchive::FindFile - \see CZipArchive::EnableFindFast - */ - struct ZIP_API CZipFindFast - { - CZipFindFast() - { - m_uIndex = 0; - m_pHeader = NULL; - } - CZipFindFast(CZipFileHeader* pHeader, WORD uIndex) - : m_pHeader(pHeader) - , m_uIndex(uIndex) - { - } - /** - A pointer to the structure in CZipCentralDir. We extract a name - from it. - */ - CZipFileHeader* m_pHeader; - - /** - The index in the central directory of the \e m_pHeader. - */ - WORD m_uIndex; - }; - - /** - Stores general information about the central directory record. - */ - struct ZIP_API Info - { - DWORD m_uCentrDirPos; ///< the position of the beginning of the central - ///< directory (as located by #Locate) - DWORD m_uBytesBeforeZip; ///< The number of bytes before the actual zip - ///< archive in a file. It is non-zero for - ///< self-extracting archives. - WORD m_uThisDisk; ///< number of the disk with the central directory end - ///< record (the number of disks in the disk-spanning - ///< archive) - WORD m_uDiskWithCD; ///< number of the disk with the start of the - ///< central directory - WORD m_uDiskEntriesNo; ///< total number of entries in the central dir - ///< on this disk - WORD m_uEntriesNumber; ///< total number of entries in the central dir - DWORD m_uSize; ///< size of the central directory (valid only if - ///< #m_bOnDisk is \c true; use #GetSize instead) - DWORD m_uOffset; ///< offset of start of central directory with respect - ///< to the starting disk number (as written in the - ///< central directory record); valid only if - ///< #m_bOnDisk is \c true - bool m_bOnDisk; - //\c true if the central directory is physically present in the archive - - protected: - friend CZipCentralDir; - bool CheckIfOK_1() - { - return ((DWORD)m_uCentrDirPos >= m_uOffset + m_uSize); - } - void SetBytesBeforeZip(bool bIsSpan) - { - m_uBytesBeforeZip = - bIsSpan ? 0 : m_uCentrDirPos - m_uSize - m_uOffset; - } - bool CheckIfOK_2() - { - return (m_uSize || !m_uEntriesNumber) && - (m_uEntriesNumber || !m_uSize); - } - void DiskChange(int iCurrentDisk) - { - m_uThisDisk = (WORD)iCurrentDisk; - if (m_uEntriesNumber) { - m_uDiskEntriesNo = 0; - } else { - m_uDiskWithCD = m_uThisDisk; - m_uOffset = 0; - } - } - }; - - CZipCentralDir(); - virtual ~CZipCentralDir(); - - static char m_gszSignature[]; ///< central dir signature - - char - m_szSignature[4]; ///< end of central dir signature (must be 0x06054b50) - - CZipAutoBuffer m_pszComment; ///< the archive comment - CZipAutoBuffer m_pLocalExtraField; ///< a local extra field - CZipFileHeader* m_pOpenedFile; ///< points to a currently opened file or - ///< NULL if no file is opened - - /** - Called by CZipArchive::OpenInternal. - */ - void Init(); - - /** - Read the central directory from the archive. - \note Throws exceptions. - */ - void Read(); - - /** - Open the file. - \param uIndex - zero-based index of the file to open - \note Throws exceptions. - */ - void OpenFile(WORD uIndex); - - /** - Test if the given file header index is valid. - \param uIndex - a zero-based index - \return \c true if the file with the given index exists inside the - archive; otherwise \c false; -*/ - bool IsValidIndex(int uIndex) const; - - /** - Remove the file header from the central directory. - \param pHeader - the header to remove - \param iIndex if index is not known set it to -1 - \param bShift - \note Throws exceptions. -*/ - void RemoveFile(CZipFileHeader* pHeader, - int iIndex = -1, - bool bShift = true); - - /* - Remove last file from the central directory. - */ - void RemoveLastFile(CZipFileHeader* pHeader = NULL, int iIndex = -1) - { - if (iIndex == -1) { - iIndex = m_headers.GetSize() - 1; - if (iIndex == -1) - return; - } - if (!pHeader) - pHeader = m_headers[iIndex]; - DWORD uNewSize = pHeader->m_uOffset + GetBytesBefore(); - // then remove - RemoveFile(pHeader, iIndex); - - m_pStorage->Flush(); - m_pStorage->m_pFile->SetLength(uNewSize); - m_info.m_bOnDisk = false; // it is true when AutoFlush is set to true - } - - /** - Remove all files - \note Throws exceptions. - */ - void RemoveAll(); - /** - Cleanup the structure. - \param bEverything - - \c true - clear some attributes and remove all the file headers from - memory - - \c false - do not remove the file headers. It is called in that manner - from CZipArchive::CloseFileAfterTestFailed so that the - next file can be tested for the integrity - \see CZipArchive::CloseFileAfterTestFailed -*/ - void Clear(bool bEverything = true); - - /** - Add a new file to the central directory. - \param header - copy data from it to the new file header - \param iReplaceIndex if different from -1, the index of the file to be - replaced \return the pointer to the new header \note Throws exceptions. -*/ - CZipFileHeader* AddNewFile(const CZipFileHeader& header, - int iReplaceIndex = -1); - - /** - return the header filename, converted if needed - */ - CZipString GetProperHeaderFileName(const CZipFileHeader* pHeader) const - { - if (!m_bConvertAfterOpen) { - CZipFileHeader fh = *pHeader; - ConvertFileName(true, false, &fh); - return fh.GetFileName(); - } else - return pHeader->GetFileName(); - } - - /** - Remove physically the central directory from the archive. - Called during adding or deleting files. - \note Throws exceptions. -*/ - void RemoveFromDisk(); - - /** - Get the central directory size. - \param bWhole - if \c true, include the size of the file headers - \return the size of the central directory - \see CZipArchive::GetCentralDirSize -*/ - DWORD GetSize(bool bWhole = false) const; - - /** - Close a file inside archive opened for reading. - \param bAfterException \c true if closing after exception - \note Throws exceptions. - */ - void CloseFile(bool bAfterException = false); - - /** - Close a file inside archive opened for reading. - \note Throws exceptions. - */ - void CloseNewFile(); - - /** - Write the central directory to the archive. - \note Throws exceptions. - */ - void Write(CZipActionCallback* pCallback); - - /** - \see CZipArchive::EnableFindFast - */ - void EnableFindFast(bool bEnable, bool bCaseSensitive); - - /** - \see CZipArchive::FindFile - \note \e bSporadically set to \c false rebuilds #m_findarray if - necessary - */ - int FindFile(LPCTSTR lpszFileName, - bool bCaseSensitive, - bool bSporadically, - bool bFileNameOnly); - - /** - \see CZipArchive::GetFindFastIndex - */ - int GetFindFastIndex(int iFindFastIndex) const - { - if (!IsValidIndex(iFindFastIndex) || !m_bFindFastEnabled) { - // ASSERT(FALSE); // - return -1; - } - - return m_findarray[iFindFastIndex].m_uIndex; - } - - /** - Points to CZipArchive::m_storage. - */ - CZipStorage* m_pStorage; - - /** - The size of the buffer used in searching for the central dir. - Set before opening the archive. - It is usually set with CZipArchive::SetAdvanced - (specify this value as the third argument). - \see CZipArchive::SetAdvanced - */ - int m_iBufferSize; - - /** - Holds all the files inside archive info. - \see CZipFileHeader - */ - CZipArray m_headers; - - CZipFileHeader* operator[](int iIndex) { return m_headers[iIndex]; } - const CZipFileHeader* operator[](int iIndex) const - { - return m_headers[iIndex]; - } - - /** - - If \c true, the conversion of the filenames takes - place after opening the archive (after reading the central directory - from the file), and before writing the central directory back to - the archive. - - If \c false, the conversion takes place on each call to - CZipArchive::GetFileInfo - - Change is value with CZipArchive::SetConvertAfterOpen. - - Set it to \c true when you plan to use CZipArchive::FindFile or get the - stored files information.
Set it to \c false when you plan mostly to - modify the archive. - - \b Default: \c true - \note Set it before opening the archive. - \see CZipArchive::SetConvertAfterOpen - \see ConvertFileName - */ - bool m_bConvertAfterOpen; - - /** - Convert the filename of the CZipFileHeader depending on the current system - and the system the zip file was created on (change slash to backslash or - vice versa, perform ANSI-OEM conversion if necessary). - \param bFromZip - if \c true, convert from archive format - \param bAfterOpen - if \c true, called after opening the archive or before closing - \param pHeader - the header to have filename converted; if \c NULL convert the currently - opened file - \see ZipCompatibility::FileNameUpdate - \see m_bConvertAfterOpen -*/ - void ConvertFileName(bool bFromZip, - bool bAfterOpen, - CZipFileHeader* pHeader = NULL) const - { - if (bAfterOpen != m_bConvertAfterOpen) - return; - if (!pHeader) { - pHeader = m_pOpenedFile; - ASSERT(pHeader); - } - ZipCompatibility::FileNameUpdate(*pHeader, bFromZip); - } - - /** - Convert all the filenames to the system form. - Called by CZipArchive::FindFile - \see CZipArchive::FindFile -*/ - void ConvertAll(); - - /** - \param lpszFileName - the name of the file to find, must be exactly the same (apart from case) - as it appears in the archive - \return the index in #m_findarray with the appropriate CZipFindFast - structure or \c -1 if there is no file with the given name \see - CZipArchive::FindFile -*/ - int FindFileNameIndex(LPCTSTR lpszFileName) const; - - DWORD GetBytesBefore() const { return m_info.m_uBytesBeforeZip; } - /** - Get the information about the central directory - */ - void GetInfo(Info& info) const { info = m_info; } - /** - \return the value of m_bFindFastEnabled - */ - bool IsFindFastEnabled() { return m_bFindFastEnabled; } - /** - Called by CZipArchive::RenameFile - */ - void RenameFile(WORD uIndex, LPCTSTR lpszNewName); - - protected: - /** - Sort the files inside the archive headers by the order in the archive. - */ - void SortHeaders(); - static int CompareHeaders(const void* pArg1, const void* pArg2) - { - CZipFileHeader* pw1 = *(CZipFileHeader**)pArg1; - CZipFileHeader* pw2 = *(CZipFileHeader**)pArg2; - if ((pw1->m_uOffset < pw2->m_uOffset && - pw1->m_uDiskStart == pw2->m_uDiskStart) || - (pw1->m_uDiskStart < pw2->m_uDiskStart)) - return -1; - else if ((pw1->m_uOffset > pw2->m_uOffset && - pw1->m_uDiskStart == pw2->m_uDiskStart) || - (pw1->m_uDiskStart > pw2->m_uDiskStart)) - return 1; - else { - ASSERT(FALSE); - // two files with the same offsets on the same disk??? - CZipException::Throw(CZipException::badZipFile); - return 0; // just for the compiler comfort - } - } - - /** - Build #m_findarray. -*/ - void BuildFindFastArray(bool bCaseSensitive); - - /** - Used in fast finding files by the filename. - \see CZipFindFast - \see m_bFindFastEnabled - \see CZipArchive::FindFile - */ - CZipArray m_findarray; - - /** - If \c true, the there is an additional array build, to speed up the - finding process - CZipArchive::FindFile uses this array to perform a - binary search. - \b Default: \c false - \see CZipArchive::EnableFindFast - \see CZipArchive::FindFile - \see CZipCentralDir::m_findarray - */ - bool m_bFindFastEnabled; - - /** - The \e lpszFileName and \e bCaseSensitive arguments - are the same as in the #FindFileNameIndex. The function get CZipFindFast - structure pointed by \e uIndex and compares the filename of CZipFileHeader - class stored in this structure with \e lpszFileName. - \param lpszFileName - \param uIndex - the index from #m_findarray - \return - - 0 if the filenames are the same - - < 0 if the filename stored in the array is less than \e lpszFileName - - > 0 if the filename stored in the array is greater than \e lpszFileName -*/ - int CompareElement(LPCTSTR lpszFileName, WORD uIndex) const - { - return (m_findarray[uIndex].m_pHeader->GetFileName().* - m_pCompare)(lpszFileName); - } - /** - Insert a new CZipFindFast element to the #m_findarray. - Initialize CZipFindFast object with \e pHeader and \e uIndex values. -*/ - void InsertFindFastElement(CZipFileHeader* pHeader, WORD uIndex); - - /** - A compare function (Collate or CollateNoCase) set once so as not - to check every time which one to use
- ZIPSTRINGCOMPARE is defined in CZipString.h as:
- typedef int (CZipString::*ZIPSTRINGCOMPARE)( LPCTSTR ) const; - - */ - ZIPSTRINGCOMPARE m_pCompare; - - /** - The way the m_findarray is sorted - */ - bool m_bCaseSensitive; - - /** - \see Info - */ - Info m_info; - - /** - \return the location of the beginning of the central dir end record in - the archive \note Throws exceptions. - */ - DWORD Locate(); - /** - Read the file headers from the file. - \note Throws exceptions. - */ - void ReadHeaders(); - - /** - Free the memory allocated for the CZipFileHeader structures. - */ - void RemoveHeaders(); - /** - Remove data descriptors from the write buffer in the disk spanning volume - that turned out to be one-disk only. - We do not remove them from password encrypted files. - - \param bFromBuffer - if \c true, remove from the buffer in memory otherwise from the file on - a disk \return \c false if the file mapping to memory was not successful - Can happen only when \e bFormBuffer is \c false. - \note Throws exceptions. -*/ - bool RemoveDataDescr(bool bFromBuffer); - /** - Write the file headers to the archive. - \note Throws exceptions. -*/ - void WriteHeaders(CZipActionCallback* pCallback, bool bOneDisk); - /** - Write the central directory end record. - \return the size of the record - \note Throws exceptions. -*/ - DWORD WriteCentralEnd(); - - /** - Throw an exception with the given code. - \param err - \see CZipException::Throw -*/ - void ThrowError(int err) const; -}; - -#endif // !defined(AFX_CENTRALDIR_H__859029E8_8927_4717_9D4B_E26E5DA12BAE__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipCollections.h b/src/smpackagee/ZipArchive/ZipCollections.h deleted file mode 100644 index ab38909768..0000000000 --- a/src/smpackagee/ZipArchive/ZipCollections.h +++ /dev/null @@ -1,82 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipCollections.h $ -// $Archive: /ZipArchive/ZipCollections.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef ZIPCOLLECTIONS_DOT_H -#define ZIPCOLLECTIONS_DOT_H - -#if _MSC_VER > 1000 -#pragma once -#pragma warning(push) -#pragma warning( \ - disable : 4786) // 'identifier' : identifier was truncated to 'number' - // characters in the debug information -#endif // _MSC_VER > 1000 - -#include -typedef CStringArray CZipStringArray; - -template -class CZipArray : public CArray -{ - - static int CompareAsc(const void* pArg1, const void* pArg2) - { - TYPE w1 = *(TYPE*)pArg1; - TYPE w2 = *(TYPE*)pArg2; - return w1 == w2 ? 0 : (w2 > w1 ? -1 : 1); - } - static int CompareDesc(const void* pArg1, const void* pArg2) - { - TYPE w1 = *(TYPE*)pArg1; - TYPE w2 = *(TYPE*)pArg2; - return w1 == w2 ? 0 : (w1 > w2 ? -1 : 1); - } - - public: - void Sort(bool bAscending) - { - int iSize = GetSize(); - if (!iSize) // if ommitted operator [] will fail if empty - return; - qsort((void*)&((*this)[0]), - iSize, - sizeof(TYPE), - bAscending ? CompareAsc : CompareDesc); - } -}; - -typedef CZipArray CZipWordArray; - -template -class CZipPtrList : public CTypedPtrList -{ - public: - typedef POSITION iterator; - typedef POSITION const_iterator; - - bool IteratorValid(const iterator& iter) const { return iter != NULL; } -}; - -template -class CZipMap : public CMap -{ -}; - -#ifdef _MFC_VER -#pragma warning(pop) -#endif - -#endif /* ZIPCOLLECTIONS_DOT_H */ diff --git a/src/smpackagee/ZipArchive/ZipCompatibility.cpp b/src/smpackagee/ZipArchive/ZipCompatibility.cpp deleted file mode 100644 index b07599812b..0000000000 --- a/src/smpackagee/ZipArchive/ZipCompatibility.cpp +++ /dev/null @@ -1,194 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipCompatibility.cpp $ -// $Archive: /ZipArchive/ZipCompatibility.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipCompatibility.h" -#include "ZipAutoBuffer.h" -#include "ZipException.h" -#include "ZipFileHeader.h" -#include "ZipPlatform.h" -#include "stdafx.h" -enum iInternalAttr -{ - attROnly = 0x01, - attHidd = 0x02, - attSys = 0x04, - attDir = 0x10, - attArch = 0x20 -}; -// *********************** WINDOWS ************************** -#ifndef _WIN32 -#define FILE_ATTRIBUTE_READONLY 0x00000001 -#define FILE_ATTRIBUTE_HIDDEN 0x00000002 -#define FILE_ATTRIBUTE_SYSTEM 0x00000004 -#define FILE_ATTRIBUTE_DIRECTORY 0x00000010 -#define FILE_ATTRIBUTE_ARCHIVE 0x00000020 -#endif -// *********************** UINX ************************** -#define USER_PERMISSIONS_MASK 0x01C00000 -#define EXTRACT_USER_PERMISSIONS(x) ((x & USER_PERMISSIONS_MASK) >> 22) -#define CREATE_USER_PERMISSIONS(x) ((x & 0x0007) << 22) - -#define GROUP_PERMISSIONS_MASK 0x00380000 -#define EXTRACT_GROUP_PERMISSIONS ((x & GROUP_PERMISSIONS_MASK) >> 19) -#define CREATE_GROUP_PERMISSIONS(x) ((x & 0x0007) << 19) - -#define OTHER_PERMISSIONS_MASK 0x00070000 -#define EXTRACT_OTHER_PERMISSIONS ((x & OTHER_PERMISSIONS_MASK) >> 16) -#define CREATE_OTHER_PERMISSIONS(x) ((x & 0x0007) << 16) - -#define UNIX_DIRECTORY_ATTRIBUTE 0x40000000 -#define UNIX_FILE_ATTRIBUTE 0x80000000 - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -using namespace ZipCompatibility; - -typedef DWORD (*conv_func)(DWORD, bool); - -DWORD -AttrDos(DWORD, bool); -DWORD -AttrUnix(DWORD, bool); -DWORD -AttrMac(DWORD, bool); - -// more to come... -conv_func conv_funcs[11] = { AttrDos, NULL, NULL, AttrUnix, NULL, NULL, - AttrDos, AttrMac, NULL, NULL, AttrDos }; - -DWORD -ZipCompatibility::ConvertToSystem(DWORD uAttr, int iFromSystem, int iToSystem) -{ - - if (iToSystem != iFromSystem && iFromSystem < 11 && iToSystem < 11) { - conv_func p = conv_funcs[iFromSystem], q = conv_funcs[iToSystem]; - if (p && q) - uAttr = q(p(uAttr, true), false); - else - CZipException::Throw(CZipException::platfNotSupp); - } - return uAttr; -} - -DWORD -AttrDos(DWORD uAttr, bool) -{ - return uAttr; -} - -DWORD -AttrUnix(DWORD uAttr, bool bFrom) -{ - DWORD uNewAttr = 0; - if (bFrom) { - if (uAttr & UNIX_DIRECTORY_ATTRIBUTE) - uNewAttr = attDir; - - uAttr = EXTRACT_USER_PERMISSIONS(uAttr); - - // we may set archive attribute if the file hasn't the execute - // permissions - // - if (!(uAttr & 1)) - uNewAttr |= attArch; - - if (!(uAttr & 2)) - uNewAttr |= attROnly; - - if (!(uAttr & 4)) - uNewAttr |= attHidd; - } else { - - uNewAttr = 0; // we cannot assume that if the file hasn't the archive - // attribute set - - // then it is executable and set execute permissions - - if (!(uAttr & attHidd)) - uNewAttr |= - (CREATE_OTHER_PERMISSIONS(4) | CREATE_GROUP_PERMISSIONS(4)) | - CREATE_USER_PERMISSIONS(4); - - if (!(uAttr & attROnly)) - uNewAttr |= - (CREATE_GROUP_PERMISSIONS(2) | CREATE_USER_PERMISSIONS(2)); - if (uAttr & attDir) - uNewAttr |= UNIX_DIRECTORY_ATTRIBUTE | attDir; - else - uNewAttr |= UNIX_FILE_ATTRIBUTE; - } - - return uNewAttr; -} - -DWORD -AttrMac(DWORD uAttr, bool) -{ - DWORD uNewAttr = uAttr & (attDir | attROnly); - // if (bFrom) - // { - // - // } - // else - // { - // - // } - return uNewAttr; -} - -// ************************************************************************ -ZIPINLINE bool -ZipCompatibility::IsPlatformSupported(int iCode) -{ - return iCode == zcDosFat || iCode == zcUnix || iCode == zcMacintosh || - iCode == zcNtfs || iCode == zcOs2Hpfs; -} - -void -ZipCompatibility::FileNameUpdate(CZipFileHeader& header, bool bFromZip) -{ - int iSysHeader = header.GetSystemCompatibility(); - int iCurSystem = ZipPlatform::GetSystemID(); - if (bFromZip) { - if (iCurSystem == zcDosFat) - SlashBackslashChg(header.m_pszFileName, true); - if (iSysHeader == zcDosFat) - ZipPlatform::AnsiOem(header.m_pszFileName, false); - } else { - if (iSysHeader == zcDosFat) { - ZipPlatform::AnsiOem(header.m_pszFileName, true); - } - SlashBackslashChg(header.m_pszFileName, false); - } -} - -void -ZipCompatibility::SlashBackslashChg(CZipAutoBuffer& buffer, bool bReplaceSlash) -{ - char t1 = '\\' /*backslash*/, t2 = '/', c1, c2; - if (bReplaceSlash) { - c1 = t1; - c2 = t2; - } else { - c1 = t2; - c2 = t1; - } - for (DWORD i = 0; i < buffer.GetSize(); i++) { - if (buffer[i] == c2) - buffer[i] = c1; - } -} diff --git a/src/smpackagee/ZipArchive/ZipCompatibility.h b/src/smpackagee/ZipArchive/ZipCompatibility.h deleted file mode 100644 index 70a159aff4..0000000000 --- a/src/smpackagee/ZipArchive/ZipCompatibility.h +++ /dev/null @@ -1,107 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipCompatibility.h $ -// $Archive: /ZipArchive/ZipCompatibility.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipCompatibility.h - * ZipCompatibility namespace declaration. - * - */ - -#if !defined( \ - AFX_ZIPCOMPATIBILITY_H__8E8B9904_84C7_4B22_B364_A10ED0E7DAD6__INCLUDED_) -#define AFX_ZIPCOMPATIBILITY_H__8E8B9904_84C7_4B22_B364_A10ED0E7DAD6__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -class CZipAutoBuffer; -class CZipFileHeader; - -/** - Functions that provides the proper conversion of attributes - and filename strings between different system platforms. -*/ -namespace ZipCompatibility { -/** - The codes of the compatibility of the file attribute information. - \see CZipArchive::GetSystemCompatibility - \see CZipFileHeader::GetSystemCompatibility - \see ZipPlatform::GetSystemID - */ -enum ZipPlatforms -{ - zcDosFat, ///< MS-DOS and OS/2 (FAT / VFAT / FAT32 file systems) - zcAmiga, ///< Amiga - zcVaxVms, ///< VAX/VMS - zcUnix, ///< Unix / Linux - zcVmCms, ///< VM/CMS - zcAtari, ///< Atari ST - zcOs2Hpfs, ///< OS/2 H.P.F.S. - zcMacintosh, ///< Macintosh - zcZsystem, ///< Z-System - zcCpm, ///< CP/M - zcNtfs ///< Windows NTFS -}; - -/** - Check whether the system with the given code is supported by the ZipArchive - library. \param iCode \link #ZipPlatforms the system code \endlink \return - \c true if supported -*/ -bool -IsPlatformSupported(int iCode); - -/** - Convert the system attributes between different system platforms. - It calls one of the converting functions. - \param uAttr - attributes to convert - \param iFromSystem - system code to convert from - \param iToSystem - system code to convert to - \return the converted attributes - \note Throws exceptions. - \see ZipPlatforms -*/ -DWORD -ConvertToSystem(DWORD uAttr, int iFromSystem, int iToSystem); - -/** - Convert the filename of the file inside archive. - This conversion may not change the size of the filename, otherwise an - error may occur in #ReadLocal while comparing the filename sizes. - \param header - the file header to have the filename converted - \param bFromZip - if \c true convert the path from the from it is stored in the archive - to the current system compatible form; otherwise vice-versa. - \see CZipCentralDir::ConvertFileName -*/ void -FileNameUpdate(CZipFileHeader& header, bool bFromZip); - -/** - Change the slash to backslash or vice-versa in \e buffer. - \param buffer - \param bReplaceSlash - if \c true, change slash to backslash -*/ -void -SlashBackslashChg(CZipAutoBuffer& buffer, bool bReplaceSlash); -}; - -#endif // !defined(AFX_ZIPCOMPATIBILITY_H__8E8B9904_84C7_4B22_B364_A10ED0E7DAD6__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipException.cpp b/src/smpackagee/ZipArchive/ZipException.cpp deleted file mode 100644 index bea4374b70..0000000000 --- a/src/smpackagee/ZipArchive/ZipException.cpp +++ /dev/null @@ -1,285 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipException.cpp $ -// $Archive: /ZipArchive/ZipException.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipException.h" -#include "stdafx.h" -#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -#ifdef _MFC_VER -IMPLEMENT_DYNAMIC(CZipException, CException) -#endif - -CZipException::CZipException(int iCause, LPCTSTR lpszZipName) -#ifdef _MFC_VER - : CException(TRUE) -#endif -{ - m_iCause = iCause; - - if (lpszZipName) - m_szFileName = lpszZipName; -} - -CZipException::~CZipException() {} - -// inline void CZipException::Throw(int iZipError, LPCTSTR lpszZipName) -// { -// #ifdef _MFC_VER -// throw new CZipException(iZipError, lpszZipName); -// #else -// CZipException e(iZipError, lpszZipName); -// throw e; -// #endif -// MSVC++: ignore "Unreachable code" warning here, it's due to -// optimizations -// } - -int -CZipException::ZlibErrToZip(int iZlibError) -{ - switch (iZlibError) { - case 2: // Z_NEED_DICT: - return CZipException::needDict; - case 1: // Z_STREAM_END: - return CZipException::streamEnd; - case -1: // Z_ERRNO: - return CZipException::errNo; - case -2: // Z_STREAM_ERROR: - return CZipException::streamError; - case -3: // Z_DATA_ERROR: - return CZipException::dataError; - case -4: // Z_MEM_ERROR: - return CZipException::memError; - case -5: // Z_BUF_ERROR: - return CZipException::bufError; - case -6: // Z_VERSION_ERROR: - return CZipException::versionError; - default: - return CZipException::generic; - } -} - -#ifdef ZIP_ENABLE_ERROR_DESCRIPTION - -BOOL -CZipException::GetErrorMessage(LPTSTR lpszError, UINT nMaxError, UINT*) - -{ - if (!lpszError || !nMaxError) - return FALSE; - CZipString sz = GetErrorDescription(); - if (sz.IsEmpty()) - return FALSE; - UINT iLen = sz.GetLength(); - if (nMaxError - 1 < iLen) - iLen = nMaxError - 1; - LPTSTR lpsz = sz.GetBuffer(iLen); -#ifdef _UNICODE - wcsncpy(lpszError, lpsz, iLen); -#else - strncpy(lpszError, lpsz, iLen); -#endif - lpszError[iLen] = _T('\0'); - return TRUE; -} - -CZipString -CZipException::GetErrorDescription() -{ - return GetInternalErrorDescription(m_iCause); -} - -CZipString -CZipException::GetSystemErrorDescription() -{ -#ifdef WIN32 - DWORD x = GetLastError(); - if (x) { - LPVOID lpMsgBuf; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - x, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&lpMsgBuf, - 0, - NULL); - CZipString sz = (LPCTSTR)lpMsgBuf; - LocalFree(lpMsgBuf); - return sz; - } -#endif - return GetInternalErrorDescription(errno == 0 ? generic : errno, true); -} - -CZipString -CZipException::GetInternalErrorDescription(int iCause, bool bNoLoop) -{ - CZipString sz; - switch (iCause) { - case EROFS: - sz = _T("Read-only file system"); - break; - case ESPIPE: - sz = _T("Illegal seek"); - break; - case ENOSPC: - sz = _T("No space left on device"); - break; - case EFBIG: - sz = _T("File too large"); - break; - case EMFILE: - sz = _T("Too many open files"); - break; - case ENFILE: - sz = _T("File table overflow"); - break; - case EINVAL: - sz = _T("Invalid argument"); - break; - case EISDIR: - sz = _T("Is a directory"); - break; - case ENOTDIR: - sz = _T("Not a directory"); - break; - case ENODEV: - sz = _T("No such device"); - break; - case EXDEV: - sz = _T("Cross-device link"); - break; - case EEXIST: - sz = _T("File exists"); - break; - case EFAULT: - sz = _T("Bad address"); - break; - case EACCES: - sz = _T("Permission denied"); - break; - case ENOMEM: - sz = _T("Not enough space"); - break; - case EBADF: - sz = _T("Bad file number"); - break; - case ENXIO: - sz = _T("No such device or address"); - break; - case EIO: - sz = _T("I/O error"); - break; - case EINTR: - sz = _T("Interrupted system call"); - break; - case ENOENT: - sz = _T("No such file or directory"); - break; - case EPERM: - sz = _T("Not super-user"); - break; - case badZipFile: - sz = _T("Damaged or not a zip file"); - break; - case badCrc: - sz = _T("Crc mismatched"); - break; - case noCallback: - sz = _T("No disk-spanning callback functor set"); - break; - case aborted: - sz = _T("Disk change aborted"); - break; - case abortedAction: - sz = _T("Action aborted"); - break; - case abortedSafely: - sz = _T("Action aborted safely"); - break; - case nonRemovable: - sz = _T("The device selected for the disk spanning archive is non ") - _T("removable"); - break; - case tooManyVolumes: - sz = _T("Limit of the maximum volumes reached (999)"); - break; - case tooLongFileName: - sz = _T("The filename of the file being added to the archive is ") - _T("too long"); - break; - case badPassword: - sz = _T("Incorrect password set for the file being decrypted"); - break; - case dirWithSize: - sz = _T("During testing found the directory with the size greater ") - _T("than 0"); - break; - case internal: - sz = _T("Internal error"); - break; - case notRemoved: - sz.Format(_T("%s (%s)"), - _T("Error while removing a file"), - (LPCTSTR)GetSystemErrorDescription()); - break; - case notRenamed: - sz.Format(_T("%s (%s)"), - _T("Error while renaming a file"), - (LPCTSTR)GetSystemErrorDescription()); - break; - case platfNotSupp: - sz = _T("Cannot create the file for the specified platform"); - break; - case cdirNotFound: - sz = _T("The central directory was not found in the archive (or ") - _T("you were trying to open not the last disk of a ") - _T("multi-disk archive)"); - break; - case streamEnd: - sz = _T("Zlib Library error (end of stream)"); - break; - case errNo: - sz = GetInternalErrorDescription(errno != errNo ? errno : generic); - break; - case streamError: - sz = _T("Zlib library error (stream error)"); - break; - case dataError: - sz = _T("Zlib library error (data error)"); - break; - case memError: - sz = _T("Not enough memory"); - break; - case bufError: - sz = _T("Zlib library error (buffer error)"); - break; - case versionError: - sz = _T("Zlib library error (version error)"); - break; - default: - sz = bNoLoop ? _T("Unknown error") - : (LPCTSTR)GetSystemErrorDescription(); - } - return sz; -} - -#endif // ZIP_ENABLE_ERROR_DESCRIPTION diff --git a/src/smpackagee/ZipArchive/ZipException.h b/src/smpackagee/ZipArchive/ZipException.h deleted file mode 100644 index 1333a4157e..0000000000 --- a/src/smpackagee/ZipArchive/ZipException.h +++ /dev/null @@ -1,219 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipException.h $ -// $Archive: /ZipArchive/ZipException.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipException.h - * Interface for the CZipException class. - * - */ - -#if !defined( \ - AFX_ZIPEXCEPTION_H__E3546921_D728_11D3_B7C7_E77339672847__INCLUDED_) -#define AFX_ZIPEXCEPTION_H__E3546921_D728_11D3_B7C7_E77339672847__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#pragma warning(push) -#pragma warning(disable : 4702) // disable "Unreachable code" warning in Throw - // function in the Release mode -#endif // _MSC_VER > 1000 - -#include "ZipBaseException.h" -#include "ZipExport.h" -#include "ZipString.h" - -#define ZIP_ENABLE_ERROR_DESCRIPTION - -/** - A class representing exceptions specific to the ZipArchive library. - Library exception class derived in the MFC version from \c CException - and in non-MFC version from \c std::exception. -*/ -class ZIP_API CZipException : public CZipBaseException -{ - public: - /** - \param iCause - error cause (takes one of the #ZipErrors enumeration codes) - \param lpszZipName - the name of the file where the error occurred (if applicable) -*/ - CZipException(int iCause = generic, LPCTSTR lpszZipName = NULL); - - CZipException::CZipException(CZipException& e) - { - m_szFileName = e.m_szFileName; - m_iCause = e.m_iCause; - } - - /* - Throw an exception. - Throw CZipException* in the MFC version of the library - (the object must be deleted with Delete() method) - and CZipException in other versions. - The arguments are the same as in CZipException(). - \param iZipError - \param lpszZipName - \see CZipException() -*/ - - static void Throw(int iZipError = CZipException::generic, - LPCTSTR lpszZipName = NULL) - { -#ifdef _MFC_VER - throw new CZipException(iZipError, lpszZipName); -#else - CZipException e(iZipError, lpszZipName); - throw e; -#endif - } - - /** - Convert a zlib library error code to a \link #ZipErrors CZipException error - code \endlink \param iZlibError zlib library error code \return \link - #ZipErrors CZipException error code \endlink -*/ - - static int ZlibErrToZip(int iZlibError); - -#ifdef ZIP_ENABLE_ERROR_DESCRIPTION - - /* - Return the error description. - \note You need to have defined ZIP_ENABLE_ERROR_DESCRIPTION - (in file ZipException.h); undefine this value if you don't want to - store the messages in the library. - */ - CZipString GetErrorDescription(); - - /** - Return the description of the error based on system variables - (this function is provided only for compatibility with MFC \c - CException::GetErrorMessage) - - \param lpszError - a pointer to a buffer that will receive the error message - if \c NULL - - \param nMaxError - the maximum number of characters the buffer can hold, including the NULL - terminator - - - \return - \c TRUE if the error string is not empty - \note - - The function will not copy more than \c nMaxError � 1 characters - to the buffer, and it always adds a trailing null to end the string; - if the buffer is too small, the error message will be truncated. - - You need to have defined ZIP_ENABLE_ERROR_DESCRIPTION - (in file ZipException.h); undefine this value if you don't want to - store the messages in the library. - - */ - BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError, UINT* = NULL); - -#endif // ZIP_ENABLE_ERROR_DESCRIPTION - - /** - The name of the zip file where the error occurred. - */ - CZipString m_szFileName; - - /** - The codes of errors thrown by the ZipArchive library - */ - enum ZipErrors - { - noError, ///< no error - // 1 - 42 reserved for errno (from STL) values - - // used only in non-MFC versions 43 - 99 reserved - generic = 100, ///< unknown error - badZipFile, ///< damaged or not a zip file - badCrc, ///< crc mismatched - noCallback, ///< no disk-spanning callback functor set - aborted, ///< callback functor's method Callback returned \c false while - ///< disk change in the disk-spanning archive - abortedAction, ///< callback functor's method Callback returned \c false - ///< in CZipArchive class members: AddNewFile, - ///< ExtractFile, TestFile, DeleteFile or DeleteFiles - abortedSafely, ///< the same as above, you may be sure that the - ///< operation was successfully completed before or it - ///< didn't cause any damage in the archive (break when - ///< counting before deleting files; see - ///< CZipArchive::cbDeleteCnt) - nonRemovable, ///< the disk selected for pkzipSpan archive is non - ///< removable - tooManyVolumes, ///< limit of the maximum volumes reached (999) - tooLongFileName, ///< the filename of the file added to the archive is - ///< too long - badPassword, ///< incorrect password set for the file being decrypted - dirWithSize, ///< during testing: found the directory with the size - ///< greater than 0 - internal, ///< internal error - notRemoved, ///< error while removing a file (under Windows call - ///< GetLastError() to find out more) - notRenamed, ///< error while renaming a file (under Windows call - ///< GetLastError() to find out more) - platfNotSupp, ///< the platform that the zip file is being created for - ///< is not supported - cdirNotFound, ///< the central directory was not found in the archive - ///< (it is thrown also when the last disk of multi-disk - ///< archive is not in the drive when opening the archive) - streamEnd = 500, ///< zlib library error - needDict, ///< zlib library error - errNo, ///< zlib library error - streamError, ///< zlib library error - dataError, ///< zlib library error - memError, ///< zlib library error thrown by CZipMemFile as well - bufError, ///< zlib library error - versionError, ///< zlib library error - }; - - /** - A cause of the error - takes one of the #ZipErrors enumeration codes. - */ - int m_iCause; - - virtual ~CZipException(); - - protected: -#ifdef ZIP_ENABLE_ERROR_DESCRIPTION - - /* - Return the error description - \param iCause : error number - \param bNoLoop: if \c true tells not to search for en error description, - it the error is generic - \return - */ - CZipString GetInternalErrorDescription(int iCause, bool bNoLoop = false); - - /* - Return the description of the error based on system variables - \return - */ - CZipString GetSystemErrorDescription(); - -#endif // ZIP_ENABLE_ERROR_DESCRIPTION - -#ifdef _MFC_VER - DECLARE_DYNAMIC(CZipException) -#pragma warning(pop) -#endif -}; - -#endif // !defined(AFX_ZIPEXCEPTION_H__E3546921_D728_11D3_B7C7_E77339672847__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipExport.h b/src/smpackagee/ZipArchive/ZipExport.h deleted file mode 100644 index 0efad48a30..0000000000 --- a/src/smpackagee/ZipArchive/ZipExport.h +++ /dev/null @@ -1,18 +0,0 @@ -#if !defined(ZIP_EXPORT_H) -#define ZIP_API_H - -#if defined(ZIP_HAS_DLL) -#if (ZIP_HAS_DLL == 1) -#if defined(ZIP_BUILD_DLL) -#define ZIP_API __declspec(dllexport) -#else -#define ZIP_API __declspec(dllimport) -#endif /* ZIP_BUILD_DLL */ -#else -#define ZIP_API -#endif /* ! ZIP_HAS_DLL == 1 */ -#else -#define ZIP_API -#endif /* ZIP_HAS_DLL */ - -#endif /* ZIP_EXPORT_H */ diff --git a/src/smpackagee/ZipArchive/ZipFile.cpp b/src/smpackagee/ZipArchive/ZipFile.cpp deleted file mode 100644 index f50e84004f..0000000000 --- a/src/smpackagee/ZipArchive/ZipFile.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFile.cpp $ -// $Archive: /ZipArchive/ZipFile.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipFile.h" -#include "stdafx.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -// IMPLEMENT_DYNAMIC(CZipAbstractFile, CFile) -IMPLEMENT_DYNAMIC(CZipFile, CFile) - -CZipFile::CZipFile() {} - -CZipFile::~CZipFile() {} - -CZipFile::operator HANDLE() -{ - return (HANDLE)m_hFile; -} - -// __int64 CZipFile::Seek(__int64 dOff, UINT nFrom) -// { -// ASSERT_VALID(this); -// ASSERT(m_hFile != (UINT)hFileNull); -// ASSERT(nFrom == begin || nFrom == end || nFrom == current); -// ASSERT(begin == FILE_BEGIN && end == FILE_END && current == FILE_CURRENT); -// LARGE_INTEGER li; -// li.QuadPart = dOff; -// -// li.LowPart = ::SetFilePointer((HANDLE)m_hFile, li.LowPart, &li.HighPart, -// (DWORD)nFrom); DWORD dw = GetLastError(); if ((li.LowPart == (DWORD)-1) && -// (dw != NO_ERROR)) -// { -// CFileException::ThrowOsError((LONG)dw); -// } -// -// return li.QuadPart; -// } diff --git a/src/smpackagee/ZipArchive/ZipFile.h b/src/smpackagee/ZipArchive/ZipFile.h deleted file mode 100644 index 04a99d6126..0000000000 --- a/src/smpackagee/ZipArchive/ZipFile.h +++ /dev/null @@ -1,68 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFile.h $ -// $Archive: /ZipArchive/ZipFile.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_) -#define AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#include "ZipAbstractFile.h" -#include "ZipExport.h" - -class ZIP_API CZipFile - : public CZipAbstractFile - , public CFile -{ - public: - DECLARE_DYNAMIC(CZipFile) - void Flush() { CFile::Flush(); } - ZIP_ULONGLONG GetPosition() const { return CFile::GetPosition(); } - CZipString GetFilePath() const { return CFile::GetFilePath(); } - void SetLength(ZIP_ULONGLONG nNewLen) { CFile::SetLength(nNewLen); } - UINT Read(void* lpBuf, UINT nCount) { return CFile::Read(lpBuf, nCount); } - void Write(const void* lpBuf, UINT nCount) { CFile::Write(lpBuf, nCount); } - ZIP_ULONGLONG Seek(ZIP_LONGLONG lOff, int nFrom) - { - return CFile::Seek(lOff, nFrom); - } - ZIP_ULONGLONG GetLength() const { return CFile::GetLength(); } - bool Open(LPCTSTR lpszFileName, UINT nOpenFlags, bool bThrowExc) - { - CFileException* e = new CFileException; - bool bRet = CFile::Open(lpszFileName, nOpenFlags, e) != 0; - if (!bRet && bThrowExc) - throw e; - e->Delete(); - return bRet; - } - CZipFile(); - bool IsClosed() const { return m_hFile == CFile::hFileNull; } - - CZipFile(LPCTSTR lpszFileName, UINT nOpenFlags) - : CFile(lpszFileName, nOpenFlags) - { - } - void Close() - { - if (!IsClosed()) - CFile::Close(); - } - operator HANDLE(); - virtual ~CZipFile(); -}; - -#endif // !defined(AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipFileHeader.cpp b/src/smpackagee/ZipArchive/ZipFileHeader.cpp deleted file mode 100644 index 594e15829e..0000000000 --- a/src/smpackagee/ZipArchive/ZipFileHeader.cpp +++ /dev/null @@ -1,358 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFileHeader.cpp $ -// $Archive: /ZipArchive_STL/ZipFileHeader.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipFileHeader.h" -#include "ZipArchive.h" -#include "ZipAutoBuffer.h" -#include "ZipCompatibility.h" -#include "ZipPlatform.h" -#include "stdafx.h" -#include - -#define FILEHEADERSIZE 46 -#define LOCALFILEHEADERSIZE 30 - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -char CZipFileHeader::m_gszSignature[] = { 0x50, 0x4b, 0x01, 0x02 }; -char CZipFileHeader::m_gszLocalSignature[] = { 0x50, 0x4b, 0x03, 0x04 }; -CZipFileHeader::CZipFileHeader() -{ - m_uExternalAttr = 0; // ZipPlatform::GetDefaultAttributes(); - m_uModDate = m_uModTime = 0; - m_uMethod = Z_DEFLATED; - // SetSystemCompatibility(ZipPlatform::m_sSystemID); -} - -CZipFileHeader::~CZipFileHeader() {} - -// read the header from the central dir -bool -CZipFileHeader::Read(CZipStorage* pStorage) -{ - // // just in case - // m_pszComment.Release(); - // m_pszFileName.Release(); - WORD uFileNameSize, uCommentSize, uExtraFieldSize; - CZipAutoBuffer buf(FILEHEADERSIZE); - pStorage->Read(buf, FILEHEADERSIZE, true); - memcpy(&m_szSignature, buf, 4); - memcpy(&m_uVersionMadeBy, buf + 4, 2); - memcpy(&m_uVersionNeeded, buf + 6, 2); - memcpy(&m_uFlag, buf + 8, 2); - memcpy(&m_uMethod, buf + 10, 2); - memcpy(&m_uModTime, buf + 12, 2); - memcpy(&m_uModDate, buf + 14, 2); - memcpy(&m_uCrc32, buf + 16, 4); - memcpy(&m_uComprSize, buf + 20, 4); - memcpy(&m_uUncomprSize, buf + 24, 4); - memcpy(&uFileNameSize, buf + 28, 2); - memcpy(&uExtraFieldSize, buf + 30, 2); - memcpy(&uCommentSize, buf + 32, 2); - memcpy(&m_uDiskStart, buf + 34, 2); - memcpy(&m_uInternalAttr, buf + 36, 2); - memcpy(&m_uExternalAttr, buf + 38, 4); - memcpy(&m_uOffset, buf + 42, 4); - buf.Release(); - - if (memcmp(m_szSignature, m_gszSignature, 4) != 0) - return false; - - int iCurDsk = pStorage->GetCurrentDisk(); - m_pszFileName.Allocate(uFileNameSize); // don't add NULL at the end - pStorage->Read(m_pszFileName, uFileNameSize, true); - if (uExtraFieldSize) { - ASSERT(!m_pExtraField.IsAllocated()); - m_pExtraField.Allocate(uExtraFieldSize); - pStorage->Read(m_pExtraField, uExtraFieldSize, true); - } - if (uCommentSize) { - m_pszComment.Allocate(uCommentSize); - pStorage->Read(m_pszComment, uCommentSize, true); - } - - return pStorage->GetCurrentDisk() == - iCurDsk; // check that the whole header is on the one disk -} - -time_t -CZipFileHeader::GetTime() const -{ - struct tm atm; - atm.tm_sec = (m_uModTime & ~0xFFE0) << 1; - atm.tm_min = (m_uModTime & ~0xF800) >> 5; - atm.tm_hour = m_uModTime >> 11; - - atm.tm_mday = m_uModDate & ~0xFFE0; - atm.tm_mon = ((m_uModDate & ~0xFE00) >> 5) - 1; - atm.tm_year = (m_uModDate >> 9) + 80; - atm.tm_isdst = -1; - return mktime(&atm); -} - -// write the header to the central dir -DWORD -CZipFileHeader::Write(CZipStorage* pStorage) -{ - WORD uFileNameSize = GetFileNameSize(), uCommentSize = GetCommentSize(), - uExtraFieldSize = GetExtraFieldSize(); - DWORD iSize = - FILEHEADERSIZE + uFileNameSize + uCommentSize + uExtraFieldSize; - CZipAutoBuffer buf(iSize); - memcpy(buf, &m_szSignature, 4); - memcpy(buf + 4, &m_uVersionMadeBy, 2); - memcpy(buf + 6, &m_uVersionNeeded, 2); - memcpy(buf + 8, &m_uFlag, 2); - memcpy(buf + 10, &m_uMethod, 2); - memcpy(buf + 12, &m_uModTime, 2); - memcpy(buf + 14, &m_uModDate, 2); - memcpy(buf + 16, &m_uCrc32, 4); - memcpy(buf + 20, &m_uComprSize, 4); - memcpy(buf + 24, &m_uUncomprSize, 4); - memcpy(buf + 28, &uFileNameSize, 2); - memcpy(buf + 30, &uExtraFieldSize, 2); - memcpy(buf + 32, &uCommentSize, 2); - memcpy(buf + 34, &m_uDiskStart, 2); - memcpy(buf + 36, &m_uInternalAttr, 2); - memcpy(buf + 38, &m_uExternalAttr, 4); - memcpy(buf + 42, &m_uOffset, 4); - - memcpy(buf + 46, m_pszFileName, uFileNameSize); - - if (uExtraFieldSize) - memcpy(buf + 46 + uFileNameSize, m_pExtraField, uExtraFieldSize); - - if (uCommentSize) - memcpy(buf + 46 + uFileNameSize + uExtraFieldSize, - m_pszComment, - uCommentSize); - - pStorage->Write(buf, iSize, true); - return iSize; -} - -bool -CZipFileHeader::ReadLocal(CZipStorage* pStorage, WORD& iLocExtrFieldSize) -{ - char buf[LOCALFILEHEADERSIZE]; - pStorage->Read(buf, LOCALFILEHEADERSIZE, true); - if (memcmp(buf, m_gszLocalSignature, 4) != 0) - return false; - - bool bIsDataDescr = (((WORD) * (buf + 6)) & 8) != 0; - - WORD uFileNameSize = GetFileNameSize(); - WORD uTemp; - memcpy(&uTemp, buf + 6, 2); // give the priority to the local flag - if ((uTemp & 0xf) != (m_uFlag & 0xf)) - m_uFlag = uTemp; - if ((memcmp(buf + 8, &m_uMethod, 2) != 0) || - (m_uMethod && (m_uMethod != Z_DEFLATED)) || - (memcmp(buf + 26, &uFileNameSize, 2) != 0)) - return false; - - // jeszcze mo¿naby porównaæ nazwy plików - - if (!bIsDataDescr /* || !pStorage->IsSpanMode()*/) - if (!CheckCrcAndSizes(buf + 14)) - return false; - - memcpy(&iLocExtrFieldSize, buf + 28, 2); - pStorage->m_pFile->Seek(uFileNameSize, CZipAbstractFile::current); - - return true; -} - -void -CZipFileHeader::SetTime(const time_t& ttime) -{ - tm* gt = localtime(&ttime); - WORD year = (WORD)(gt->tm_year + 1900); - if (year <= 1980) - year = 0; - else - year -= 1980; - m_uModDate = (WORD)(gt->tm_mday + ((gt->tm_mon + 1) << 5) + (year << 9)); - m_uModTime = - (WORD)((gt->tm_sec >> 1) + (gt->tm_min << 5) + (gt->tm_hour << 11)); -} -// the buffer contains crc32, compressed and uncompressed sizes to be compared -// with the actual values -bool -CZipFileHeader::CheckCrcAndSizes(char* pBuf) const -{ - return (memcmp(pBuf, &m_uCrc32, 4) == 0) && - (memcmp(pBuf + 4, &m_uComprSize, 4) == 0) && - (memcmp(pBuf + 8, &m_uUncomprSize, 4) == 0); -} - -// write the local header -void -CZipFileHeader::WriteLocal(CZipStorage& storage) -{ - // extra field is local by now - WORD uFileNameSize = GetFileNameSize(), - uExtraFieldSize = GetExtraFieldSize(); - DWORD iLocalSize = LOCALFILEHEADERSIZE + uExtraFieldSize + uFileNameSize; - CZipAutoBuffer buf(iLocalSize); - memcpy(buf, m_gszLocalSignature, 4); - memcpy(buf + 4, &m_uVersionNeeded, 2); - memcpy(buf + 6, &m_uFlag, 2); - memcpy(buf + 8, &m_uMethod, 2); - memcpy(buf + 10, &m_uModTime, 2); - memcpy(buf + 12, &m_uModDate, 2); - memcpy(buf + 14, &m_uCrc32, 4); - memcpy(buf + 18, &m_uComprSize, 4); - memcpy(buf + 22, &m_uUncomprSize, 4); - memcpy(buf + 26, &uFileNameSize, 2); - memcpy(buf + 28, &uExtraFieldSize, 2); - memcpy(buf + 30, m_pszFileName, uFileNameSize); - memcpy(buf + 30 + uFileNameSize, m_pExtraField, uExtraFieldSize); - - // possible disk change before writing to the file in the disk spanning mode - // so write the local header first - storage.Write(buf, iLocalSize, true); - // it was only local information, use CZipArchive::SetExtraField to set the - // file extra field in the central directory - m_pExtraField.Release(); - - m_uDiskStart = (WORD)storage.GetCurrentDisk(); - m_uOffset = storage.GetPosition() - iLocalSize; -} - -// prepare the data before adding a new file -bool -CZipFileHeader::PrepareData(int iLevel, bool bSpan, bool bEncrypted) -{ - memcpy(m_szSignature, m_gszSignature, 4); - m_uInternalAttr = 0; - m_uVersionNeeded = IsDirectory() ? 0xa : 0x14; // 1.0 or 2.0 - SetVersion((WORD)(0x14)); - - m_uCrc32 = 0; - m_uComprSize = 0; - m_uUncomprSize = 0; - if (iLevel == 0) - m_uMethod = 0; - - if ((m_uMethod != Z_DEFLATED) && (m_uMethod != 0)) - m_uMethod = Z_DEFLATED; - - m_uFlag = 0; - if (m_uMethod == Z_DEFLATED) - switch (iLevel) { - case 1: - m_uFlag |= 6; - break; - case 2: - m_uFlag |= 4; - break; - case 8: - case 9: - m_uFlag |= 2; - break; - } - - if (bSpan || bEncrypted) - m_uFlag |= 8; // data descriptor present - - if (bEncrypted) { - m_uComprSize = ZIPARCHIVE_ENCR_HEADER_LEN; // encrypted header - m_uFlag |= 1; // encrypted file - } - - return !(m_pszComment.GetSize() > USHRT_MAX || - m_pszFileName.GetSize() > USHRT_MAX || - m_pExtraField.GetSize() > USHRT_MAX); -} - -void -CZipFileHeader::GetCrcAndSizes(char* pBuffer) const -{ - memcpy(pBuffer, &m_uCrc32, 4); - memcpy(pBuffer + 4, &m_uComprSize, 4); - memcpy(pBuffer + 8, &m_uUncomprSize, 4); -} - -DWORD -CZipFileHeader::GetSize(bool bLocal) const -{ - if (bLocal) - return LOCALFILEHEADERSIZE + GetExtraFieldSize() + GetFileNameSize(); - else - return FILEHEADERSIZE + GetExtraFieldSize() + GetFileNameSize() + - GetCommentSize(); -} - -bool -CZipFileHeader::SetComment(LPCTSTR lpszComment) -{ - return CZipArchive::WideToSingle(lpszComment, m_pszComment) != -1; -} - -CZipString -CZipFileHeader::GetComment() const -{ - CZipString temp; - CZipArchive::SingleToWide(m_pszComment, temp); - return temp; -} - -bool -CZipFileHeader::SetFileName(LPCTSTR lpszFileName) -{ - - return CZipArchive::WideToSingle(lpszFileName, m_pszFileName) != -1; -} - -CZipString -CZipFileHeader::GetFileName() const -{ - CZipString temp; - CZipArchive::SingleToWide(m_pszFileName, temp); - return temp; -} - -bool -CZipFileHeader::IsDirectory() const -{ - return ZipPlatform::IsDirectory(GetSystemAttr()); -} - -DWORD -CZipFileHeader::GetSystemAttr() const -{ - int iSystemComp = GetSystemCompatibility(); - if (ZipCompatibility::IsPlatformSupported(iSystemComp)) { - if (!m_uExternalAttr && - CZipPathComponent::HasEndingSeparator(GetFileName())) - return ZipPlatform::GetDefaultDirAttributes(); // can happen - else - return ZipCompatibility::ConvertToSystem( - m_uExternalAttr, iSystemComp, ZipPlatform::GetSystemID()); - } else - return CZipPathComponent::HasEndingSeparator(GetFileName()) - ? ZipPlatform::GetDefaultDirAttributes() - : ZipPlatform::GetDefaultAttributes(); -} - -void -CZipFileHeader::SetSystemAttr(DWORD uAttr) -{ - m_uExternalAttr = ZipCompatibility::ConvertToSystem( - uAttr, ZipPlatform::GetSystemID(), GetSystemCompatibility()); -} diff --git a/src/smpackagee/ZipArchive/ZipFileHeader.h b/src/smpackagee/ZipArchive/ZipFileHeader.h deleted file mode 100644 index c2b152fab4..0000000000 --- a/src/smpackagee/ZipArchive/ZipFileHeader.h +++ /dev/null @@ -1,344 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFileHeader.h $ -// $Archive: /ZipArchive/ZipFileHeader.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipFileHeader.h - * Interface for the CZipFileHeader class. - * - */ - -#if !defined(AFX_FILEHEADER_H__0081FC65_C9C9_4D48_AF72_DBF37DF5E0CF__INCLUDED_) -#define AFX_FILEHEADER_H__0081FC65_C9C9_4D48_AF72_DBF37DF5E0CF__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "ZipAutoBuffer.h" -#include "ZipCompatibility.h" -#include "ZipExport.h" -#include "ZipStorage.h" -#include "sys/types.h" -#define ZIPARCHIVE_ENCR_HEADER_LEN 12 - -/** - Representation of a single file stored in the zip archive. - Modify all the class attributes BEFORE adding a file to and archive - ( using CZipArchive::OpenNewFile ). - It is not possible to modify the data of the existing files in the archive - (it would mean updating all the information in the local headers - and the offsets would be changed as well when the filename would changed its - size) -*/ -class ZIP_API CZipFileHeader -{ - friend class CZipCentralDir; - friend class CZipArchive; - friend void ZipCompatibility::FileNameUpdate(CZipFileHeader&, bool); - - public: - CZipFileHeader(); - virtual ~CZipFileHeader(); - - // - /** - Change slash to backslash or vice-versa in #m_pszFileName. - \param bWindowsStyle - if \c true, change slash to backslash; otherwise vice versa; -*/ - - /** - \return the filename size in characters (without NULL) -*/ - WORD GetFileNameSize() const { return (WORD)m_pszFileName.GetSize(); } - - /** - \return the comment size in characters (without NULL) -*/ - WORD GetCommentSize() const { return (WORD)m_pszComment.GetSize(); } - - /** - \return the extra field size in characters -*/ - WORD GetExtraFieldSize() const { return (WORD)m_pExtraField.GetSize(); } - - /** - \return the filename -*/ - CZipString GetFileName() const; - - /* - Set the filename - \param lpszFileName - \return - \c true, if conversion from UNICODE to single byte was successful - (or if there was no conversion needed or possible); otherwise \c false; -*/ - bool SetFileName(LPCTSTR lpszFileName); - - /** - \return the file comment -*/ - CZipString GetComment() const; - - /* - Set the file comment. - \param lpszComment - \return - \c true, if conversion from UNICODE to single byte was successful - (or if there was no conversion needed or possible); otherwise \c false; - -*/ - bool SetComment(LPCTSTR lpszComment); - - /** - \return \c true if the data descriptor is present -*/ - bool IsDataDescr() const { return (m_uFlag & (WORD)8) != 0; } - - /** - \return - get the effective compressed size: if the file is encrypted, return - less by the size of the encryption header - */ - DWORD GetEffComprSize() - { - return m_uComprSize - (IsEncrypted() ? ZIPARCHIVE_ENCR_HEADER_LEN : 0); - } - /** - \return - \c false if the file should be stored instead of being compressed - */ - bool CompressionEfficient() - { - DWORD uBefore = m_uUncomprSize; - // ignore the length of encryption header - DWORD uAfter = GetEffComprSize(); - return uAfter <= uBefore; - } - - /** - \return the compression ratio of the file - */ - float GetCompressionRatio() - { - return m_uUncomprSize ? ((float)m_uComprSize) * 100 / m_uUncomprSize - : 0; - } - - /** - \return \c if the file is encrypted ( a password is needed to extract - this file) \see CZipArchive::SetPassword -*/ - bool IsEncrypted() const { return (m_uFlag & (WORD)1) != 0; } - - char m_szSignature[4]; ///< central file header signature - WORD m_uVersionMadeBy; ///< version made by and system compatibility - WORD m_uVersionNeeded; ///< version needed to extract - WORD m_uFlag; ///< general purpose bit flag - WORD m_uMethod; ///< compression method - WORD m_uModTime; ///< last mod file time - WORD m_uModDate; ///< last mod file date - DWORD m_uCrc32; ///< crc-32 - DWORD m_uComprSize; ///< compressed size - DWORD m_uUncomprSize; ///< uncompressed size - // filename length 2 bytes - // WORD m_uFileNameSize; - // extra field length 2 bytes - // WORD m_uExtraFieldSize; - // file comment length 2 bytes - // WORD m_uCommentSize; - WORD m_uDiskStart; ///< disk number start - WORD m_uInternalAttr; ///< internal file attributes - protected: - DWORD m_uExternalAttr; ///< external file attributes - public: - DWORD m_uOffset; ///< relative offset of local header - CZipAutoBuffer m_pExtraField; ///< extra field (variable size) - static char m_gszSignature[]; ///< central file header signature - static char m_gszLocalSignature[]; ///< local file header signature - - /** - Set #m_uModDate, #m_uModTime - (file modification time) - \param ttime - \see GetTime -*/ - void SetTime(const time_t& ttime); - - /** - \return the modification time - \see SetTime -*/ - time_t GetTime() const; - - /** - \param bLocal - if \c true return the local file header size or in the central directory - otherwise \return the total size of the structure depending on the \e - bLocal parameter -*/ - DWORD GetSize(bool bLocal = false) const; - - /** - \return the system compatibility of the current file as - the one of ZipCompatibility::ZipPlatforms values; - usually the same as CZipArchive::GetSystemComatibility. - Software can use this information e.g. to determine the line - record format for text files etc. - ZipArchive library uses it to perform a proper attributes conversion. - - \see CZipArchive::GetSystemComatibility - \see ZipPlatform::GetSystemID -*/ - int GetSystemCompatibility() const - { - return (m_uVersionMadeBy & 0xFF00) >> 8; - } - - /** - \return the attributes of the file converted to the current system - compatible value \note - - Throws exception if the archive system or the current system - is not supported by the ZipArchive library. - - (only Linux version): After obtaining the attributes, you need to - shift them right by 16 -*/ - - DWORD GetSystemAttr() const; - - /** - \return - the original attributes as stored in the archive (without performing any - conversion) - */ - DWORD GetOriginalAttributes() const { return m_uExternalAttr; } - - /** - \return \c true, if this object represents a directory; otherwise \c false; - If #m_uExternalAttr value is zero, the function check for a presence of a - path separator at the end of the file name. If it is present, it is assumed - to be a directory. -*/ - bool IsDirectory() const; - - protected: - /** - Set the system compatibility of the file. - \param iSystemID - one of ZipCompatibility::ZipPlatforms values - \see CZipArchive::GetSystemCompatibility -*/ - void SetSystemCompatibility(int iSystemID) - { - m_uVersionMadeBy &= 0x00FF; - m_uVersionMadeBy |= (WORD)(iSystemID << 8); - } - - /** - Set the system attributes - if you wish to set the attributes of this structure use - CZipArchive::SetFileHeaderAttr() \param uAttr attributes to set \note Throws - exceptions if the archive system or the current system is not supported by - the ZipArchive library. \see CZipArchive::SetFileHeaderAttr \see - GetSystemAttr \see SetSystemCompatibility -*/ - void SetSystemAttr(DWORD uAttr); - - /** - Set the version made by number. - -*/ - void SetVersion(WORD uVersion) - { - if ((m_uVersionMadeBy & 0x00FF) != (uVersion & 0x00FF)) { - m_uVersionMadeBy &= 0xFF00; - m_uVersionMadeBy |= (WORD)(uVersion & 0x00FF); - } - } - - /** - a filename - */ - CZipAutoBuffer m_pszFileName; - - /** - a file comment - */ - CZipAutoBuffer m_pszComment; - - /** - Fill the buffer with the current values of crc and compressed and - uncompressed sizes of the file. -*/ - void GetCrcAndSizes(char* pBuffer) const; - - /** - Check whether the actual values of crc and compressed and - uncompressed sizes of the file are the same as defined in - the file header. - \param pBuf - buffer with the mentioned data - \return \c true if they are the same; otherwise \c false; -*/ - bool CheckCrcAndSizes(char* pBuf) const; - - /** - Prepare the data for the class while adding a new file. - Called by CZipArchive::OpenNewFile - \param iLevel - a compression level - \param bSpan - \c true, if the data descriptor will be present because of spanning - archive \param bEncrypted \c true, if the file will be encrypted \return - \c true if the sizes of the filename, extra field and comments does not - exceed \c unsigned \c short maximum value; otherwise \c false; -*/ - bool PrepareData(int iLevel, bool bSpan, bool bEncrypted); - /** - Write the local file header to the \e storage - \param storage - \note Throws exceptions. -*/ - void WriteLocal(CZipStorage& storage); - - /** - Read the file header from the central directory record from \e pStorage. - \param *pStorage - \return \c true if the whole file header is on one disk in - a multi-disk archive; otherwise \c false; - \note Throws exceptions. -*/ - bool Read(CZipStorage* pStorage); - /** - Read the local file header from \e pStorage and check for consistency. - \param *pStorage - \param iLocExtrFieldSize - receives local extra field size - \return \c false, if something goes wrong; otherwise \c true; - \note Throws exceptions. -*/ - bool ReadLocal(CZipStorage* pStorage, WORD& iLocExtrFieldSize); - /** - Write the file header to \e pStorage. - \param *pStorage - \return the size of the file header - \note Throws exceptions. -*/ - DWORD Write(CZipStorage* pStorage); -}; - -#endif // !defined(AFX_FILEHEADER_H__0081FC65_C9C9_4D48_AF72_DBF37DF5E0CF__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipFileMapping.h b/src/smpackagee/ZipArchive/ZipFileMapping.h deleted file mode 100644 index cb261b84cd..0000000000 --- a/src/smpackagee/ZipArchive/ZipFileMapping.h +++ /dev/null @@ -1,69 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFileMapping.h $ -// $Archive: /ZipArchive/ZipFileMapping.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -// -// Check the site http://www.artpol-software.com for the updated version of the -// library. -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_) -#define AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "ZipFile.h" -namespace ziparchv { - -struct CZipFileMapping -{ - CZipFileMapping() - { - m_hFileMap = NULL; - m_pFileMap = NULL; - } - bool CreateMapping(CZipFile* pFile) - { - if (!pFile) - return false; - m_hFileMap = CreateFileMapping( - (*pFile), NULL, PAGE_READWRITE, 0, 0, _T("ZipArchive Mapping File")); - if (!m_hFileMap) - return false; - // Get pointer to memory representing file - m_pFileMap = MapViewOfFile(m_hFileMap, FILE_MAP_WRITE, 0, 0, 0); - return (m_pFileMap != NULL); - } - void RemoveMapping() - { - if (m_pFileMap) { - UnmapViewOfFile(m_pFileMap); - m_pFileMap = NULL; - } - if (m_hFileMap) { - CloseHandle(m_hFileMap); - m_hFileMap = NULL; - } - } - ~CZipFileMapping() { RemoveMapping(); } - char* GetMappedMemory() { return reinterpret_cast(m_pFileMap); } - - protected: - HANDLE m_hFileMap; - LPVOID m_pFileMap; -}; -} - -#endif // !defined(AFX_AUTOHANDLE_H__D68326EA_D7FA_4792_AB1F_68D09533E399__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipMemFile.cpp b/src/smpackagee/ZipArchive/ZipMemFile.cpp deleted file mode 100644 index 35ae95c8d7..0000000000 --- a/src/smpackagee/ZipArchive/ZipMemFile.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipMemFile.cpp $ -// $Archive: /ZipArchive/ZipMemFile.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipMemFile.h" -#include "ZipException.h" -#include "stdafx.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -void -CZipMemFile::Grow(size_t nGrowTo) -{ - if (m_nBufSize < (UINT)nGrowTo) { - if (m_nGrowBy == 0) - CZipException::Throw(CZipException::memError); - size_t nNewSize = m_nBufSize; - while (nNewSize < nGrowTo) - nNewSize += m_nGrowBy; - BYTE* lpNew; - if (m_lpBuf) - lpNew = (BYTE*)realloc((void*)m_lpBuf, nNewSize); - else - lpNew = (BYTE*)malloc(nNewSize); - - if (!lpNew) - CZipException::Throw(CZipException::memError); - m_nBufSize = nNewSize; - m_lpBuf = lpNew; - } -} - -void -CZipMemFile::SetLength(ZIP_ULONGLONG nNewLen) -{ - if (m_nBufSize < (UINT)nNewLen) - Grow((size_t)nNewLen); - else - m_nPos = (size_t)nNewLen; - m_nDataSize = (size_t)nNewLen; -} - -UINT -CZipMemFile::Read(void* lpBuf, UINT nCount) -{ - if (m_nPos > m_nDataSize) - return 0; - UINT nToRead = - (m_nPos + nCount > m_nDataSize) ? m_nDataSize - m_nPos : nCount; - memcpy(lpBuf, m_lpBuf + m_nPos, nToRead); - m_nPos += nToRead; - return nToRead; -} - -void -CZipMemFile::Write(const void* lpBuf, UINT nCount) -{ - if (!nCount) - return; - - if (m_nPos + nCount > m_nBufSize) - Grow(m_nPos + nCount); - memcpy(m_lpBuf + m_nPos, lpBuf, nCount); - m_nPos += nCount; - if (m_nPos > m_nDataSize) - m_nDataSize = m_nPos; -} - -ZIP_ULONGLONG -CZipMemFile::Seek(ZIP_LONGLONG lOff, int nFrom) -{ - ZIP_ULONGLONG lNew = m_nPos; - - if (nFrom == CZipAbstractFile::begin) - lNew = lOff; - else if (nFrom == CZipAbstractFile::current) - lNew += lOff; - else if (nFrom == CZipAbstractFile::end) - lNew = m_nDataSize + lOff; - else - return lNew; - - if (lNew < 0) - CZipException::Throw(CZipException::memError); - - m_nPos = (size_t)lNew; - return lNew; -} diff --git a/src/smpackagee/ZipArchive/ZipMemFile.h b/src/smpackagee/ZipArchive/ZipMemFile.h deleted file mode 100644 index 2e1e1afa26..0000000000 --- a/src/smpackagee/ZipArchive/ZipMemFile.h +++ /dev/null @@ -1,105 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipMemFile.h $ -// $Archive: /ZipArchive/ZipMemFile.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipMemFile.h - * Interface for the CZipMemFile class. - * - */ -#if !defined(AFX_ZIPMEMFILE_H__EA73AB25_6B51_4C5E_8D78_BAC95812598F__INCLUDED_) -#define AFX_ZIPMEMFILE_H__EA73AB25_6B51_4C5E_8D78_BAC95812598F__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#include "ZipAbstractFile.h" -#include "ZipExport.h" -#include "ZipString.h" - -/** - A memory buffer which behaves like a physical file. - Automatically grows when necessary -*/ -class ZIP_API CZipMemFile : public CZipAbstractFile -{ - protected: - size_t m_nGrowBy, m_nPos; - size_t m_nBufSize, m_nDataSize; - BYTE* m_lpBuf; - bool m_bAutoDelete; - void Free() - { - if (m_lpBuf) { - free(m_lpBuf); - m_lpBuf = NULL; - } - } - void Init() - { - m_nGrowBy = m_nPos = 0; - m_nBufSize = m_nDataSize = 0; - m_lpBuf = NULL; - } - void Grow(size_t nBytes); - - public: - bool IsClosed() const { return m_lpBuf == NULL; } - void Flush() {} - - ZIP_ULONGLONG Seek(ZIP_LONGLONG lOff, int nFrom); - ZIP_ULONGLONG GetLength() const { return m_nDataSize; } - void Write(const void* lpBuf, UINT nCount); - UINT Read(void* lpBuf, UINT nCount); - void SetLength(ZIP_ULONGLONG nNewLen); - CZipString GetFilePath() const { return _T(""); } - CZipMemFile(long nGrowBy = 1024) - { - Init(); - m_nGrowBy = nGrowBy; - m_bAutoDelete = true; - } - - CZipMemFile(BYTE* lpBuf, UINT nBufSize, long nGrowBy = 0) - { - Init(); - Attach(lpBuf, nBufSize, nGrowBy); - } - ZIP_ULONGLONG GetPosition() const { return m_nPos; } - void Attach(BYTE* lpBuf, UINT nBufSize, long nGrowBy = 0) - { - Close(); - m_lpBuf = lpBuf; - m_nGrowBy = nGrowBy; - m_nBufSize = nBufSize; - m_nDataSize = nGrowBy == 0 ? nBufSize : 0; - m_bAutoDelete = false; - } - BYTE* Detach() - { - BYTE* b = m_lpBuf; - Init(); - return b; - } - void Close() - { - if (m_bAutoDelete) - Free(); - Init(); - } - virtual ~CZipMemFile() { Close(); } -}; - -#endif // !defined(AFX_ZIPMEMFILE_H__EA73AB25_6B51_4C5E_8D78_BAC95812598F__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipPathComponent.cpp b/src/smpackagee/ZipArchive/ZipPathComponent.cpp deleted file mode 100644 index abbaaada45..0000000000 --- a/src/smpackagee/ZipArchive/ZipPathComponent.cpp +++ /dev/null @@ -1,72 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPathComponent.cpp $ -// $Archive: /ZipArchive/ZipPathComponent.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipPathComponent.h" -#include "stdafx.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CZipPathComponent::~CZipPathComponent() {} - -void -CZipPathComponent::SetFullPath(LPCTSTR lpszFullPath) -{ - - TCHAR szDrive[_MAX_DRIVE]; - TCHAR szDir[_MAX_DIR]; - TCHAR szFname[_MAX_FNAME]; - TCHAR szExt[_MAX_EXT]; - - CZipString szTempPath(lpszFullPath); - const CZipString szPrefix = _T("\\\\?\\unc\\"); - int i = -1, iLen = szPrefix.GetLength(); - if (iLen > szTempPath.GetLength()) - iLen = szTempPath.GetLength(); - CZipString szPossiblePrefix = szTempPath.Left(iLen); - szPossiblePrefix.MakeLower(); // must perform case insensitive comparison - while (++i < iLen && szPossiblePrefix[i] == szPrefix[i]) - ; - if (i == 2 || i == 4 || i == 8) // unc path, unicode path or unc path - // meeting windows file name conventions - { - m_szPrefix = szTempPath.Left(i); - szTempPath = szTempPath.Mid(i); - } else - m_szPrefix.Empty(); - - _tsplitpath(szTempPath, szDrive, szDir, szFname, szExt); - m_szDrive = szDrive; - m_szDirectory = szDir; - - m_szDirectory.TrimLeft(m_cSeparator); - m_szDirectory.TrimRight(m_cSeparator); - SetExtension(szExt); - m_szFileTitle = szFname; -} - -CZipString -CZipPathComponent::GetNoDrive() const -{ - CZipString szPath = m_szDirectory; - CZipString szFileName = GetFileName(); - if (!szFileName.IsEmpty() && !szPath.IsEmpty()) - szPath += m_cSeparator; - - szPath += szFileName; - return szPath; -} diff --git a/src/smpackagee/ZipArchive/ZipPathComponent.h b/src/smpackagee/ZipArchive/ZipPathComponent.h deleted file mode 100644 index e268cb3616..0000000000 --- a/src/smpackagee/ZipArchive/ZipPathComponent.h +++ /dev/null @@ -1,195 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPathComponent.h $ -// $Archive: /ZipArchive/ZipPathComponent.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipPathComponent.h - * Interface for the CZipPathComponent class. - * - */ -#if !defined( \ - AFX_ZIPPATHCOMPONENT_H__9B222C08_AD11_4138_96CC_1237511E3E37__INCLUDED_) -#define AFX_ZIPPATHCOMPONENT_H__9B222C08_AD11_4138_96CC_1237511E3E37__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#include "ZipExport.h" -#include "ZipString.h" - -/** - A class splitting a file path into components. -*/ -class ZIP_API CZipPathComponent -{ - public: - CZipPathComponent() {} - virtual ~CZipPathComponent(); - - static const TCHAR m_cSeparator; ///< A system - specific default path - ///< separator. Defined in ZipPlatform.cpp. - /** - Append a path separator to \e szPath if it is not already there. - */ - static void AppendSeparator(CZipString& szPath) - { - RemoveSeparators(szPath); - szPath += m_cSeparator; - } - - /** - Remove separators from the end of \e szPath - */ - static void RemoveSeparators(CZipString& szPath) - { - // szPath.TrimRight(m_cSeparator); - szPath.TrimRight(_T("\\/")); - } - - /** - Remove separators from the beginning of \e szPath - - */ - - static void RemoveSeparatorsLeft(CZipString& szPath) - { - szPath.TrimLeft(_T("\\/")); - } - - /** - \return \c true if \e c is a slash or a backslash - */ - static bool IsSeparator(TCHAR c) { return c == _T('\\') || c == _T('/'); } - - /** - \return \c true if the path has a path separator at the and - */ - static bool HasEndingSeparator(const CZipString& szPath) - { - int iLen = szPath.GetLength(); - if (iLen) - return IsSeparator(szPath[iLen - 1]); - else - return false; - } - - /** - Construct the object and set a path. - \param lpszFullPath - the full path of the file - \see SetFullPath -*/ - CZipPathComponent(LPCTSTR lpszFullPath) { SetFullPath(lpszFullPath); } - - // full path of the file (not a directory alone) - /** - Set the path. - \param lpszFullPath - a full path to the file (including a filename - the last element in the - path is assumed to be a filename) -*/ - void SetFullPath(LPCTSTR lpszFullPath); - - /** - \return the filename (without an extension) -*/ - CZipString GetFileTitle() const { return m_szFileTitle; } - - /** - Set the file title (without an extension). - \param lpszFileTitle - \return -*/ - void SetFileTitle(LPCTSTR lpszFileTitle) { m_szFileTitle = lpszFileTitle; } - - /** - Set the extension alone. - \param lpszExt - may but not have to contain a dot at the beginning -*/ - void SetExtension(LPCTSTR lpszExt) - { - m_szFileExt = lpszExt; - m_szFileExt.TrimLeft(_T('.')); - } - - /** - \return the file extension without a dot -*/ - CZipString GetFileExt() const { return m_szFileExt; } - /** - \return the drive (no path separator at the end) -*/ - CZipString GetFileDrive() const { return m_szDrive; } - /** - \return the full path without the drive (no separator at the beginning) -*/ - CZipString GetNoDrive() const; - - /** - \return the filename including an extension -*/ - CZipString GetFileName() const - { - CZipString szFullFileName = m_szFileTitle; - if (!m_szFileExt.IsEmpty()) { - szFullFileName += _T("."); - szFullFileName += m_szFileExt; - } - return szFullFileName; - } - /** - \return the full path of the file (including the filename) -*/ - CZipString GetFullPath() const - { - CZipString szFullPath = GetFilePath(); - CZipString szFileName = GetFileName(); - if (!szFileName.IsEmpty()) { - szFullPath += m_cSeparator; - szFullPath += szFileName; - } - return szFullPath; - } - /** - \return the path of the file (without the separator at the end) -*/ - CZipString GetFilePath() const - { - CZipString szDrive = m_szDrive; - CZipString szDir = m_szDirectory; - if (!szDrive.IsEmpty() && !szDir.IsEmpty()) - szDrive += m_cSeparator; - - return m_szPrefix + szDrive + szDir; - } - - protected: - /** - \name Path components - */ - //@{ - CZipString m_szDirectory, ///< a directory(ies) (one or more) without the - ///< path separators at the end and the beginning - m_szFileTitle, ///< a filename without an extension - m_szFileExt, ///< a file extension without a dot - m_szDrive, ///< a drive (if the system path standard uses it) without a - ///< path separator at the end - m_szPrefix; ///< a prefix (e.g. for the UNC path or Unicode path under - ///< Windows) - //@} -}; - -#endif // !defined(AFX_ZIPPATHCOMPONENT_H__9B222C08_AD11_4138_96CC_1237511E3E37__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipPlatform.cpp b/src/smpackagee/ZipArchive/ZipPlatform.cpp deleted file mode 100644 index 03d1259351..0000000000 --- a/src/smpackagee/ZipArchive/ZipPlatform.cpp +++ /dev/null @@ -1,370 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPlatform.cpp $ -// $Archive: /ZipArchive/ZipPlatform.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipPlatform.h" -#include "ZipAutoBuffer.h" -#include "ZipException.h" -#include "ZipFileHeader.h" -#include "stdafx.h" -#include - -#if defined _MSC_VER && !defined __BORLANDC__ -#include -#else -#include -#endif - -#include "ZipCompatibility.h" -#include "ZipPathComponent.h" -#include -#include -#include - -const TCHAR CZipPathComponent::m_cSeparator = _T('\\'); - -#ifndef _UTIMBUF_DEFINED -#define _utimbuf utimbuf -#endif - -DWORD -ZipPlatform::GetDeviceFreeSpace(LPCTSTR lpszPath) -{ - DWORD SectorsPerCluster, BytesPerSector, NumberOfFreeClusters, - TotalNumberOfClusters; - CZipPathComponent zpc(lpszPath); - CZipString szDrive = zpc.GetFileDrive(); - if (!GetDiskFreeSpace(szDrive, - &SectorsPerCluster, - &BytesPerSector, - &NumberOfFreeClusters, - &TotalNumberOfClusters)) { - CZipPathComponent::AppendSeparator(szDrive); // in spite of what is - // written in MSDN it is - // sometimes needed (on - // fixed disks) - if (!GetDiskFreeSpace(szDrive, - &SectorsPerCluster, - &BytesPerSector, - &NumberOfFreeClusters, - &TotalNumberOfClusters)) - - return 0; - } - __int64 total = SectorsPerCluster * BytesPerSector * NumberOfFreeClusters; - return (DWORD)total; -} - -bool -ZipPlatform::GetFileSize(LPCTSTR lpszFileName, DWORD& dSize) -{ - HANDLE f = CreateFile(lpszFileName, - GENERIC_READ, - FILE_SHARE_READ, - NULL, - OPEN_EXISTING, - 0, - NULL); - if (!f) - return false; - DWORD dwSize; - dwSize = ::GetFileSize(f, NULL); - CloseHandle(f); - if (dwSize == 0xFFFFFFFF) - return false; - dSize = dwSize; - return true; -} - -CZipString -ZipPlatform::GetTmpFileName(LPCTSTR lpszPath, DWORD iSizeNeeded) -{ - TCHAR empty[] = _T(""); - CZipString tempPath; - bool bCheckTemp = true; - if (lpszPath) { - tempPath = lpszPath; - bCheckTemp = GetDeviceFreeSpace(tempPath) < iSizeNeeded; - } - if (bCheckTemp) { - DWORD size = GetTempPath(0, NULL); - if (size == 0) - return empty; - - GetTempPath(size, tempPath.GetBuffer(size)); - tempPath.ReleaseBuffer(); - if (GetDeviceFreeSpace(tempPath) < iSizeNeeded) { - if (!GetCurrentDirectory(tempPath) || - GetDeviceFreeSpace(tempPath) < iSizeNeeded) - return empty; - } - } - CZipString tempName; - if (!GetTempFileName(tempPath, _T("ZAR"), 0, tempName.GetBuffer(_MAX_PATH))) - return empty; - tempName.ReleaseBuffer(); - return tempName; -} - -bool -ZipPlatform::GetCurrentDirectory(CZipString& sz) -{ - DWORD i = ::GetCurrentDirectory(0, NULL); - if (!i) - return false; - TCHAR* pBuf = new TCHAR[i]; - bool b = true; - if (!::GetCurrentDirectory(i, pBuf)) - b = false; - else - sz = pBuf; - delete[] pBuf; - return b; -} - -bool -ZipPlatform::SetFileAttr(LPCTSTR lpFileName, DWORD uAttr) -{ - return ::SetFileAttributes(lpFileName, uAttr) != 0; -} - -bool -ZipPlatform::GetFileAttr(LPCTSTR lpFileName, DWORD& uAttr) -{ - // not using MFC due to MFC bug (attr is one byte there) - DWORD temp = ::GetFileAttributes(lpFileName); - if (temp == -1) - return false; - uAttr = temp; - return true; -} - -bool -ZipPlatform::GetFileModTime(LPCTSTR lpFileName, time_t& ttime) -{ -#if defined _MSC_VER && !defined __BORLANDC__ - struct _stat st; - if (_tstat(lpFileName, &st) != 0) -#else - struct stat st; - if (stat(lpFileName, &st) != 0) -#endif - return false; - - ttime = st.st_mtime; - return ttime != -1; -} - -bool -ZipPlatform::SetFileModTime(LPCTSTR lpFileName, time_t ttime) -{ - struct _utimbuf ub; - ub.actime = time(NULL); - ub.modtime = ttime == -1 - ? time(NULL) - : ttime; // if wrong file time, set it to the current - return _tutime(lpFileName, &ub) == 0; -} - -bool -ZipPlatform::ChangeDirectory(LPCTSTR lpDirectory) -{ - return _tchdir(lpDirectory) == 0; // returns 0 if ok -} -int -ZipPlatform::FileExists(LPCTSTR lpszName) -{ - if (_taccess(lpszName, 0) == 0) { - if (DirectoryExists(lpszName)) - return -1; - return 1; - } else - return 0; -} - -ZIPINLINE bool -ZipPlatform::IsDriveRemovable(LPCTSTR lpszFilePath) -{ - CZipPathComponent zpc(lpszFilePath); - return ::GetDriveType(zpc.GetFileDrive()) == DRIVE_REMOVABLE; -} - -ZIPINLINE bool -ZipPlatform::SetVolLabel(LPCTSTR lpszPath, LPCTSTR lpszLabel) -{ - CZipPathComponent zpc(lpszPath); - CZipString szDrive = zpc.GetFileDrive(); - CZipPathComponent::AppendSeparator(szDrive); - return ::SetVolumeLabel(szDrive, lpszLabel) != 0; -} - -ZIPINLINE void -ZipPlatform::AnsiOem(CZipAutoBuffer& buffer, bool bAnsiToOem) -{ - if (bAnsiToOem) - CharToOemBuffA(buffer, buffer, buffer.GetSize()); - else - OemToCharBuffA(buffer, buffer, buffer.GetSize()); -} - -ZIPINLINE bool -ZipPlatform::RemoveFile(LPCTSTR lpszFileName, bool bThrow) -{ - if (!::DeleteFile((LPTSTR)lpszFileName)) - if (bThrow) - CZipException::Throw(CZipException::notRemoved, lpszFileName); - else - return false; - return true; -} -ZIPINLINE bool -ZipPlatform::RenameFile(LPCTSTR lpszOldName, LPCTSTR lpszNewName, bool bThrow) -{ - if (!::MoveFile((LPTSTR)lpszOldName, (LPTSTR)lpszNewName)) - if (bThrow) - CZipException::Throw(CZipException::notRenamed, lpszOldName); - else - return false; - return true; -} -ZIPINLINE bool -ZipPlatform::IsDirectory(DWORD uAttr) -{ - return (uAttr & FILE_ATTRIBUTE_DIRECTORY) != 0; -} -ZIPINLINE bool -ZipPlatform::CreateDirectory(LPCTSTR lpDirectory) -{ - return ::CreateDirectory(lpDirectory, NULL) != 0; -} - -ZIPINLINE DWORD -ZipPlatform::GetDefaultAttributes() -{ - return 0x81a40020; // make it readable under Unix -} - -ZIPINLINE DWORD -ZipPlatform::GetDefaultDirAttributes() -{ - return 0x41ff0010; // make it readable under Unix -} - -ZIPINLINE int -ZipPlatform::GetSystemID() -{ - return ZipCompatibility::zcDosFat; -} - -ZIPINLINE bool -ZipPlatform::GetSystemCaseSensitivity() -{ - return false; -} - -#ifdef _UNICODE -int -ZipPlatform::WideToSingle(LPCTSTR lpWide, CZipAutoBuffer& szSingle) -{ - size_t wideLen = wcslen(lpWide); - if (wideLen == 0) { - szSingle.Release(); - return 0; - } - - // iLen does not include terminating character - int iLen = - WideCharToMultiByte(CP_ACP, 0, lpWide, wideLen, szSingle, 0, NULL, NULL); - if (iLen > 0) { - szSingle.Allocate(iLen, true); - iLen = WideCharToMultiByte( - CP_ACP, 0, lpWide, wideLen, szSingle, iLen, NULL, NULL); - ASSERT(iLen != 0); - } else // here it means error - { - szSingle.Release(); - iLen--; - } - return iLen; -} -int -ZipPlatform::SingleToWide(const CZipAutoBuffer& szSingle, CZipString& szWide) -{ - int singleLen = szSingle.GetSize(); - // iLen doesn't include terminating character - int iLen = MultiByteToWideChar( - CP_ACP, MB_PRECOMPOSED, szSingle.GetBuffer(), singleLen, NULL, 0); - if (iLen > 0) { - iLen = MultiByteToWideChar(CP_ACP, - MB_PRECOMPOSED, - szSingle.GetBuffer(), - singleLen, - szWide.GetBuffer(iLen), - iLen); - szWide.ReleaseBuffer(iLen); - ASSERT(iLen != 0); - } else { - szWide.Empty(); - iLen--; // return -1 - } - return iLen; -} -#endif - -#ifndef _MFC_VER -#include -#include -bool -ZipPlatform::TruncateFile(int iDes, DWORD iSize) -{ - int ret = chsize(iDes, iSize); - return ret != -1; -} - -int -ZipPlatform::OpenFile(LPCTSTR lpszFileName, UINT iMode, int iShareMode) -{ - switch (iShareMode) { - case (CZipFile::shareDenyWrite & CZipFile::shareDenyRead): - iShareMode = SH_DENYRW; - break; - case (CZipFile::shareDenyRead): - iShareMode = SH_DENYRD; - break; - case (CZipFile::shareDenyWrite): - iShareMode = SH_DENYWR; - break; - default: - iShareMode = SH_DENYNO; - } - return _tsopen(lpszFileName, - iMode, - iShareMode, - S_IREAD | S_IWRITE /*required only when O_CREAT mode*/); -} - -bool -ZipPlatform::FlushFile(int iDes) -{ - return _commit(iDes) == 0; -} - -int -ZipPlatform::GetFileSystemHandle(int iDes) -{ - return _get_osfhandle(iDes); -} - -#endif //_MFC_VER diff --git a/src/smpackagee/ZipArchive/ZipPlatform.h b/src/smpackagee/ZipArchive/ZipPlatform.h deleted file mode 100644 index 31b0fa3b1c..0000000000 --- a/src/smpackagee/ZipArchive/ZipPlatform.h +++ /dev/null @@ -1,204 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPlatform.h $ -// $Archive: /ZipArchive/ZipPlatform.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipPlatform.h - * ZipPlatform namespace declaration. - * - */ -#if !defined(AFX_ZipPlatform_H__E2FE6343_9D03_4F3C_A1F7_706C9F0ED978__INCLUDED_) -#define AFX_ZipPlatform_H__E2FE6343_9D03_4F3C_A1F7_706C9F0ED978__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -class CZipFileHeader; -class CZipAutoBuffer; -#include "ZipExport.h" -#include "ZipPathComponent.h" -#include "ZipString.h" -#include - -/** - Interface to the system API. - All functions have a system - specific implementation . -*/ -namespace ZipPlatform { - -/** - return the default system case-sensitivity - */ -ZIP_API bool -GetSystemCaseSensitivity(); - -/** - \return A current system name tag. - May be one of ZipCompatibility::ZipPlatforms values. - \see CZipArchive::GetSystemCompatibility - */ -ZIP_API int -GetSystemID(); - -/** - \return the default file attributes for the current system -*/ -ZIP_API DWORD -GetDefaultAttributes(); - -/** - \return the default directory attributes for the current system -*/ -ZIP_API DWORD -GetDefaultDirAttributes(); - -/** - Get the free space on the device pointed by \e lpszPath -*/ -ZIP_API DWORD -GetDeviceFreeSpace(LPCTSTR lpszPath); - -/** - Return the temporary file name ensuring there is enough size in the - destination directory,. Checking for the size is disabled by default. -*/ -ZIP_API CZipString -GetTmpFileName(LPCTSTR lpszPath = NULL, DWORD iSizeNeeded = DWORD(-1)); -/** - \name Various operations on files and directories. - All the functions which are returning a \c bool value, - return \c true when the operation was successful. -*/ -//@{ -ZIP_API bool -GetCurrentDirectory( - CZipString& sz); ///< Get the current directory and store it in \e sz -ZIP_API bool -ChangeDirectory(LPCTSTR lpDirectory); -ZIP_API bool -SetFileAttr(LPCTSTR lpFileName, DWORD uAttr); -ZIP_API bool -GetFileAttr(LPCTSTR lpFileName, DWORD& uAttr); -ZIP_API bool -GetFileModTime(LPCTSTR lpFileName, - time_t& ttime); ///< get the file modification time -ZIP_API bool -GetFileSize(LPCTSTR lpszFileName, DWORD& dSize); -ZIP_API bool -SetFileModTime(LPCTSTR lpFileName, - time_t ttime); ///< set the file modification time -ZIP_API bool -CreateDirectory(LPCTSTR lpDirectory); -ZIP_API bool -SetVolLabel( - LPCTSTR lpszPath, - LPCTSTR lpszLabel); ///< \c lpszPath may point to a file on the device -ZIP_API bool -ForceDirectory(LPCTSTR lpDirectory); ///< create nested directories at once -ZIP_API bool -RemoveFile(LPCTSTR lpszFileName, bool bThrow = true); -ZIP_API bool -RenameFile(LPCTSTR lpszOldName, LPCTSTR lpszNewName, bool bThrow = true); - -#ifndef _MFC_VER -ZIP_API bool -TruncateFile(int iDes, DWORD iSize); -ZIP_API int -OpenFile(LPCTSTR lpszFileName, UINT iMode, int iShareMode); -ZIP_API bool -FlushFile(int iDes); ///< flush the file to the disk. -ZIP_API int -GetFileSystemHandle(int iDes); ///< return the underlying system handle -#endif -//@} - -/* - \param lpszDir - \return \c true, if \e lpszDir directory exists; otherwise \c false; -*/ -ZIP_API bool -DirectoryExists(LPCTSTR lpszDir); -/** - \param lpszFilePath - may point to a file path or a directory on the device - \return \c true if the drive is removable. - Implemented only on Windows system, in all others always returns \c true. -*/ -ZIP_API bool -IsDriveRemovable(LPCTSTR lpszFilePath); -/** - \param uAttr - attributes value to test - \return \c true if the attributes are the directory attributes -*/ -ZIP_API bool -IsDirectory(DWORD uAttr); - -/** - Perform the translation between ANSI and OEM character sets. - \remark - - The conversion is performed only for the zip archives created under - Windows platform. - - Windows archiving programs convert a filename to OEM before adding it to - the archive. - - OEM conversion only influences the ANSI values above 126, so it - affects only strings containing international characters. - - \param buffer - buffer to be translated - \param bAnsiToOem - if \c true, convert ANSI to OEM - if \c false, OEM to ANSI -*/ -ZIP_API void -AnsiOem(CZipAutoBuffer& buffer, bool bAnsiToOem); -/** - Check if the given file or directory exists. - \param lpszName - \return - - -1 if the given file is a directory - - 1 a file - - 0 if there is no such a file -*/ -ZIP_API int -FileExists(LPCTSTR lpszName); - -#ifdef _UNICODE -/** - Convert wide character string to single character string. - \param lpWide - Wide string to convert - \param szSingle - buffer to receive converted string (without the terminating NULL - character) \return the \e szSingle buffer length, or \c -1 when not succeeded - \note Only in UNICODE version. -*/ -ZIP_API int -WideToSingle(LPCTSTR lpWide, CZipAutoBuffer& szSingle); -/** - Convert single character string to wide character string. - \param szSingle - single string to convert (no terminating NULL character at the end) - \param szWide - receives the wide string after the conversion - \return \e the length of the string after the conversion (without the - NULL character), or \c -1 when not succeeded \note Only in UNICODE version. -*/ -ZIP_API int -SingleToWide(const CZipAutoBuffer& szSingle, CZipString& szWide); -#endif -}; - -#endif // !defined(AFX_ZipPlatform_H__E2FE6343_9D03_4F3C_A1F7_706C9F0ED978__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipPlatformComm.cpp b/src/smpackagee/ZipArchive/ZipPlatformComm.cpp deleted file mode 100644 index 77e53e5f61..0000000000 --- a/src/smpackagee/ZipArchive/ZipPlatformComm.cpp +++ /dev/null @@ -1,48 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipPlatformComm.cpp $ -// $Archive: /ZipArchive/ZipPlatformComm.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipPlatform.h" -#include "stdafx.h" - -using namespace ZipPlatform; - -bool -ZipPlatform::DirectoryExists(LPCTSTR lpszDir) -{ - CZipString sz; - if (!GetCurrentDirectory(sz)) - return false; - if (!ChangeDirectory(lpszDir)) - return false; - ChangeDirectory(sz); - return true; -} - -bool -ZipPlatform::ForceDirectory(LPCTSTR lpDirectory) -{ - ASSERT(lpDirectory); - CZipString szDirectory = lpDirectory; - szDirectory.TrimRight(CZipPathComponent::m_cSeparator); - CZipPathComponent zpc(szDirectory); - if ((zpc.GetFilePath() == szDirectory) || (FileExists(szDirectory) == -1)) - return true; - if (!ForceDirectory(zpc.GetFilePath())) - return false; - if (!CreateDirectory(szDirectory)) - return false; - return true; -} diff --git a/src/smpackagee/ZipArchive/ZipStorage.cpp b/src/smpackagee/ZipArchive/ZipStorage.cpp deleted file mode 100644 index ff0bfd0460..0000000000 --- a/src/smpackagee/ZipArchive/ZipStorage.cpp +++ /dev/null @@ -1,447 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipStorage.cpp $ -// $Archive: /ZipArchive/ZipStorage.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipStorage.h" -#include "ZipArchive.h" -#include "stdafx.h" -// #include "ZipPathComponent.h" -#include "ZipPlatform.h" - -////////////////////////////////////////////////////////////////////// -// disk spanning objectives: -// - sinature at the first disk at the beginning -// - headers and central dir records not divided between disks -// - each file has a data descriptor preceded by the signature -// (bit 3 set in flag); - -int CZipActionCallback::m_iStep = 256; - -char CZipStorage::m_gszExtHeaderSignat[] = { 0x50, 0x4b, 0x07, 0x08 }; -CZipStorage::CZipStorage() -{ - m_pChangeDiskFunc = NULL; - m_iWriteBufferSize = 65536; - m_iCurrentDisk = -1; - m_pFile = NULL; -} - -CZipStorage::~CZipStorage() {} - -DWORD -CZipStorage::Read(void* pBuf, DWORD iSize, bool bAtOnce) -{ - if (iSize == 0) - return 0; - DWORD iRead = 0; - while (!iRead) { - iRead = m_pFile->Read(pBuf, iSize); - if (!iRead) - if (IsSpanMode()) - ChangeDisk(m_iCurrentDisk + 1); - else - ThrowError(CZipException::badZipFile); - } - - if (iRead == iSize) - return iRead; - else if (bAtOnce || !IsSpanMode()) - ThrowError(CZipException::badZipFile); - - while (iRead < iSize) { - ChangeDisk(m_iCurrentDisk + 1); - UINT iNewRead = m_pFile->Read((char*)pBuf + iRead, iSize - iRead); - if (!iNewRead && iRead < iSize) - ThrowError(CZipException::badZipFile); - iRead += iNewRead; - } - - return iRead; -} - -void -CZipStorage::Open(LPCTSTR szPathName, int iMode, int iVolumeSize) -{ - m_pWriteBuffer.Allocate(m_iWriteBufferSize); - m_uBytesInWriteBuffer = 0; - m_bNewSpan = false; - m_pFile = &m_internalfile; - m_bInMemory = false; - - if ((iMode == CZipArchive::zipCreate) || - (iMode == CZipArchive::zipCreateSpan)) // create new archive - { - m_bReadOnly = false; - m_iCurrentDisk = 0; - if (iMode == CZipArchive::zipCreate) { - m_iSpanMode = noSpan; - OpenFile(szPathName, - CZipFile::modeCreate | CZipFile::modeReadWrite); - } else // create disk spanning archive - { - m_bNewSpan = true; - m_iBytesWritten = 0; - if (iVolumeSize <= 0) // pkzip span - { - if (!m_pChangeDiskFunc) - ThrowError(CZipException::noCallback); - if (!ZipPlatform::IsDriveRemovable(szPathName)) - ThrowError(CZipException::nonRemovable); - m_iSpanMode = pkzipSpan; - } else { - m_iTdSpanData = iVolumeSize; - m_iSpanMode = tdSpan; - } - - NextDisk(4, szPathName); - Write(m_gszExtHeaderSignat, 4, true); - } - } else // open existing - { - m_bReadOnly = iMode == CZipArchive::zipOpenReadOnly; - OpenFile( - szPathName, - CZipFile::modeNoTruncate | - (m_bReadOnly ? CZipFile::modeRead : CZipFile::modeReadWrite)); - // m_uData, i m_iSpanMode are automatically set during reading the - // central dir - m_iSpanMode = iVolumeSize == 0 ? suggestedAuto : suggestedTd; - } -} - -void -CZipStorage::Open(CZipMemFile& mf, int iMode) -{ - m_pWriteBuffer.Allocate(m_iWriteBufferSize); - m_uBytesInWriteBuffer = 0; - m_bNewSpan = false; - m_pFile = &mf; - m_bInMemory = true; - - if (iMode == CZipArchive::zipCreate) { - m_iCurrentDisk = 0; - m_iSpanMode = noSpan; - mf.SetLength(0); - } else // open existing - { - mf.SeekToBegin(); - m_iSpanMode = suggestedAuto; - } -} - -void -CZipStorage::ChangeDisk(int iNumber) -{ - if (iNumber == m_iCurrentDisk) - return; - - ASSERT(m_iSpanMode != noSpan); - m_iCurrentDisk = iNumber; - OpenFile(m_iSpanMode == pkzipSpan ? ChangePkzipRead() : ChangeTdRead(), - CZipFile::modeNoTruncate | CZipFile::modeRead); -} - -void -CZipStorage::ThrowError(int err) -{ - CZipException::Throw(err, m_pFile->GetFilePath()); -} - -bool -CZipStorage::OpenFile(LPCTSTR lpszName, UINT uFlags, bool bThrow) -{ - return m_pFile->Open(lpszName, uFlags | CZipFile::shareDenyWrite, bThrow); -} - -CZipString -CZipStorage::ChangePkzipRead() -{ - CZipString szTemp = m_pFile->GetFilePath(); - m_pFile->Close(); - CallCallback(-1, szTemp); - return szTemp; -} - -CZipString -CZipStorage::ChangeTdRead() -{ - CZipString szTemp = GetTdVolumeName(m_iCurrentDisk == m_iTdSpanData); - m_pFile->Close(); - return szTemp; -} - -CZipString -CZipStorage::RenameLastFileInTDSpan() -{ - ASSERT(m_iSpanMode == tdSpan); - // give to the last volume the zip extension - CZipString szFileName = m_pFile->GetFilePath(); - CZipString szNewFileName = GetTdVolumeName(true); - if (!m_bInMemory) { - m_pFile->Flush(); - m_pFile->Close(); - } - if (ZipPlatform::FileExists(szNewFileName)) - ZipPlatform::RemoveFile(szNewFileName); - ZipPlatform::RenameFile(szFileName, szNewFileName); - return szNewFileName; -} - -CZipString -CZipStorage::Close(bool bAfterException) -{ - bool bClose = true; - CZipString sz; - if (!bAfterException) { - Flush(); - if ((m_iSpanMode == tdSpan) && (m_bNewSpan)) { - sz = RenameLastFileInTDSpan(); - bClose = false; // already closed in RenameLastFileInTDSpan - } - } - if (sz.IsEmpty()) - sz = m_pFile->GetFilePath(); - if (bClose && !m_bInMemory) { - FlushFile(); - m_pFile->Close(); - } - - m_pWriteBuffer.Release(); - m_iCurrentDisk = -1; - m_iSpanMode = noSpan; - m_pFile = NULL; - return sz; -} - -CZipString -CZipStorage::GetTdVolumeName(bool bLast, LPCTSTR lpszZipName) const -{ - CZipString szFilePath = - lpszZipName ? lpszZipName : (LPCTSTR)m_pFile->GetFilePath(); - CZipPathComponent zpc(szFilePath); - CZipString szExt; - if (bLast) - szExt = m_szSpanExtension; - else - szExt.Format(_T("%.3d"), m_iCurrentDisk); - zpc.SetExtension(szExt); - return zpc.GetFullPath(); -} - -void -CZipStorage::NextDisk(int iNeeded, LPCTSTR lpszFileName) -{ - Flush(); - ASSERT(m_iSpanMode != noSpan); - if (m_iBytesWritten) { - m_iBytesWritten = 0; - m_iCurrentDisk++; - if (m_iCurrentDisk >= 999) - ThrowError(CZipException::tooManyVolumes); - } - CZipString szFileName; - bool bPkSpan = (m_iSpanMode == pkzipSpan); - if (bPkSpan) - szFileName = - lpszFileName ? lpszFileName : (LPCTSTR)m_pFile->GetFilePath(); - else - szFileName = GetTdVolumeName(false, lpszFileName); - - if (!m_pFile->IsClosed()) { - m_pFile->Flush(); - m_pFile->Close(); - } - - if (bPkSpan) { - int iCode = iNeeded; - while (true) { - CallCallback(iCode, szFileName); - if (ZipPlatform::FileExists(szFileName)) - iCode = -2; - else { - CZipString label; - label.Format(_T("pkback# %.3d"), m_iCurrentDisk + 1); - if (!ZipPlatform::SetVolLabel(szFileName, label)) - iCode = -3; - else if (!OpenFile(szFileName, - CZipFile::modeCreate | - CZipFile::modeReadWrite, - false)) - iCode = -4; - else - break; - } - } - m_uCurrentVolSize = GetFreeVolumeSpace(); - } else { - m_uCurrentVolSize = m_iTdSpanData; - OpenFile(szFileName, CZipFile::modeCreate | CZipFile::modeReadWrite); - } -} - -void -CZipStorage::CallCallback(int iCode, CZipString szTemp) -{ - ASSERT(m_pChangeDiskFunc); - m_pChangeDiskFunc->m_szExternalFile = szTemp; - m_pChangeDiskFunc->m_uDiskNeeded = m_iCurrentDisk + 1; - if (!m_pChangeDiskFunc->Callback(iCode)) - CZipException::Throw(CZipException::aborted, szTemp); -} - -DWORD -CZipStorage::GetFreeVolumeSpace() const -{ - ASSERT(m_iSpanMode == pkzipSpan); - CZipString szTemp = m_pFile->GetFilePath(); - if (szTemp.IsEmpty()) // called once when creating a disk spanning archive - return 0; - else { - CZipPathComponent zpc(szTemp); - return ZipPlatform::GetDeviceFreeSpace(zpc.GetFilePath()); - } -} - -void -CZipStorage::UpdateSpanMode(WORD uLastDisk) -{ - m_iCurrentDisk = uLastDisk; - if (uLastDisk) { - // disk spanning detected - CZipString szFilePath = m_pFile->GetFilePath(); - if (m_iSpanMode == suggestedAuto) - m_iSpanMode = - ZipPlatform::IsDriveRemovable(szFilePath) ? pkzipSpan : tdSpan; - else { - ASSERT(m_iSpanMode == suggestedTd); - m_iSpanMode = tdSpan; - } - - if (m_iSpanMode == pkzipSpan) { - if (!m_pChangeDiskFunc) - ThrowError(CZipException::noCallback); - } else /*if (m_iSpanMode == tdSpan)*/ - m_iTdSpanData = - uLastDisk; // disk with .zip extension ( the last one) - CZipPathComponent zpc(szFilePath); - m_szSpanExtension = zpc.GetFileExt(); - m_pWriteBuffer.Release(); // no need for this in this case - } else - m_iSpanMode = noSpan; -} - -void -CZipStorage::Write(const void* pBuf, DWORD iSize, bool bAtOnce) -{ - if (!IsSpanMode()) - WriteInternalBuffer((char*)pBuf, iSize); - else { - // if not at once, one byte is enough free space - DWORD iNeeded = bAtOnce ? iSize : 1; - DWORD uTotal = 0; - - while (uTotal < iSize) { - DWORD uFree; - while ((uFree = VolumeLeft()) < iNeeded) { - if ((m_iSpanMode == tdSpan) && !m_iBytesWritten && - !m_uBytesInWriteBuffer) - // in the tdSpan mode, if the size of the archive is less - // than the size of the packet to be written at once, - // increase once the size of the volume - m_uCurrentVolSize = iNeeded; - else - NextDisk(iNeeded); - } - - DWORD uLeftToWrite = iSize - uTotal; - DWORD uToWrite = uFree < uLeftToWrite ? uFree : uLeftToWrite; - WriteInternalBuffer((char*)pBuf + uTotal, uToWrite); - if (bAtOnce) - return; - else - uTotal += uToWrite; - } - } -} - -void -CZipStorage::WriteInternalBuffer(const char* pBuf, DWORD uSize) -{ - DWORD uWritten = 0; - while (uWritten < uSize) { - DWORD uFreeInBuffer = GetFreeInBuffer(); - if (uFreeInBuffer == 0) { - Flush(); - uFreeInBuffer = m_pWriteBuffer.GetSize(); - } - DWORD uLeftToWrite = uSize - uWritten; - DWORD uToCopy = - uLeftToWrite < uFreeInBuffer ? uLeftToWrite : uFreeInBuffer; - memcpy( - m_pWriteBuffer + m_uBytesInWriteBuffer, pBuf + uWritten, uToCopy); - uWritten += uToCopy; - m_uBytesInWriteBuffer += uToCopy; - } -} - -DWORD -CZipStorage::VolumeLeft() const -{ - // for pkzip span m_uCurrentVolSize is updated after each flush() - return m_uCurrentVolSize - m_uBytesInWriteBuffer - - ((m_iSpanMode == pkzipSpan) ? 0 : m_iBytesWritten); -} - -void -CZipStorage::Flush() -{ - if (m_iSpanMode != noSpan) - m_iBytesWritten += m_uBytesInWriteBuffer; - if (m_uBytesInWriteBuffer) { - m_pFile->Write(m_pWriteBuffer, m_uBytesInWriteBuffer); - m_uBytesInWriteBuffer = 0; - } - if (m_iSpanMode == pkzipSpan) - // after writing it is difficult to predict the free space due to - // not completly written clusters, write operation may start from - // the new cluster - m_uCurrentVolSize = GetFreeVolumeSpace(); -} - -void -CZipStorage::FinalizeSpan() -{ - ASSERT(IsSpanMode() == 1); // span in creation - ASSERT(!m_bInMemory); - - CZipString szFileName; - if ((m_iSpanMode == tdSpan) && (m_bNewSpan)) - szFileName = RenameLastFileInTDSpan(); - else { - szFileName = m_pFile->GetFilePath(); - // the file is already closed - m_pFile->Close(); - } - m_bNewSpan = false; - if (m_iCurrentDisk == 0) // one-disk span was converted to normal archive - m_iSpanMode = noSpan; - else - m_iTdSpanData = m_iCurrentDisk; - - OpenFile( - szFileName, - CZipFile::modeNoTruncate | - (m_iSpanMode == noSpan ? CZipFile::modeReadWrite : CZipFile::modeRead)); -} diff --git a/src/smpackagee/ZipArchive/ZipStorage.h b/src/smpackagee/ZipArchive/ZipStorage.h deleted file mode 100644 index 89fbdabf9e..0000000000 --- a/src/smpackagee/ZipArchive/ZipStorage.h +++ /dev/null @@ -1,579 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipStorage.h $ -// $Archive: /ZipArchive/ZipStorage.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $. -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -/** - * \file ZipStorage.h - * Interface for the CZipStorage class. - * - */ - -#if !defined(AFX_ZIPSTORAGE_H__941824FE_3320_4794_BDE3_BE334ED8984B__INCLUDED_) -#define AFX_ZIPSTORAGE_H__941824FE_3320_4794_BDE3_BE334ED8984B__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "ZipAutoBuffer.h" -#include "ZipExport.h" -#include "ZipFile.h" -#include "ZipMemFile.h" -#include "ZipString.h" - -/** - A base class for functional objects (functors) that are used as a callbacks - during various actions. You need to derive your own class and overload \c - Callback method to use it. Do not derive from CZipCallback directly but from - CZipSpanCallback (as a callback when there is a need for a disk change in a - disk-spanning archive) or from CZipActionCallback for other actions. -*/ -struct ZIP_API CZipCallback -{ - /** - Method called as a callback. - Return \c false from inside the method to abort the current operation. - If it is a span callback functor, a CZipException with - CZipException::aborted code will be thrown, otherwise the code will be - CZipException::abortedAction or CZipException::abortedSafely. The - following actions can be safely aborted (without having the archive - corrupted): - - counting bytes before deleting files - - testing - - saving central directory on non-disk-spanning archive - (saved data is removed in case of break and you can save it again); - it the archive is disk-spanning and if saving is aborted, the archive - will not be damaged, but saved part of the central directory will be not - removed and the new central directory will have to be saved after it - - \note Overrride this method in the derived class. If you define this - method inside the class declaration, it should be inlined by the compiler - making the action progress faster. - */ - virtual bool Callback(int iProgress) = 0; - - CZipString m_szExternalFile; ///< if the action (adding, extracting or - ///< disk-spanning) uses an external file, its - ///< filename is stored here -}; - -/** - Derive from this a class to be used as a callback functor for the disk - change callback. You need to override member function CZipCallback::Callback. - The meaning of \e iProgress parameter is the reason for calling: - - -1 : a disk needed for reading
- other codes occurs during writing: - - >=0 : min. number of bytes needed - - -2 : the file with the archive name already exists on the disk - - -3 : the disk is probably write - protected - - -4 : couldn't create a file - Return \c false from the callback function to abort operation: the proper - exception will be thrown. - - \see CZipCallback::Callback - \see CZipArchive::SetSpanCallback -*/ -struct ZIP_API CZipSpanCallback : public CZipCallback -{ - DWORD m_uDiskNeeded; ///< the number of a disk needed (counting from 1) -}; - -/** - Derive from this a class to be used as a callback functors when adding, - extracting, deleting, testing a file or saving central directory. You need to - override member function CZipCallback::Callback. The meaning of \e iProgress - parameter is the count of data just processed. It is a smallest number of - bytes after which the callback method is called and it depends on the value - of \e nBufSize in the CZipArchive methods that uses the callback feature. In - case of saving the central directory action it is the count of file headers - just written (see CZipArchive::cbSave) \see CZipCallback::Callback \see - CZipArchive::SetCallback -*/ -struct ZIP_API CZipActionCallback : public CZipCallback -{ - - CZipActionCallback() - { - m_uTotalToDo = 0; - m_uTotalSoFar = 0; - } - - /** - The type of the callback. It is set to one of CZipArchive::CallbackType - values when the action begins. It's useful if you have more than one - callback assigned to the same functor. - */ - int m_iType; - - /** - Used by the ZipArchive library to init the callback function with the - filenames. Resets #m_uTotalToDo and #m_uTotalSoFar variables to 0. - #m_iType variable is already set to the proper value. Called at the - beginning of the action. - */ - virtual void Init(LPCTSTR lpszFileInZip = NULL, - LPCTSTR lpszExternalFile = NULL) - { - m_szFileInZip = lpszFileInZip; - m_szExternalFile = lpszExternalFile; - m_uTotalToDo = 0; // not yet known - m_uTotalSoFar = 0; // nothing yet done - } - - /** - Called by the ZipArchive functions that use the callback feature after - calculating total data to process. \param uTotalToDo total data to - process; set #m_uTotalToDo to this value - */ - virtual void SetTotal(DWORD uTotalToDo) - { - m_uTotalToDo = uTotalToDo; - // m_uTotalSoFar = 0; // already done in - // CZipArchive::CZipClbckStrg::Get - } - - /** - Total number of data to process. The value of this variable is set after - calling by the library #SetTotal method (it is 0 before). Depending on - the action it is set then to: - - adding file: the size the external file being added (or if callback is - CZipArchive::cbAddTmp, the size of compressed data: - CZipFileHeader::m_uComprSize) - - extracting file: the size of uncompressed data - (CZipFileHeader::m_uUncomprSize) - - testing file: the same as above - - deleting file: the count of bytes to move - the size of all files to - remain above the first file to delete (calculated from offsets - CZipFileHeader::m_uOffset - - saving central directory: the number of files in the archive - - */ - DWORD m_uTotalToDo; - DWORD m_uTotalSoFar; ///< total number of bytes processed so far - CZipString m_szFileInZip; ///< file in zip archive being currently processed - - /** - \return the number of bytes left to process - */ - DWORD LeftToDo() { return m_uTotalToDo - m_uTotalSoFar; } - - /** - Called after the action finishes (it is not called in case of an - exception, but it is called before throwing CZipException::abortedAction - or CZipException::abortedSafely) - */ - virtual void CallbackEnd() { ASSERT(m_uTotalSoFar == m_uTotalToDo); }; - - /** - Used internally to call Callback and increase #m_uTotalSoFar by \e - iProgress - */ - virtual bool operator()(int iProgress) - { - m_uTotalSoFar += iProgress; - return Callback(iProgress); - } - - /** - Used only when creating map before deletion (see - CZipArchive::cbDeleteCnt) or saving the central directory record. You'll - be notified every nth step (n is \e m_iStep value) with \e iProgress set - to \e m_iStep . Do not set it to low values or you can have a long - waiting on archives with huge number of files. - - \b Default: 256. - */ - static int m_iStep; - - /** - Used internally to return #m_iStep value but not 0 (return 1 in this - case). - */ - int GetStep() { return m_iStep ? m_iStep : 1; } // do not allow 0 (crash) -}; - -/** - A low-level class - operates physically on archive (CZipArchive operates - logically) -*/ -class ZIP_API CZipStorage -{ - friend class CZipCentralDir; - - public: - /** - The type of the disk spanning archive. - \see CZipArchive::GetSpanMode - */ - enum ZipSpanMode - { - noSpan, ///< no disk spanning - pkzipSpan, ///< \ref PKSpan "disk spanning compatible with PKZIP" - tdSpan, ///< \ref TDSpan "TD mode disk spanning archive" - /** - Detect the type automatically. - If the archive is on the removable device assume PKZIP - compatible, otherwise TD mode compatible. - */ - suggestedAuto, - /** - If the disk spanning archive is on the removable device - assume it is TD mode compatible - */ - suggestedTd - }; - - CZipStorage(); - virtual ~CZipStorage(); - - /* - Open the archive in memory (new or existing). - The parameters are the same as CZipArchive::OpenMode. - \param mf - \param iMode - \note Throws exceptions - \see CZipArchive::Open(LPCTSTR, int, int) -*/ - void Open(CZipMemFile& mf, int iMode); - - /* - Open or create an archive. - The parameters are the same as CZipArchive::Open. - \param szPathName - \param iMode - \param iVolumeSize - \note Throws exceptions - \see CZipArchive::Open(CZipMemFile& , int); -*/ - void Open(LPCTSTR szPathName, int iMode, int iVolumeSize); - - /** - Close the disk-spanning archive and reopens as an existing disk-spanning - archive or set mode to #noSpan - */ - void FinalizeSpan(); - - /** - Called only by CZipCentralDir::Read() when opening an existing archive. - \param uLastDisk - the disk number the central directory is on - \note Throws exceptions. - -*/ - void UpdateSpanMode(WORD uLastDisk); - - /** - Write chunk of data to the archive. - \param pBuf - buffer with data - \param iSize - bytes to write - \param bAtOnce - if \c true, the whole data must fit in the current volume, - otherwise the disk change is performed - \note Throws exceptions. -*/ - void Write(const void* pBuf, DWORD iSize, bool bAtOnce); - - /** - Read chunk of data from the archive. - \param pBuf - buffer to receive data - \param iSize - bytes to read - \param bAtOnce - if \c true, the specified number of bytes must be read from the same - volume (no disk change allowed) - \note Throws exceptions. -*/ - DWORD Read(void* pBuf, DWORD iSize, bool bAtOnce); - - /** - Return the position in the file, taking into account the bytes in the - write buffer. \note Throws exceptions. - */ - DWORD GetPosition() const - { - return (DWORD)(m_pFile->GetPosition()) + m_uBytesInWriteBuffer; - } - - /** - Flush the data from the read buffer to the disk. - \note Throws exceptions. - */ - void Flush(); - - /** - Forces any data remaining in the file buffer to be written to the disk - */ - void FlushFile() - { - if (!m_bInMemory && !IsReadOnly()) - m_pFile->Flush(); - } - - /** - A method used to change disks during writing to the disk spanning archive. - \param iNeeded - no of bytes needed on the disk - \param lpszFileName - the archive filename - \note Throws exceptions. -*/ - void NextDisk(int iNeeded, LPCTSTR lpszFileName = NULL); - - /** - \return a zero-based number of the current disk -*/ - int GetCurrentDisk() const { return m_iCurrentDisk; } - - /** - Change the disk during extract operations. - \param iNumber - a zero-based disk number requested - \return -*/ - void ChangeDisk(int iNumber); - - /** - Detect the span mode. - \return - - -1 - existing disk spanning archive opened - - 0 - no disk spanning archive - - 1 - disk spanning archive in creation - -*/ - int IsSpanMode() const - { - return m_iSpanMode == noSpan ? 0 : (m_bNewSpan ? 1 : -1); - } - - /** - return \c true if the archive cannot be modified. - */ - bool IsReadOnly() { return m_bReadOnly || IsSpanMode() < 0; } - - /* - \param bAfterException - set to \c true after the library has throw an exception. - The simplified mode is used then. - In this case it'll be possible to reuse the object to operate on another - archive, but the current archive file will not be valid anyway. - \return the filepath of the archive (used by CZipArchive::Close) - \note Throws exceptions. -*/ - CZipString Close(bool bAfterException); - - /** - The size of the write buffer. - Set before opening the archive. - It is usually set with CZipArchive::SetAdvanced - (specify this value as the first argument). - \see CZipArchive::SetAdvanced - */ - int m_iWriteBufferSize; - - /** - The physical archive file (on a storage device). - Not used when opening archive in memory - with Open(CZipMemFile& , int). - */ - CZipFile m_internalfile; - - /* - The buffer representing the archive. - It is a physical file or a memory buffer depending on what - method was used to open the archive. In the first case it is - a pointer to #m_internalfile. - \see Open(LPCTSTR, int, int); - \see Open(CZipMemFile& mf, int) - */ - CZipAbstractFile* m_pFile; - - /** - Takes one of the values of #ZipSpanMode. - */ - int m_iSpanMode; - - /** - A callback functor which method \c Callback is called when there is a - need for a disk change while operating on a #pkzipSpan archive. \see - CZipArchive::SetSpanCallback - */ - CZipSpanCallback* m_pChangeDiskFunc; - - /** - The signature of the extended header - */ - static char m_gszExtHeaderSignat[]; - - protected: - /** - Flush without writing. Can be used only on non-disk spanning archives. - */ - void EmptyWriteBuffer() { m_uBytesInWriteBuffer = 0; } - - /** - Open a physical file. - \param lpszName - the name of the file to open - \param uFlags - file open flags - \param bThrow - if \c true then throw an exception in case of failure - \return \c true if successful -*/ - bool OpenFile(LPCTSTR lpszName, UINT uFlags, bool bThrow = true); - /** - Throw an exception with the given code. - \param err - \see CZipException::Throw -*/ - void ThrowError(int err); - - /** - Return the number of bytes left on the current volume. -*/ - DWORD VolumeLeft() const; - - /** - Rename last file in TD mode disk spanning archive when done with - creating - */ - CZipString RenameLastFileInTDSpan(); - /** - Write data to the internal buffer. - \param *pBuf - the buffer to copy data from - \param uSize - bytes to write - \note Throws exceptions. -*/ - void WriteInternalBuffer(const char* pBuf, DWORD uSize); - - /** - \return the number of free bytes on the current removable disk -*/ - DWORD GetFreeVolumeSpace() const; - - /** - Call the callback functor. - Throw an exception if the callback functor's method \c Callback returns \c - false. \param iCode a code to be passed to the callback functor \param - szTemp a string to be used as a filename (the second argument of - CZipException::Throw) when the exception must be thrown \note Throws - exceptions. \see CZipArchive::SetSpanCallback \see CZipException::Throw -*/ - void CallCallback(int iCode, CZipString szTemp); - - /** - Construct the name of the volume in #tdSpan mode. - \param bLast - must be \c true if constructing the last volume name (an extension "zip" - is given) \param lpszZipName the name of the archive \return the new - volume name -*/ - CZipString GetTdVolumeName(bool bLast, LPCTSTR lpszZipName = NULL) const; - - /** - Change the disk in #tdSpan mode - */ - CZipString ChangeTdRead(); - - /** - Change the disk in #pkzipSpan mode - */ - CZipString ChangePkzipRead(); - - /** - Used only in \ref TDSpan "TD span mode" . The value it holds depends on - the open mode. - - Opened existing disk spanning archive - store the number of the last - disk ( the one with "zip" extension). - - Disk spanning archive in creation - the size of the volume. - - \see CZipArchive::Open - \see CZipArchive::GetSpanMode - - */ - int m_iTdSpanData; - - /** - The extension of the last volume. - */ - CZipString m_szSpanExtension; - - /** - \return the count bytes left free in the write buffer - */ - DWORD GetFreeInBuffer() const - { - return m_pWriteBuffer.GetSize() - m_uBytesInWriteBuffer; - } - - /** - Number of bytes available in the write buffer. - */ - DWORD m_uBytesInWriteBuffer; - - /** - The value it holds depends on the open mode: - \par - - #tdSpan : the total size of the current volume - - #pkzipSpan: a free space on the current volume -*/ - DWORD m_uCurrentVolSize; - - /** - number of bytes left free in the write buffer - */ - DWORD m_uVolumeFreeInBuffer; - - /** - Write buffer caching data. - */ - CZipAutoBuffer m_pWriteBuffer; - - /** - Used only during disk spanning archive creation. - Tells how many bytes have been written physically to the current volume. - */ - DWORD m_iBytesWritten; - - /** - \c True, if the current archive is a new disk spanning archive. - */ - bool m_bNewSpan; - - /** - The current disk in a disk spanning archive. - Disk no 0 is the first disk. - */ - int m_iCurrentDisk; - - /** - It is set to \e true when an archive is created in memory; \e false - otherwise. - */ - bool m_bInMemory; - - /** - It is set to \e true if OpenMode::zipOpenReadOnly was specified when - opening the archive - */ - bool m_bReadOnly; -}; - -#endif // !defined(AFX_ZIPSTORAGE_H__941824FE_3320_4794_BDE3_BE334ED8984B__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/ZipString.cpp b/src/smpackagee/ZipArchive/ZipString.cpp deleted file mode 100644 index 13ea2e2fe8..0000000000 --- a/src/smpackagee/ZipArchive/ZipString.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipString.cpp $ -// $Archive: /ZipArchive/ZipString.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipString.h" - -ZIPSTRINGCOMPARE -GetCZipStrCompFunc(bool bCaseSensitive, bool bCollate) -{ - if (bCollate) - return bCaseSensitive ? &CZipString::Collate - : &CZipString::CollateNoCase; - else - return bCaseSensitive ? &CZipString::Compare - : &CZipString::CompareNoCase; -} diff --git a/src/smpackagee/ZipArchive/ZipString.h b/src/smpackagee/ZipArchive/ZipString.h deleted file mode 100644 index ea2b7fe729..0000000000 --- a/src/smpackagee/ZipArchive/ZipString.h +++ /dev/null @@ -1,37 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipString.h $ -// $Archive: /ZipArchive/ZipString.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef ZIPSTRING_DOT_H -#define ZIPSTRING_DOT_H -#include "ZipExport.h" -#include "stdafx.h" - -typedef CString CZipString; - -/** - A poiter type to point to CZipString to Collate or CollateNoCase - or Compare or CompareNoCase -*/ -typedef int (CZipString::*ZIPSTRINGCOMPARE)(LPCTSTR) const; - -/** - return a pointer to the function in CZipString structure, - used to compare elements depending on the arguments -*/ -ZIP_API ZIPSTRINGCOMPARE -GetCZipStrCompFunc(bool bCaseSensitive, bool bCollate = true); - -#endif /* ZIPSTRING_DOT_H */ diff --git a/src/smpackagee/ZipArchive/__Windows_MFC.zcfg b/src/smpackagee/ZipArchive/__Windows_MFC.zcfg deleted file mode 100644 index dc711df027..0000000000 --- a/src/smpackagee/ZipArchive/__Windows_MFC.zcfg +++ /dev/null @@ -1 +0,0 @@ -Windows MFC diff --git a/src/smpackagee/ZipArchive/_copy_from_Win-MFC.bat b/src/smpackagee/ZipArchive/_copy_from_Win-MFC.bat deleted file mode 100644 index adac7df4d9..0000000000 --- a/src/smpackagee/ZipArchive/_copy_from_Win-MFC.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -copy Windows\*.* *.* -copy mfc\*.* *.* -del __*.zcfg -echo Windows MFC > __Windows_MFC.zcfg diff --git a/src/smpackagee/ZipArchive/_copy_from_Win-STL.bat b/src/smpackagee/ZipArchive/_copy_from_Win-STL.bat deleted file mode 100644 index 88f426740b..0000000000 --- a/src/smpackagee/ZipArchive/_copy_from_Win-STL.bat +++ /dev/null @@ -1,5 +0,0 @@ -@echo off -copy Windows\*.* *.* -copy stl\*.* *.* -del __*.zcfg -echo Windows STL > __Windows_STL.zcfg diff --git a/src/smpackagee/ZipArchive/_version.txt b/src/smpackagee/ZipArchive/_version.txt deleted file mode 100644 index 3f684d2d90..0000000000 --- a/src/smpackagee/ZipArchive/_version.txt +++ /dev/null @@ -1 +0,0 @@ -2.3.4 diff --git a/src/smpackagee/ZipArchive/borland.zip b/src/smpackagee/ZipArchive/borland.zip deleted file mode 100644 index 98dfe5ded0c5bdfa90dda381b6cd6b8f780cb078..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7568 zcmZ{pWl$a4pS2I}?he7--3jgz+#wvC!$E>ea1HM677_^V?(Ps=gS+d?o%z>$?@Zn4 zuIjF?UC)=*Rco*PTdE3B(AWS-06d_{?tua2>_O`Y005jp001cOZ+lZ)3p4Z2c6Kc0 zj*gX+UGhC*=&&14-R(VMta|xfH6MZ;a=)gADAmdk)Xcb0tTMG^NHey#RQG9!v%Y{h zdyvUEXNnJCrOw%G3LdA{9mx2%?SLfpg3vCNWI|;*M#Sp|bYLOF4Ci7ce^)Ik3)r96 z4qkX-E`~M%PjpY#?l2?YOAiZm3ajS&L*aWpsbTD9=@5KCAI3M<6Im-1{Z|z(cWw(e z(rYHR^9$Jcpz6Gp&-kCV>_~Gy5xJO5@h*!0SkG3?7>dXKkVC!%Ek2_PEi*#LW+HV0 zYND!55}72cZT)V8kaZKA>_ez)l_J zskQ3bVoaq?d-_D>-Qo;dKoZV@NAq0+*u}lAC#$ud z**6eQ6%M)7V~%};r(o8Agr6SxA}E2%7p@OUVE*`c<29Bc#8n|*=W}{-adT7G)O3Ga zk2r;7iV$7UHFY3&2Ol>W14YOTD?^{7@JD8Uc|8;kuR{(~UDS`XmVi}Q4q{Bq z%-8|AX06nYLe?Fs!kTmkl#UqJkIuXgeDDZIcgkB!SPbl$@i;+1$$Q z6bjXF6L4>HA}X6ITXGdX`#3k> z?j>-CQmt}DSvPvE2cJZ2klz8}OeM7Do?-3G+p*VrG5Fe4RzjRJ2JGs%n>xi!M)odK zH~WnI497Rt5Nxv!zwOnlx7F`cns@A~bKc?0{MON_N2!{Yt*JXqe|@!Vx&0!?IkL%{T_*~;CEzd)*a{?eU57z zQgyXZAy|(={@6Y<=Bsj>OQ7ra;~6mG1=;YE%w-v>-OZAJA;Nq$wLtp%4b0msJag%w z`4QF>FFD(W18_P!HCOgMqui2!kjdHab*=&rOT@i?S1~CsZz!7=JV(q~S-o4DPCJhG zoHd+%s7N%Lxoz=;LBsF75|61Z*%lhf=Rj!sNkLTILRBAnUoF1EfPrDlf!mv z#^gpWRXA+OWl|^nNvoRqNO}-9xl|j;zE5?tQbl-y<0;e=i<^>nM9+$taW2R3U`+1KgxEmzJ z#{?w!{PiQZQ3q$U&Lw6lM=7ILsxYm;j!8b-$3dwFCc1BdvwwiLwRMSfn7RGvgjIoz z>0)2c9mEoZSb9EeiD_^+DS;eS zn|(1`Rx+9k?yk7PQQR z9nwK`?#K5rsxyS5p|f%|5x4g0VB*#Z$4;CFoFsdMU!?sfM<;pp&)fqJ*QBBG^fqW@74j? z2w{8uc&L~34N|9YnLw#y#h8@^#F7%}5c-;#dXi#Ih^P2QkC@;e#FjD9Oyb=Mw}11q zIENK){A9zFs~eLFAwQO9+hDbE9Jwm2W@yVwig9#;RxBy)Y}@bS^VN+v$7K(#WRqLg zuH`4u&Nd?Ii9c90rcj;KzdI}K$nSK&9<1VMR{3k&m3D6&_}dAIs_@qx&$?gZIh7?BBbyLVQtqK;8DWjq>1-9%W2SCe(fq@}=#6KCvpHBZ3n7{Mm5 zpRB}hiAfy~cCC0c4`qH|FR=!bUiiT8M`gS^qi=dy}mR!X@y3ly}lK*m7In@BuOGM z$P)*9I5Sp4!z}YhI=ZJ+8G=aup{o}7P*gi&icVRlO)W>6lv=JyE^oH;6sSY3coj{9 zYmx4yQdmu1pN}`*>ZFvRj1`}#Hy&cQ4_RdWNe7FS+(T&|`f>}4Cz3m<|6HirNOywtivUoIkqg#Nl5< z)XbDOp!5fAW9!-_)U`5?3qA9T;Jhk3IvzF@SiD_3`_nU3uqVdFVG;Q=70dx`nXD*S z>V38F>#ba$m_eS`ci8mM>HOQ-RBEl!dviW zvq@1K5+z}Qnh%|O&^&G&W(<3ohBzC-NuwfSB4(_(rn3?`xQLsa;M->D$X5WSo~^9B z7=$Jn4SjvMCJ|FpA-#^GZGt>BwyG0YD>rqXCJ~-4w;V+xZ_6x0ha-QZyq-QdGSc2@ zC`{0IPPIV+f~I!9G0`8n;`c8YOl>`=_)WfVo}XhSCG61T!yA`#9%nToDoMOvm}a`X z?>jz4^@fp)*~n0~_-;6ec@pJ&Vq;Z69NhE4%AfFA@frw!gVRK#9Gu-Qtu*xfCS3r7 zPTY^N$aAJQP*Y1FNzI}2jhE&IVrt^C9$dmDzV@v*jKc9S1-WHY!mIYe8op+|_i%xD zxmAVN<4_=jvS&qQCNojP=BCQzX zrsPPMN&=hb?>$m(f%BO6Kg3J4=$7n}-UbO(-7a;1kENj7fGhHv8B;WRxwg-nf{MF&d|13{NTyIk2*KZQsOate~L!=D0(tKihpJ zF?b|F&a($bt^(RQz8@zGjco7E@UXnNNTN?XqhGT$2PU@pMpI8$lngEXC$)F%64-PW zYy&sXe?^vZoD1F02gQVrI4my<;U;DE{6?*Wy$e2y0*SvyK=OuVv$iM(Tv*2hkM!pZ zU1-E`?@yeSLZUd<7a?vJIal==5jv}SkS0)}ZI$LW$S@vWg)Vobaq7=H5&a3=?9>ae zZSZlyyAp8Txe_*(<}GnVVd46P%D1cPy#Gmyl4` z=*kFYr%LW~^Zoua7GC!m(JnrAkT&ivVugGp4UrIp7|3+QJ&4cfq0;3xZC&HIVB6Y- z!=Ql@@~cFu1>=lf+O2B8zgp#UjuZaAA%ndrvUN#6zp*^7jRD!G8PS8yz)zT`m*jQ> zM;#tuJP-7YTI?#acx=8RbV;H%g>1}t>zhz{c)<`FJI7?(Zh@$_Kk659MKLl94{!zSVzl-@jOXl6f+h0}Dwg7zS0TBh5mlg{sDxv=zqYyu z*%PMA`#6$*4`drOz9D2&0q?^-HoB(_9IXO1swhmh#m6_vx$)k1vkQPj8ZjEOp|@Yww|WSvtf8atClo&qble7%yz!Mo(X zVQau-gA4b`MWt1VO6$lq=tuz1_yNkX&aCpvqDgG3gI{`I_L-l2BUQ*`Q~(_fveZx= zG)B4_dSB32ItBRv_%XULGj)SZCt)P?AH;p`yr>7&3%nSvJg;b|bJ7L`)fi<=ikvSlSfYa4*?tPUH)66CZBU1QyJW#ny145L%(;x}E-w5uYVrvM zTIOb|)PL%;xnwAd=66cjJum~^T&P4>!NFcGsy%etrGXwBLLYuKkeu&&U=vabBYNtS z@TXkF2wnJ9Bd>c_eEBha**=L$;#N0o$!3SB!!RXqq>%dqhDnjtxAH9t8U?>A27l}+ zeAPK~#zb z)u)KnWV#{X%LshgBN-%A&igmgNhrpto}BA*g4YW?KE>v1HaOAQ#^U5dw1qdGeLsSq zMo(~mCp!C7bLJLS(cUsd005E#0D$|;5zRpkKo+ZLJ$;SkK}=ue@=LPED*YB72uNiK zS$O?{#en+_Bn#)EJt=B^O8rO{BWrB7I?-2`yM2y$i<%#Z$)4>82g}zkF;@W&!aNzJGHp&f34>fa_aoWzx$RQ!2WtIK`Z=6R5Lm5Xc&Mru19jkgEiwaD zn>isII`eZ2dyiH#7C=TF%fW9vzSiA8g`XA@uOpA3>m56vrwCA3M?tb(+Pvt5!8E^w zgyFPIAzR|ARQnC#gQ~g$s2tyvp>w;xJwc-)M)#0wD`3<_l|gjM1rXT&8dw>W{z1Dj zm1H$`igx8`XK>w4)`_AArcLIXi#R5+m~_XW$wtwLQ>yVWN|klo6)&e?_}Kh8GZqkQ z6KI@GEye0s^l-Q|Yiw%*lMkGPKQ<#ab_pZG_J&Y<^g{U|Hj7;D8j*r>Sj+HOdx)J5 zzvQ}fzY|7m{9!?{z>&FeMjyqB$&3OCyJNodN9EwlnrvRcaue@AH>4snz;A^kF)h=3CO zi)haWbl*M~hYvQVP4nM=SvTyYVkJ_xHCa^=!OK%dEEZlfyp!+Ert9>!KNr?sdIR#GmLR8&*g3A-jy zNY#PFB`Y(o2A0ujsK;z7Iqi0))2CRETv@$5Hg;3>n&etrC!zOkL|Tnw!0I6K%SN&j z15L5R)2_9Q=glAsUe@r9l^CRJk`+`&!xGgT+HXR%fikptO@c{-1m8waPfX5Bmbe98 zB5EnWTaEV&7JMixQ0Uw8N{*Du;VvQ^aH~#6-a|)7lN2|gy?L-&0ih+;Ol49ddI$HE zpbdmt3?U<{Q7JQG1j{;d|Foox9{ESVi zS?S4~a4-Z8%9td^hpGXs5WH}8s(V)R*QwHPZc4&L<3-w+P7r;xHQblst?C(Y*6z18 zOOUy_l$yJ`JGrRhZG8@Ks7)YvNWkqFaN&el_v{?JUhT{hZBY<9e-KKh2%{y?>!b=lz(NE>S%hEnOt^$kY4Cgy~1?K;?~*+cxN3*3}uo=2rm0U&7mwOZB@1 z3~k&YQNVViFCPlJ`pV?E=IaoT>MmwdKkx#c6=*8wJ3zK5PJ2)#b+L4W%uKKBO&IQC z2NxiR(?(H}Zg$;Bxb9DmE|z#>D!+BF5|TOQ&}1{M{924^Dwp%Dt@EIJ)DwCtB)dR@C1%h8(qm7Z&T)#gXF@Jjka;VY)O=7A)jyNh^fE3vM097pC||=0Pb|68kDp}gld3iAy*gYj6PucK3^CJ^+yx!F>c>L zbEDr6ljqD{w3fY9&DW*+468)ihAF~#xzDAT+<>Xi#a%!v5yz-DlOaQu7?GF}wzhdx zYez0n?oZ+ZDm_pgAz~(_J^)l{V)~+}(5Na%z^*E|;CHDh6@YMP0tPHm2a>>cD7f~B z35L3=cb6{*c3^&|S6BXwx}&f(W;~o^bbtesvLwi#jVx~|FasO7w}+_Ohja*k^F?8s zf-xHQ#Fs4T@YVrNFVo~gS{YYHx}%fXCkPVk$e z{BB(<{+zB}^}8_Mi<9(8JZNBJy18Plum zfJ^39=1sf}5XiRubYtZWrD;0c<934Vm{QH!4aQ<+>%-D@Mp8kIBiLO+Y>aJpXBb80 zE~1V}QTQ!7UR5mo?Cw68moUNHWR`)jfX%6d$!!#&+jA>K?RX_MVxOUDJ072J?Vha3 zMvsp)b|hK3*slBoQ8Fgg^=ZN0puVBY=Pf;SSYO)swI3g?Y!F*b6_kPU;BfS5VWHT; zMo?o_0fCYhr%YpDtBpG6%wH``|+-=fhL-e?`e8clROq(m&a zS_Vl`FNfaZdo6EyK9?xty z_jF2GbE!jwz5|V(jNlM3ma*cN)c|VZ-_oP(eN7pk&(WcGv=1D?5S1rhd}?k4aq14k zF|XrYu8)=yt2F9_yj=#%q~R2(EJWuY%fPo=2r)}1CMDvllacq7L9_#BWd;Rof_@UH zxF$H}mCDJuMMSM?;>DC46k3(jLs=p2HCwMYbZ3j5(}w9O?hVO4SI2v z>Sv-EHU?euyo?HL?DA>k1r`sNY%j%vloX_&?znNBdErYHQAtkgs);KUs|CHFGxem}-g>h1S7m^$4-BY&MkTOcSLOCM&v*I;E$5JY;=^?+sqN#e)Tr1$ z+DX2geepUF*mi)-CKB4f{6becli=~SP(6KD+~k2T$bLGLDsN;V;rg&{Z~mA?l)h@a zYOg&w`0ZDoVPvY8pkV>;$`YbYQRzG|6=N|-9BSU=+IZ#mi)YX88~F|<`cJE#eIQWK zQZwlbpJeV(jy~HXng((|RTF`Oay61y7=rtn9|jP1OHDkqf5gP*5a-eCnL{8yrv}@* zHTnVBD?h-^vNnk~5XS*&xZ2FDIvn)Y`2 zBe7`>6QWphxtE3{8@in!2Xxf|xy-l{e5$zF!piAZs-d+XnbKrAE>Y#A1y(-C+ATcx zgFG*O6IE4!fW!v;-^Jj2q -Q: I experience linking problems. What to do? - - - -Q: When do I need to purchase the commercial license? - - - - -Q: When I open a multi-disk archive (Pkzip mode) and the last disk is not in - the drive, I receive the %CZipException::cdirNotFound exception. How to detect - whether the last disk is in the drive? - - - -Q: Of what size should be a single volume in a multi-disk archive created in -the TD span mode ? - - - - -Q: How can I detect the disk spanning mode of an archive? - - - -Q: How to integrate the library with the sample application? - - - -Q: Why the library doesn't want to extract archives (mostly old)? - - - -Q: In %CZipArchive::AddNewFile and %CZipArchive::ExtractFile I want to use partial -path for the filename inside the archive. - - - -Q: I want to create an archive that will be readable under Unix/Linux. - - - -Q: How can I use UNC path with %CZipArchive::ExtractFile function ? - - - -Q: How to create a zip archive in memory and then write it to disk or -read the archive from the disk and extract from memory ? - - - -Q: How can I extract or delete files that matches a specified wildcard pattern ? - - -
-***************************************************************************** -\anchor q1 - -Q: I experience linking problems. What to do? - - -A: -\par If you get mostly LNK2005 : - If you changed the project configuration (e.g. from Release to Unicode Release), rebuild the projects. - If you are still getting link errors, make sure that the library and your program are both using single-threaded or both - multithreaded (or multithreaded DLL) run-time library. The option Project->Settings-> c/c++ ->Code Generation->Use run-time library - should be set to the same value in the ZipArchive library and the program - project options. Make sure that you link appropriate configurations (Release against Release, Debug against Debug...) - and that you're using MFC library in the same way (shared, static or not using) in those configurations. -\par If you get LNK1104 (e.g. cannot open file "mfc42u.lib") - You're trying to compile the Unicode version but you haven't installed the necessary libraries. -When installing Visual C++ Professional for example, you need to check the boxes "Static Libraries for Unicode" and -"Shared Libraries for Unicode". They are in "VC++ MFC and Template libraries\\MS Foundation Class Libraries". -You don't need to reinstall the Visual Studio to add them. - - - - -\anchor q13 - -Q: When do I need to purchase the commercial license? - - -A: The ZipArchive library is distributed under GNU GPL which implies that it can only be used -with software that is licensed under conditions compliant with the GPL. It means that -you need to provide a customer with the source code of your software that uses the library. -The commercial license removes this obligation. You can find out more at \ref s1. - -\anchor q2 - -Q: When I open a multi-disk archive (Pkzip mode) and the last disk is not in - the drive, I receive the CZipException::cdirNotFound exception. How to detect - whether the last disk is in the drive? - - -A: The last disk can not be detected before opening an archive. The only way to -prevent the program from failing when an incorrect disk is inserted is to -catch the CZipException::cdirNotFound exception while opening the archive and keep prompting the user to insert the last disk into the drive. Please see the sample application on how -it can be done in details. - -\anchor q3 - -Q: Of what size should be a single volume in a multi-disk archive created in -the TD span mode ? - - -A: The size of the volume may be from 1 byte to the maximum integer value, and the bigger - the - faster is creation and extraction (no file changes meantime), but the size - of the whole archive is the same. The optimal solution is to set it to about - the size of the diskette (a little less to be comfortable when there are bad sectors found on the disk) to allow the future conversion to PKZIP span mode. - -\anchor q5 - -Q: How can I detect the disk spanning mode of an archive? - - -A: You need to open the archive and the call CZipArchive::GetSpanMode. When opening the archive in tdSpan mode on a removable device, you should set \e iVolumeSize to a non-zero value while opening the archive (with CZipArchive::Open). There is no universal way to distinguish a PKSpan archive from a TDSpan archive on a removable device, because they have identical internal structure. - - -\anchor q7 - -Q: How to integrate the library with the sample application? - - -A:The usual way is to put ZipArchive library at the same directory level what your -project is, and then use one of the \ref sectVisual "integration methods". -Make a directory structure like this:
-\htmlonly ----
-    |-ZipArc           // the application project
-    |-ZipArchive   // the ZipArchive library
-\endhtmlonly - -You can now follow the integration method 1 or 2 (the easier one). - -\anchor q8 - -Q: Why the library doesn't want to extract archives (mostly old)? - - -A: The common reason is that the data is compressed using \e imploded method (usually with old archivers). -The only methods supported by the zlib library are \e deflation which is the most commonly used by archivers and \e storing which is in fact not a compression method. You can use a compiled ZipArc application to find out what method the file was compressed with (View->File Info) - - -\anchor q9 - -Q: In CZipArchive::AddNewFile and CZipArchive::ExtractFile I want to use partial -path for the filename inside the archive. For example:
-When I compress some directory, like this: - c:\\program files\\example (full directory path: c:\\program files\\example\\text\\txt) - it comes with the whole path. I would like that the zip only get the EXAMPLE\\text\\txt path. -
- -A: You can set \e bFullPath argument to \c false in these functions and set -the beginning part of the path that you commonly want to eliminate with -CZipArchive::SetRootPath function. In the example above you'd set it to -c:\\program files\\ (the path separator at the end is added automatically). - -\anchor q10 - -Q: I want to create an archive that will be readable under Unix/Linux. - - -A: Inside the archive there is an information stored about the system it was -created under. It helps converting the file attributes that are stored inside -the archive to file attributes that are used on the system on which the file is extracted. -Some Unix archivers cannot convert Windows attributes to Unix, so that it is needed -to create the archive with the Unix attributes already (and the internal info about the -system set to a Unix value). To achieve that, simply call CZipArchive::SetSystemCompatibility -with the argument set to ZipCompatibility::zcUnix after creating the archive. - -\anchor q11 - -Q: How can I use UNC path with CZipArchive::ExtractFile function ? - - -\verbatim -A: You need to replace \\\\ at the beginning of the UNC path with \\\\?\UNC\ . -\endverbatim - -\anchor q12 - -Q: How to create a zip archive in memory and then write it to a disk or -read the archive from the disk and extract from memory ? - - -A: See \ref sectMemory - -\anchor q14 - -Q: How can I extract or delete files that matches a specified wildcard pattern ? - - -A: You need to build a CZipWordArray with CZipArchive::FindMatches and then: -- to delete: use the array as an argument to CZipArchive::DeleteFiles -- to extract: the array stores the indexes of the files to extract; you need to -enumerate the array and pass the indexes one-by-one to CZipArchive::ExtractFile function - -*/ diff --git a/src/smpackagee/ZipArchive/gpl.txt b/src/smpackagee/ZipArchive/gpl.txt deleted file mode 100644 index 832de66790..0000000000 --- a/src/smpackagee/ZipArchive/gpl.txt +++ /dev/null @@ -1,285 +0,0 @@ -/** \page pageGPL GNU GENERAL PUBLIC LICENSE - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - -*/ \ No newline at end of file diff --git a/src/smpackagee/ZipArchive/mfc/ZipBaseException.h b/src/smpackagee/ZipArchive/mfc/ZipBaseException.h deleted file mode 100644 index 3119f0c9d3..0000000000 --- a/src/smpackagee/ZipArchive/mfc/ZipBaseException.h +++ /dev/null @@ -1,22 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipBaseException.h $ -// $Archive: /ZipArchive/ZipBaseException.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef __ZIPBASEEXCEPTION_H__ -#define __ZIPBASEEXCEPTION_H__ - -typedef CException CZipBaseException; - -#endif //__ZIPBASEEXCEPTION_H__4 diff --git a/src/smpackagee/ZipArchive/mfc/ZipCollections.h b/src/smpackagee/ZipArchive/mfc/ZipCollections.h deleted file mode 100644 index ab38909768..0000000000 --- a/src/smpackagee/ZipArchive/mfc/ZipCollections.h +++ /dev/null @@ -1,82 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipCollections.h $ -// $Archive: /ZipArchive/ZipCollections.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef ZIPCOLLECTIONS_DOT_H -#define ZIPCOLLECTIONS_DOT_H - -#if _MSC_VER > 1000 -#pragma once -#pragma warning(push) -#pragma warning( \ - disable : 4786) // 'identifier' : identifier was truncated to 'number' - // characters in the debug information -#endif // _MSC_VER > 1000 - -#include -typedef CStringArray CZipStringArray; - -template -class CZipArray : public CArray -{ - - static int CompareAsc(const void* pArg1, const void* pArg2) - { - TYPE w1 = *(TYPE*)pArg1; - TYPE w2 = *(TYPE*)pArg2; - return w1 == w2 ? 0 : (w2 > w1 ? -1 : 1); - } - static int CompareDesc(const void* pArg1, const void* pArg2) - { - TYPE w1 = *(TYPE*)pArg1; - TYPE w2 = *(TYPE*)pArg2; - return w1 == w2 ? 0 : (w1 > w2 ? -1 : 1); - } - - public: - void Sort(bool bAscending) - { - int iSize = GetSize(); - if (!iSize) // if ommitted operator [] will fail if empty - return; - qsort((void*)&((*this)[0]), - iSize, - sizeof(TYPE), - bAscending ? CompareAsc : CompareDesc); - } -}; - -typedef CZipArray CZipWordArray; - -template -class CZipPtrList : public CTypedPtrList -{ - public: - typedef POSITION iterator; - typedef POSITION const_iterator; - - bool IteratorValid(const iterator& iter) const { return iter != NULL; } -}; - -template -class CZipMap : public CMap -{ -}; - -#ifdef _MFC_VER -#pragma warning(pop) -#endif - -#endif /* ZIPCOLLECTIONS_DOT_H */ diff --git a/src/smpackagee/ZipArchive/mfc/ZipFile.cpp b/src/smpackagee/ZipArchive/mfc/ZipFile.cpp deleted file mode 100644 index f50e84004f..0000000000 --- a/src/smpackagee/ZipArchive/mfc/ZipFile.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFile.cpp $ -// $Archive: /ZipArchive/ZipFile.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipFile.h" -#include "stdafx.h" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -// IMPLEMENT_DYNAMIC(CZipAbstractFile, CFile) -IMPLEMENT_DYNAMIC(CZipFile, CFile) - -CZipFile::CZipFile() {} - -CZipFile::~CZipFile() {} - -CZipFile::operator HANDLE() -{ - return (HANDLE)m_hFile; -} - -// __int64 CZipFile::Seek(__int64 dOff, UINT nFrom) -// { -// ASSERT_VALID(this); -// ASSERT(m_hFile != (UINT)hFileNull); -// ASSERT(nFrom == begin || nFrom == end || nFrom == current); -// ASSERT(begin == FILE_BEGIN && end == FILE_END && current == FILE_CURRENT); -// LARGE_INTEGER li; -// li.QuadPart = dOff; -// -// li.LowPart = ::SetFilePointer((HANDLE)m_hFile, li.LowPart, &li.HighPart, -// (DWORD)nFrom); DWORD dw = GetLastError(); if ((li.LowPart == (DWORD)-1) && -// (dw != NO_ERROR)) -// { -// CFileException::ThrowOsError((LONG)dw); -// } -// -// return li.QuadPart; -// } diff --git a/src/smpackagee/ZipArchive/mfc/ZipFile.h b/src/smpackagee/ZipArchive/mfc/ZipFile.h deleted file mode 100644 index 04a99d6126..0000000000 --- a/src/smpackagee/ZipArchive/mfc/ZipFile.h +++ /dev/null @@ -1,68 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFile.h $ -// $Archive: /ZipArchive/ZipFile.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_) -#define AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#include "ZipAbstractFile.h" -#include "ZipExport.h" - -class ZIP_API CZipFile - : public CZipAbstractFile - , public CFile -{ - public: - DECLARE_DYNAMIC(CZipFile) - void Flush() { CFile::Flush(); } - ZIP_ULONGLONG GetPosition() const { return CFile::GetPosition(); } - CZipString GetFilePath() const { return CFile::GetFilePath(); } - void SetLength(ZIP_ULONGLONG nNewLen) { CFile::SetLength(nNewLen); } - UINT Read(void* lpBuf, UINT nCount) { return CFile::Read(lpBuf, nCount); } - void Write(const void* lpBuf, UINT nCount) { CFile::Write(lpBuf, nCount); } - ZIP_ULONGLONG Seek(ZIP_LONGLONG lOff, int nFrom) - { - return CFile::Seek(lOff, nFrom); - } - ZIP_ULONGLONG GetLength() const { return CFile::GetLength(); } - bool Open(LPCTSTR lpszFileName, UINT nOpenFlags, bool bThrowExc) - { - CFileException* e = new CFileException; - bool bRet = CFile::Open(lpszFileName, nOpenFlags, e) != 0; - if (!bRet && bThrowExc) - throw e; - e->Delete(); - return bRet; - } - CZipFile(); - bool IsClosed() const { return m_hFile == CFile::hFileNull; } - - CZipFile(LPCTSTR lpszFileName, UINT nOpenFlags) - : CFile(lpszFileName, nOpenFlags) - { - } - void Close() - { - if (!IsClosed()) - CFile::Close(); - } - operator HANDLE(); - virtual ~CZipFile(); -}; - -#endif // !defined(AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/mfc/ZipString.h b/src/smpackagee/ZipArchive/mfc/ZipString.h deleted file mode 100644 index ea2b7fe729..0000000000 --- a/src/smpackagee/ZipArchive/mfc/ZipString.h +++ /dev/null @@ -1,37 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipString.h $ -// $Archive: /ZipArchive/ZipString.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef ZIPSTRING_DOT_H -#define ZIPSTRING_DOT_H -#include "ZipExport.h" -#include "stdafx.h" - -typedef CString CZipString; - -/** - A poiter type to point to CZipString to Collate or CollateNoCase - or Compare or CompareNoCase -*/ -typedef int (CZipString::*ZIPSTRINGCOMPARE)(LPCTSTR) const; - -/** - return a pointer to the function in CZipString structure, - used to compare elements depending on the arguments -*/ -ZIP_API ZIPSTRINGCOMPARE -GetCZipStrCompFunc(bool bCaseSensitive, bool bCollate = true); - -#endif /* ZIPSTRING_DOT_H */ diff --git a/src/smpackagee/ZipArchive/mfc/stdafx.h b/src/smpackagee/ZipArchive/mfc/stdafx.h deleted file mode 100644 index 3048192819..0000000000 --- a/src/smpackagee/ZipArchive/mfc/stdafx.h +++ /dev/null @@ -1,48 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// $Workfile: stdafx.h $ -// $Archive: /ZipArchive/stdafx.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_) -#define AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#if _MSC_VER < 1300 && !defined __BORLANDC__ -#define ZIPINLINE inline -#else -#define ZIPINLINE -#endif - -#if _MSC_VER >= 1300 -#define ZIP_ULONGLONG ULONGLONG -#define ZIP_LONGLONG LONGLONG -#else -#define ZIP_ULONGLONG DWORD -#define ZIP_LONGLONG LONG -#endif - -#define ZIP_ARCHIVE_MFC - -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers -#include -#include - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/resource.h b/src/smpackagee/ZipArchive/resource.h deleted file mode 100644 index c7ea44ab06..0000000000 --- a/src/smpackagee/ZipArchive/resource.h +++ /dev/null @@ -1,15 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by version.rc -// - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/src/smpackagee/ZipArchive/stl/ZipBaseException.h b/src/smpackagee/ZipArchive/stl/ZipBaseException.h deleted file mode 100644 index 13df362e62..0000000000 --- a/src/smpackagee/ZipArchive/stl/ZipBaseException.h +++ /dev/null @@ -1,22 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipBaseException.h $ -// $Archive: /ZipArchive_STL/ZipBaseException.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef __ZIPBASEEXCEPTION_H__ -#define __ZIPBASEEXCEPTION_H__ - -typedef std::exception CZipBaseException; - -#endif //__ZIPBASEEXCEPTION_H__ diff --git a/src/smpackagee/ZipArchive/stl/ZipCollections.h b/src/smpackagee/ZipArchive/stl/ZipCollections.h deleted file mode 100644 index 8992421fa4..0000000000 --- a/src/smpackagee/ZipArchive/stl/ZipCollections.h +++ /dev/null @@ -1,163 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipCollections.h $ -// $Archive: /ZipArchive_STL/ZipCollections.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef ZIPCOLLECTIONS_DOT_H -#define ZIPCOLLECTIONS_DOT_H - -#if _MSC_VER > 1000 -#pragma warning(push, 3) // STL "requirements" -#pragma warning(disable : 4284) // return type for 'identifier::operator >' is - // not a UDT or reference to a UDT. Will produce - // errors if applied using infix notation -#pragma warning(disable : 4018) //'expression' : signed/unsigned mismatch -#endif - -#include -#include -#include -#include -#include - -#include "ZipExport.h" -#include "ZipString.h" - -template -class CZipArray : private std::vector -{ - public: - typedef std::vector::iterator iterator; - typedef std::vector inherited; - - protected: - iterator GetIterFromIndex(int uIndex) - { - iterator iter = begin(); - iter += uIndex; - // int t = 0; while (t != uIndex) {iter++;t++;} - return iter; - } - - public: - void Sort(bool bAscending) - { - if (bAscending) - std::sort(begin(), end(), std::less()); - else - std::sort(begin(), end(), std::greater()); - } - int GetSize() const { return (int)size(); } - int GetUpperBound() const { return size() - 1; } - int Add(const TYPE& x) - { - push_back(x); - return GetUpperBound(); - } - void RemoveAll() { clear(); } - void RemoveAt(int uIndex) { erase(GetIterFromIndex(uIndex)); } - void InsertAt(int uIndex, const TYPE& x) - { - insert(GetIterFromIndex(uIndex), x); - } -#ifndef _MSC_VER - TYPE& operator[](int iIndex) { return inherited::operator[](iIndex); } - TYPE operator[](int iIndex) const { return inherited::operator[](iIndex); } -#else - using inherited::operator[]; -#endif -}; - -typedef CZipArray CZipStringArray; -typedef CZipArray CZipWordArray; - -template -class ZIP_API CZipPtrList : private std::list -{ - - public: - typedef std::list::iterator iterator; - typedef std::list::const_iterator const_iterator; - int GetCount() const { return size(); } - void AddTail(const TYPE& x) { push_back(x); } - void AddHead(const TYPE& x) { push_front(x); } - void RemoveHead() { pop_front(); } - void RemoveTail() { pop_back(); } - void RemoveAll() { clear(); } - TYPE& GetHead() { return front(); } - TYPE GetHead() const { return front(); } - TYPE& GetTail() { return back(); } - TYPE GetTail() const { return back(); } - iterator GetHeadPosition() { return begin(); } - const_iterator GetHeadPosition() const { return begin(); } - iterator GetTailPosition() { return back(); } - TYPE& GetNext(iterator& pos) { return *pos++; } - const TYPE GetNext(const_iterator& pos) const { return *pos++; } - TYPE& GetPrev(iterator& pos) { return *pos--; } - TYPE GetPrev(iterator& pos) const { return *pos--; } - iterator Find(TYPE& x) { return std::find(begin(), end(), x); } - void RemoveAt(iterator& pos) { erase(pos); } - bool IteratorValid(const_iterator& iter) const { return iter != end(); } - bool IteratorValid(iterator& iter) { return iter != end(); } - iterator FindIndex(int iIndex) - { - iterator iter = begin(); - int t = 0; - while (t != iIndex) { - iter++; - t++; - } - return iter; - } - const_iterator FindIndex(int iIndex) const - { - const_iterator iter = begin(); - int t = 0; - while (t != iIndex) { - iter++; - t++; - } - return iter; - } - TYPE& GetAt(const iterator& pos) { return *pos; } - TYPE GetAt(const_iterator& pos) const { return *pos; } -}; - -// simplified and partial only -template -class ZIP_API CZipMap : private std::map -{ - public: - void SetAt(KEY key, VALUE newValue) - { - insert(std::map::value_type(key, newValue)); - } - BOOL RemoveKey(KEY key) { return erase(key) != 0; } - BOOL Lookup(KEY key, VALUE& rValue) const - { - const_iterator iter = find(key); - if (iter == end()) - return FALSE; - else { - rValue = iter->second; - return TRUE; - } - } -}; - -#if defined(_MSC_VER) && (_MSC_VER > 1100) -#pragma warning(pop) -#endif - -#endif /* ZIPCOLLECTIONS_DOT_H */ diff --git a/src/smpackagee/ZipArchive/stl/ZipFile.cpp b/src/smpackagee/ZipArchive/stl/ZipFile.cpp deleted file mode 100644 index 9b4c8dc0de..0000000000 --- a/src/smpackagee/ZipArchive/stl/ZipFile.cpp +++ /dev/null @@ -1,109 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFile.cpp $ -// $Archive: /ZipArchive_STL/ZipFile.cpp $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#include "ZipFile.h" -#include "ZipException.h" -#include "ZipPlatform.h" -#include "stdafx.h" - -#include - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CZipFile::CZipFile() -{ - m_hFile = -1; -} - -void -CZipFile::ThrowError() const -{ - CZipException::Throw(errno, m_szFileName); -} - -ZIP_ULONGLONG -CZipFile::GetLength() const -{ - // cannot use Seek here, Seek is not const - long lLen, lCur; - lCur = lseek(m_hFile, 0, current); - if (lCur == -1) - ThrowError(); - lLen = lseek(m_hFile, 0, end); - // first get back - lseek(m_hFile, lCur, begin); - if (lLen == -1) - ThrowError(); - return lLen; -} - -bool -CZipFile::Open(LPCTSTR lpszFileName, UINT openFlags, bool bThrow) -{ - if (!IsClosed()) - Close(); -#ifndef __GNUC__ - UINT iNewFlags = O_BINARY; -#else - UINT iNewFlags = 0; -#endif - bool bReadOnly = false; - if (openFlags & CZipFile::modeCreate) - iNewFlags |= O_CREAT; - if ((openFlags & CZipFile::modeReadWrite) == CZipFile::modeReadWrite) - iNewFlags |= O_RDWR; - else if (openFlags & CZipFile::modeRead) { - // O_RDONLY is defined as 0 - bReadOnly = true; - iNewFlags |= O_RDONLY; - } else if (openFlags & CZipFile::modeWrite) - iNewFlags |= O_WRONLY; - - if (!(openFlags & CZipFile::modeNoTruncate) && !bReadOnly) - iNewFlags |= O_TRUNC; - - m_hFile = ZipPlatform::OpenFile(lpszFileName, iNewFlags, openFlags & 0x1C); - if (m_hFile == -1) - if (bThrow) - ThrowError(); - else - return false; - m_szFileName = lpszFileName; - return true; -} - -void -CZipFile::SetLength(ZIP_ULONGLONG nNewLen) -{ - ZipPlatform::TruncateFile(m_hFile, (DWORD)nNewLen); -} - -void -CZipFile::Flush() -{ - if (!ZipPlatform::FlushFile(m_hFile)) - ThrowError(); -} - -CZipFile::operator HANDLE() -{ - int fh = ZipPlatform::GetFileSystemHandle(m_hFile); - if (fh == -1) - ThrowError(); - return (HANDLE)fh; -} diff --git a/src/smpackagee/ZipArchive/stl/ZipFile.h b/src/smpackagee/ZipArchive/stl/ZipFile.h deleted file mode 100644 index 2c03923154..0000000000 --- a/src/smpackagee/ZipArchive/stl/ZipFile.h +++ /dev/null @@ -1,115 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipFile.h $ -// $Archive: /ZipArchive_STL/ZipFile.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_) -#define AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "ZipAbstractFile.h" -#include "ZipExport.h" -#include "ZipString.h" - -#ifndef __GNUC__ -#include -#else -#include -#include -#endif - -class ZIP_API CZipFile : public CZipAbstractFile -{ - void ThrowError() const; - - public: - int m_hFile; - operator HANDLE(); - enum OpenModes - { - modeRead = 0x0001, - modeWrite = 0x0002, - modeReadWrite = modeRead | modeWrite, - shareDenyWrite = 0x0004, - shareDenyRead = 0x0008, - shareDenyNone = 0x0010, - modeCreate = 0x0020, - modeNoTruncate = 0x0040, - }; - - CZipFile(LPCTSTR lpszFileName, UINT openFlags) - { - m_hFile = -1; - Open(lpszFileName, openFlags, true); - } - void Flush(); - ZIP_ULONGLONG GetLength() const; - CZipString GetFilePath() const { return m_szFileName; } - bool IsClosed() const { return m_hFile == -1; } - bool Open(LPCTSTR lpszFileName, UINT openFlags, bool bThrow); - void Close() - { - if (IsClosed()) - return; - - if (close(m_hFile) != 0) - ThrowError(); - else { - m_szFileName.empty(); - m_hFile = -1; - } - } - void Write(const void* lpBuf, UINT nCount) - { - if (write(m_hFile, lpBuf, nCount) != (int)nCount) - ThrowError(); - } - ZIP_ULONGLONG GetPosition() const - { -#ifndef __GNUC__ - long ret = tell(m_hFile); -#else - long ret = lseek(m_hFile, 0, SEEK_CUR); -#endif - if (ret == -1L) - ThrowError(); - return ret; - } - void SetLength(ZIP_ULONGLONG nNewLen); - UINT Read(void* lpBuf, UINT nCount) - { - errno = 0; - int ret = read(m_hFile, lpBuf, nCount); - if (ret < (int)nCount && errno != 0) - ThrowError(); - return ret; - } - ZIP_ULONGLONG Seek(ZIP_LONGLONG dOff, int nFrom) - { - long ret = lseek(m_hFile, (long)dOff, nFrom); - if (ret == -1) - ThrowError(); - return ret; - } - CZipFile(); - virtual ~CZipFile() { Close(); }; - - protected: - CZipString m_szFileName; -}; - -#endif // !defined(AFX_ZIPFILE_H__80609DE0_2C6D_4C94_A90C_0BE34A50C769__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/stl/ZipString.h b/src/smpackagee/ZipArchive/stl/ZipString.h deleted file mode 100644 index 02e6a410a2..0000000000 --- a/src/smpackagee/ZipArchive/stl/ZipString.h +++ /dev/null @@ -1,276 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: ZipString.h $ -// $Archive: /ZipArchive_STL/ZipString.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifndef __ZIPSTRING_H__ -#define __ZIPSTRING_H__ -#include "stdafx.h" - -#if defined(_MSC_VER) && (_MSC_VER > 1100) -#pragma warning(push, 3) // STL requrements -#endif - -/** - If you wish the class to respect your locale (if it is different from - English), you need to set it in your program with function - std::locale::global(std::locale("")) (to set it to be the same as your - system locale) or e.g. std::locale::global(std::locale("French")) - ( to set it to a specified value); setlocale() function is not sufficient - here. -*/ - -#include "ZipExport.h" -#include -#include -#include -#include - -#ifndef __GNUC__ -#ifndef _vsntprintf -#ifdef _UNICODE -#define _vsntprintf _vsnwprintf -#else -#define _vsntprintf _vsnprintf -#endif -#endif -#include -#else -#define _vsntprintf vsnprintf -#endif - -typedef std::basic_string stdbs; -/** - This is not a full MFC - CString replacement. - For now it contains mostly the methods required by ZipArchive library. -*/ -class ZIP_API CZipString : public stdbs -{ - void TrimInternalL(size_type iPos) - { - if (iPos == npos) - erase(); - if (iPos) - erase(0, iPos); - } - void TrimInternalR(size_type iPos) - { - if (iPos == npos) - erase(); - erase(++iPos); - } -#ifndef __GNUC__ - static int zslen(const TCHAR* lpsz) - { - return lpsz ? (int)std::char_traits::length(lpsz) : 0; - } - static TCHAR tl(TCHAR c) { return std::tolower(c, std::locale()); } - static TCHAR tu(TCHAR c) { return std::toupper(c, std::locale()); } -#else - static int zslen(const TCHAR* lpsz) - { - return lpsz ? std::string_char_traits::length(lpsz) : 0; - } -#endif - - public: - CZipString() {} - explicit CZipString(TCHAR ch, int nRepeat = 1) - : stdbs(nRepeat, ch) - { - } - CZipString(const CZipString& stringSrc) { assign(stringSrc); } - CZipString(const stdbs& stringSrc) { assign(stringSrc); } - CZipString(LPCTSTR lpsz) - { - if (!lpsz) - Empty(); - else - assign(lpsz); - } - operator LPCTSTR() const { return c_str(); } - - int GetLength() const { return (int)size(); } - bool IsEmpty() const { return empty(); } - void Empty() { erase(begin(), end()); } - TCHAR GetAt(int iIndex) const { return at(iIndex); } - TCHAR operator[](int iIndex) const { return at(iIndex); } - void SetAt(int nIndex, TCHAR ch) { at(nIndex) = ch; } - LPTSTR GetBuffer(int nMinBufLength) - { - if ((int)size() < nMinBufLength) - resize(nMinBufLength); - return empty() ? const_cast(data()) : &(at(0)); - } - void ReleaseBuffer(int nNewLength = -1) - { - resize(nNewLength > -1 ? nNewLength : zslen(c_str())); - } - void TrimLeft(TCHAR chTarget) - { - TrimInternalL(find_first_not_of(chTarget)); - } - void TrimLeft(LPCTSTR lpszTargets) - { - TrimInternalL(find_first_not_of(lpszTargets)); - } - void TrimRight(TCHAR chTarget) - { - TrimInternalR(find_last_not_of(chTarget)); - } - void TrimRight(LPCTSTR lpszTargets) - { - TrimInternalR(find_last_not_of(lpszTargets)); - } - void Format(LPCTSTR lpszFormat, ...) - { - va_list arguments; - va_start(arguments, lpszFormat); - TCHAR* pBuf = NULL; - int iCounter = 1, uTotal = 0; - do { - int nLen = sizeof(TCHAR) * iCounter * 1024; - pBuf = (TCHAR*)realloc((void*)pBuf, nLen); - if (!pBuf) - return; - uTotal = _vsntprintf(pBuf, nLen - 1, lpszFormat, arguments); - if (uTotal == -1 || - (uTotal == nLen - 1)) // for some implementations - { - pBuf[nLen - 1] = _T('\0'); - if (iCounter == 7) - break; - } else { - pBuf[uTotal] = _T('\0'); - break; - } - - } while (true); - - va_end(arguments); - *this = pBuf; - free(pBuf); - } - void Insert(int nIndex, LPCTSTR pstr) { insert(nIndex, pstr, zslen(pstr)); } - void Insert(int nIndex, TCHAR ch) { insert(nIndex, 1, ch); } - int Delete(int nIndex, int nCount = 1) - { - int iSize = (int)size(); - int iToDelete = iSize < nIndex + nCount ? iSize - nIndex : nCount; - if (iToDelete > 0) { - erase(nIndex, iToDelete); - iSize -= iToDelete; - } - return iSize; - } - void MakeLower() - { -#ifndef __GNUC__ - // use_facet doesn't work here well (doesn't convert all the local - // characters properly) - std::transform(begin(), end(), begin(), tl); -#else - - std::transform(begin(), end(), begin(), tolower); -#endif - } - void MakeUpper() - { -#ifndef __GNUC__ - // use_facet doesn't work here well (doesn't convert all the local - // characters properly) - std::transform(begin(), end(), begin(), tu); -#else - std::transform(begin(), end(), begin(), toupper); -#endif - } - void MakeReverse() { std::reverse(begin(), end()); } - CZipString Left(int nCount) const { return substr(0, nCount); } - CZipString Right(int nCount) const - { - nCount = (int)size() < nCount ? (int)size() : nCount; - return substr(size() - nCount); - } - CZipString Mid(int nFirst) const { return substr(nFirst); } - CZipString Mid(int nFirst, int nCount) const - { - return substr(nFirst, nCount); - } - int Collate(LPCTSTR lpsz) const - { -#ifndef __GNUC__ -#ifdef _UNICODE - return wcscoll(c_str(), lpsz); -#else - return strcoll(c_str(), lpsz); -#endif -#else - // return compare(lpsz); - return strcoll(c_str(), lpsz); -#endif - } - int CollateNoCase(LPCTSTR lpsz) const - { - CZipString s1(c_str()), s2(lpsz); - s1.MakeLower(); - s2.MakeLower(); - return s1.Collate(s2); - } - int Compare(LPCTSTR lpsz) const { return compare(lpsz); } - int CompareNoCase(LPCTSTR lpsz) const - { - CZipString s1(c_str()), s2(lpsz); - s1.MakeLower(); - s2.MakeLower(); - return s1.Compare(s2); - } - bool operator!=(LPCTSTR lpsz) { return Compare(lpsz) != 0; } - bool operator==(LPCTSTR lpsz) { return Compare(lpsz) == 0; } - int Find(TCHAR ch, int nStart = 0) const { return (int)find(ch, nStart); } - - int Find(LPCTSTR pstr, int nStart = 0) const - { - return (int)find(pstr, nStart); - } - - int Replace(TCHAR chOld, TCHAR chNew) - { - int iCount = 0; - for (iterator it = begin(); it != end(); ++it) - if (*it == chOld) { - *it = chNew; - iCount++; - } - return iCount; - } -}; - -/** - A poiter type to point to CZipString to Collate or CollateNoCase - or Compare or CompareNoCase -*/ -typedef int (CZipString::*ZIPSTRINGCOMPARE)(LPCTSTR) const; - -/** - return a pointer to the function in CZipString structure, - used to compare elements depending on the arguments -*/ -ZIP_API ZIPSTRINGCOMPARE -GetCZipStrCompFunc(bool bCaseSensitive, bool bCollate = true); - -#if defined(_MSC_VER) && (_MSC_VER > 1100) -#pragma warning(pop) -#endif - -#endif //__ZIPSTRING_H__ diff --git a/src/smpackagee/ZipArchive/stl/stdafx.h b/src/smpackagee/ZipArchive/stl/stdafx.h deleted file mode 100644 index cd7eeeff08..0000000000 --- a/src/smpackagee/ZipArchive/stl/stdafx.h +++ /dev/null @@ -1,125 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// $Workfile: stdafx.h $ -// $Archive: /ZipArchive_STL/stdafx.h $ -// $Date: 2003-07-21 21:10:30 -0500 (Mon, 21 Jul 2003) $ $Author: gmaynard $ -//////////////////////////////////////////////////////////////////////////////// -// This source file is part of the ZipArchive library source distribution and -// is Copyright 2000-2003 by Tadeusz Dracz (http://www.artpol-software.com/) -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#if !defined(AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_) -#define AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_ - -#if (_MSC_VER < 1300) && !defined(__BORLANDC__) && !defined(__GNUC__) -#define ZIPINLINE inline -#else -#define ZIPINLINE -#endif - -#define ZIP_ARCHIVE_STL - -#if _MSC_VER > 1000 -#pragma once -// because of STL -#pragma warning(disable : 4710) // 'function' : function not inlined -#pragma warning( \ - disable : 4514) // unreferenced inline/local function has been removed -#pragma warning( \ - disable : 4786) // 'identifier' : identifier was truncated to 'number' - // characters in the debug information -#endif // _MSC_VER > 1000 - -// some Windows typical definitions - -#if defined(_UNICODE) && !defined(UNICODE) -#define UNICODE -#endif -#if defined(UNICODE) && !defined(_UNICODE) -#define _UNICODE -#endif - -#ifndef _WIN32 -#ifndef NULL -#define NULL 0 -#endif - -#include -typedef int HFILE; -typedef void* HANDLE; -typedef unsigned long DWORD; -typedef long LONG; -typedef int BOOL; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef unsigned int UINT; - -#ifndef FALSE -#define FALSE (int)0 -#endif - -#ifndef TRUE -#define TRUE (int)1 -#endif - -typedef unsigned short WCHAR; // wc, 16-bit UNICODE character -typedef const WCHAR* LPCWSTR; -typedef const char* LPCSTR; -typedef WCHAR* LPWSTR; -typedef char* LPSTR; - -#ifdef _UNICODE -typedef wchar_t TCHAR; -typedef LPCWSTR LPCTSTR; -typedef LPWSTR LPTSTR; -#define _T(x) L##x -#else /* _UNICODE */ // r_winnt -typedef char TCHAR; -typedef LPCSTR LPCTSTR; -typedef LPSTR LPTSTR; -#define _T(x) x -#endif /* _UNICODE */ // r_winnt - -#else -#include -#include -#ifndef STRICT -#define STRICT -#endif -#endif // #ifndef _WIN32 - -#ifndef ASSERT -#include -#define ASSERT(f) assert((f)) -#endif -#ifndef VERIFY -#ifdef _DEBUG -#define VERIFY(x) ASSERT((x)) -#else -#define VERIFY(x) x -#endif -#endif - -#ifndef TRACE -#define TRACE -#endif - -#if _MSC_VER >= 1300 -#define ZIP_ULONGLONG ULONGLONG -#define ZIP_LONGLONG LONGLONG -#else -#define ZIP_ULONGLONG DWORD -#define ZIP_LONGLONG LONG -#endif - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_STDAFX_H__926F70F4_1B34_49AA_9532_498E8D2F3495__INCLUDED_) diff --git a/src/smpackagee/ZipArchive/stl/zippie/CmdLine.cpp b/src/smpackagee/ZipArchive/stl/zippie/CmdLine.cpp deleted file mode 100644 index 05c59ca2ce..0000000000 --- a/src/smpackagee/ZipArchive/stl/zippie/CmdLine.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/*------------------------------------------------------ - CCmdLine - - A utility for parsing command lines. - - Copyright (C) 1999 Chris Losinger, Smaller Animals Software. - http://www.smalleranimals.com - - This software is provided 'as-is', without any express - or implied warranty. In no event will the authors be - held liable for any damages arising from the use of this software. - - Permission is granted to anyone to use this software - for any purpose, including commercial applications, and - to alter it and redistribute it freely, subject to the - following restrictions: - - 1. The origin of this software must not be misrepresented; - you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required - 2. Altered source versions must be plainly marked as such, - and must not be misrepresented as being the original software - 3. This notice may not be removed or altered from any source - distribution - See SACmds.h for more info. -------------------------------------------------------*/ - -// if you're using MFC, you'll need to un-comment this line - -#include "CmdLine.h" -//#include "crtdbg.h" - -/*------------------------------------------------------ - int CCmdLine::SplitLine(int argc, char **argv) - - parse the command line into switches and arguments - - returns number of switches found -------------------------------------------------------*/ -int -CCmdLine::SplitLine(int argc, char** argv) -{ - clear(); - - StringType curParam; // current argv[x] - - // skip the exe name (start with i = 1) - for (int i = 1; i < argc; i++) { - // if it's a switch, start a new CCmdLine - if (IsSwitch(argv[i])) { - curParam = argv[i]; - - StringType arg; - - // look at next input string to see if it's a switch or an argument - if (i + 1 < argc) { - if (!IsSwitch(argv[i + 1])) { - // it's an argument, not a switch - arg = argv[i + 1]; - - // skip to next - i++; - } else { - arg = ""; - } - } - - // add it - CCmdParam cmd; - cmd.m_strings.push_back(arg); - - // add the CCmdParam to 'this' - pair res = - insert(CCmdLine::value_type(curParam, cmd)); - } else { - // it's not a new switch, so it must be more stuff for the last - // switch - - // ...let's add it - CCmdLine::iterator theIterator; - - // get an iterator for the current param - theIterator = find(curParam); - if (theIterator != end()) { - (*theIterator).second.m_strings.push_back(argv[i]); - } else { - // ?? - } - } - } - - return size(); -} - -/*------------------------------------------------------ - - protected member function - test a parameter to see if it's a switch : - - switches are of the form : -x - where 'x' is one or more characters. - the first character of a switch must be non-numeric! - -------------------------------------------------------*/ - -bool -CCmdLine::IsSwitch(const char* pParam) -{ - if (pParam == NULL) - return false; - - // switches must non-empty - // must have at least one character after the '-' - int len = strlen(pParam); - if (len <= 1) { - return false; - } - - // switches always start with '-' - if (pParam[0] == '-') { - // allow negative numbers as arguments. - // ie., don't count them as switches - return (!isdigit(pParam[1])); - } else { - return false; - } -} - -/*------------------------------------------------------ - bool CCmdLine::HasSwitch(const char *pSwitch) - - was the switch found on the command line ? - - ex. if the command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.HasSwitch("-a") true - cmdLine.HasSwitch("-z") false -------------------------------------------------------*/ - -bool -CCmdLine::HasSwitch(const char* pSwitch) -{ - CCmdLine::iterator theIterator; - theIterator = find(pSwitch); - return (theIterator != end()); -} - -/* - - StringType CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const -char *pDefault) - - fetch an argument associated with a switch . if the parameter at - index iIdx is not found, this will return the default that you - provide - example: - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - call return - ---- ------ - cmdLine.GetSafeArgument("-a", 0, "zz") p1 - cmdLine.GetSafeArgument("-a", 1, "zz") p2 - cmdLine.GetSafeArgument("-b", 0, "zz") p4 - cmdLine.GetSafeArgument("-b", 1, "zz") zz - -*/ - -StringType -CCmdLine::GetSafeArgument(const char* pSwitch, int iIdx, const char* pDefault) -{ - StringType sRet; - - if (pDefault != NULL) - sRet = pDefault; - - try { - sRet = GetArgument(pSwitch, iIdx); - } catch (...) { - } - - return sRet; -} - -/* - - StringType CCmdLine::GetArgument(const char *pSwitch, int iIdx) - - fetch a argument associated with a switch. throws an exception - of (int)0, if the parameter at index iIdx is not found. - - example: - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetArgument("-a", 0) p1 - cmdLine.GetArgument("-b", 1) throws (int)0, returns an empty string - -*/ - -StringType -CCmdLine::GetArgument(const char* pSwitch, int iIdx) -{ - if (HasSwitch(pSwitch)) { - CCmdLine::iterator theIterator; - - theIterator = find(pSwitch); - if (theIterator != end()) { - if ((*theIterator).second.m_strings.size() > iIdx) { - return (*theIterator).second.m_strings[iIdx]; - } - } - } - - throw(int) 0; - - return ""; -} - -/*------------------------------------------------------ - int CCmdLine::GetArgumentCount(const char *pSwitch) - - returns the number of arguments found for a given switch. - - returns -1 if the switch was not found - -------------------------------------------------------*/ - -int -CCmdLine::GetArgumentCount(const char* pSwitch) -{ - int iArgumentCount = -1; - - if (HasSwitch(pSwitch)) { - CCmdLine::iterator theIterator; - - theIterator = find(pSwitch); - if (theIterator != end()) { - iArgumentCount = (*theIterator).second.m_strings.size(); - } - } - - return iArgumentCount; -} diff --git a/src/smpackagee/ZipArchive/stl/zippie/CmdLine.h b/src/smpackagee/ZipArchive/stl/zippie/CmdLine.h deleted file mode 100644 index b1ad6ec0b0..0000000000 --- a/src/smpackagee/ZipArchive/stl/zippie/CmdLine.h +++ /dev/null @@ -1,234 +0,0 @@ -/*------------------------------------------------------ - CCmdLine - - A utility for parsing command lines. - - Copyright (C) 1999 Chris Losinger, Smaller Animals Software. - http://www.smalleranimals.com - - This software is provided 'as-is', without any express - or implied warranty. In no event will the authors be - held liable for any damages arising from the use of this software. - - Permission is granted to anyone to use this software - for any purpose, including commercial applications, and - to alter it and redistribute it freely, subject to the - following restrictions: - - 1. The origin of this software must not be misrepresented; - you must not claim that you wrote the original software. - If you use this software in a product, an acknowledgment - in the product documentation would be appreciated but is not required - 2. Altered source versions must be plainly marked as such, - and must not be misrepresented as being the original software - 3. This notice may not be removed or altered from any source - distribution - ------------------------- - Example: - Our example application uses a command line that has two - required switches and two optional switches. The app should abort - if the required switches are not present and continue with default - values if the optional switches are not present - Sample command line: - MyApp.exe -p1 text1 text2 -p2 "this is a big argument" -opt1 -55 -opt2 - Switches -p1 and -p2 are required - p1 has two arguments and p2 has one - Switches -opt1 and -opt2 are optional - opt1 requires a numeric argument - opt2 has no arguments - Also, assume that the app displays a 'help' screen if the '-h' switch - is present on the command line - #include "CmdLine.h" - - void main(int argc, char **argv) - { - // our cmd line parser object - CCmdLine cmdLine; - - // parse argc,argv - if (cmdLine.SplitLine(argc, argv) < 1) - { - // no switches were given on the command line, abort - ASSERT(0); - exit(-1); - } - - // test for the 'help' case - if (cmdLine.HasSwitch("-h")) - { - show_help(); - exit(0); - } - - // get the required arguments - StringType p1_1, p1_2, p2_1; - try - { - // if any of these fail, we'll end up in the catch() block - p1_1 = cmdLine.GetArgument("-p1", 0); - p1_2 = cmdLine.GetArgument("-p1", 1); - p2_1 = cmdLine.GetArgument("-p2", 0); - - } - catch (...) - { - // one of the required arguments was missing, abort - ASSERT(0); - exit(-1); - } - - // get the optional parameters - - // convert to an int, default to '100' - int iOpt1Val = atoi(cmdLine.GetSafeArgument("-opt1", 0, 100)); - - // since opt2 has no arguments, just test for the presence of - // the '-opt2' switch - bool bOptVal2 = cmdLine.HasSwitch("-opt2"); - - .... and so on.... - - } - - If this class is used in an MFC application, StringType is CString, else - it uses the STL 'string' type. - - If this is an MFC app, you can use the __argc and __argv macros from - you CYourWinApp::InitInstance() function in place of the standard argc - and argv variables. - -------------------------------------------------------*/ -#ifndef SACMDSH -#define SACMDSH - -#if _MSC_VER > 1000 -#pragma once -#pragma warning(disable : 4786) -#pragma warning(disable : 4018) -#endif // _MSC_VER > 1000 - -// #ifdef __AFX_H__ -// // if we're using MFC, use CStrings -// #define StringType CString -// #else -// // if we're not using MFC, use STL strings -// #define StringType string -// #endif -#ifdef __GNUC__ -#include "ZipString.h" -#else -#include "../../ZipString.h" -#endif - -#define StringType CZipString - -//#include // you may need this -#include -#include -#include -using namespace std; - -// handy little container for our argument vector -struct CCmdParam -{ - vector m_strings; -}; - -// this class is actually a map of strings to vectors -typedef map _CCmdLine; - -// the command line parser class -class CCmdLine : public _CCmdLine -{ - - public: - /*------------------------------------------------------ - int CCmdLine::SplitLine(int argc, char **argv) - - parse the command line into switches and arguments. - - returns number of switches found - ------------------------------------------------------*/ - int SplitLine(int argc, char** argv); - - /*------------------------------------------------------ - bool CCmdLine::HasSwitch(const char *pSwitch) - - was the switch found on the command line ? - - ex. if the command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.HasSwitch("-a") true - cmdLine.HasSwitch("-z") false - ------------------------------------------------------*/ - bool HasSwitch(const char* pSwitch); - - /* - - StringType CCmdLine::GetSafeArgument(const char *pSwitch, int iIdx, const - char *pDefault) - - fetch an argument associated with a switch . if the parameter at - index iIdx is not found, this will return the default that you - provide. - - example: - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - call return - ---- ------ - cmdLine.GetSafeArgument("-a", 0, "zz") p1 - cmdLine.GetSafeArgument("-a", 1, "zz") p2 - cmdLine.GetSafeArgument("-b", 0, "zz") p4 - cmdLine.GetSafeArgument("-b", 1, "zz") zz - - */ - - StringType GetSafeArgument(const char* pSwitch, - int iIdx, - const char* pDefault); - - /*------------------------------------------------------ - - StringType CCmdLine::GetArgument(const char *pSwitch, int iIdx) - - fetch a argument associated with a switch. throws an exception - of (int)0, if the parameter at index iIdx is not found. - - example: - command line is : app.exe -a p1 p2 p3 -b p4 -c -d p5 - - call return - ---- ------ - cmdLine.GetArgument("-a", 0) p1 - cmdLine.GetArgument("-b", 1) throws (int)0, returns an empty string - - ------------------------------------------------------*/ - StringType GetArgument(const char* pSwitch, int iIdx); - - /*------------------------------------------------------ - int CCmdLine::GetArgumentCount(const char *pSwitch) - - returns the number of arguments found for a given switch. - - returns -1 if the switch was not found - - ------------------------------------------------------*/ - int GetArgumentCount(const char* pSwitch); - - protected: - /*------------------------------------------------------ - - protected member function - test a parameter to see if it's a switch : - - switches are of the form : -x - where 'x' is one or more characters. - the first character of a switch must be non-numeric! - - ------------------------------------------------------*/ - bool IsSwitch(const char* pParam); -}; - -#endif diff --git a/src/smpackagee/ZipArchive/stl/zippie/zippie.cpp b/src/smpackagee/ZipArchive/stl/zippie/zippie.cpp deleted file mode 100644 index 8ff858ebf4..0000000000 --- a/src/smpackagee/ZipArchive/stl/zippie/zippie.cpp +++ /dev/null @@ -1,911 +0,0 @@ -/* - * $Archive: /zippie/zippie.cpp $ - * $Author: gmaynard $ - * - * $History: zippie.cpp $ - * - * ***************** Version 4 ***************** - * User: Tadeusz Dracz Date: 02-04-01 Time: 2:05 - * Updated in $/zippie - * - * ***************** Version 3 ***************** - * User: Tadeusz Dracz Date: 02-01-19 Time: 18:01 - * Updated in $/zippie - * - * ***************** Version 2 ***************** - * User: Tadeusz Dracz Date: 01-11-08 Time: 19:54 - * Updated in $/zippie - * added support for wildcards when extracting or deleting - * - */ -///////////////////////////////////////////////////////////////////////////////// -// zippie.cpp : Defines the entry point for the console application. -// An STL program that uses the ZipArchive library -// -// Copyright (C) 2000 - 2003 Tadeusz Dracz. -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// For the licensing details see the file License.txt -//////////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUC__ -#include "ZipArchive.h" -#include "ZipPlatform.h" -#include -#include -#include -#include -#include -#else -#include "../../ZipArchive.h" -#include "../../ZipPlatform.h" -#endif -#include "CmdLine.h" -#include -#include -#include -#include - -ZIPSTRINGCOMPARE pZipComp; - -struct CZipAddFileInfo -{ - CZipAddFileInfo(const CZipString& szFilePath, - const CZipString& szFileNameInZip) - : m_szFilePath(szFilePath) - , m_szFileNameInZip(szFileNameInZip) - { - int is = szFileNameInZip.GetLength(); - m_iSeparators = 0; - for (int i = 0; i < is; i++) - if (CZipPathComponent::IsSeparator(szFileNameInZip[i])) - m_iSeparators++; - } - CZipString m_szFilePath, m_szFileNameInZip; - - bool CheckOrder(const CZipString& sz1, - const CZipString& sz2, - int iSep1, - int iSep2, - bool bCheckTheBeginning = false) const - { - if (iSep1) { - if (iSep2) { - if (iSep1 == iSep2) - return (sz1.*pZipComp)(sz2) < 0; - - if (bCheckTheBeginning) { - - int is = sz1.GetLength() > sz2.GetLength() - ? sz2.GetLength() - : sz1.GetLength(); - int iSeparators = 0; - // find the common path beginning - int iLastSepPos = -1; - for (int i = 0; i < is; i++) { - CZipString sz = sz2.Mid(i, 1); - if ((sz1.Mid(i, 1).*pZipComp)(sz) != - 0) // must be Mid 'cos of case sens. here - break; - else if (CZipPathComponent::IsSeparator(sz[0])) { - iLastSepPos = i; - iSeparators++; - } - } - - // if necessary remove the common path beginning and check - // again - if (iLastSepPos != -1) - return CheckOrder(sz1.Mid(iLastSepPos), - sz2.Mid(iLastSepPos), - iSep1 - iSeparators, - iSep2 - iSeparators); - } - return (sz1.*pZipComp)(sz2) < 0; - } else - return false; - } else if (iSep2) - return true; - else - return (sz1.*pZipComp)(sz2) < 0; - } - bool operator>(const CZipAddFileInfo& wz) const - { - bool b = CheckOrder(m_szFileNameInZip, - wz.m_szFileNameInZip, - m_iSeparators, - wz.m_iSeparators, - true); - return b; - } - - protected: - int m_iSeparators; // for a sorting puroposes -}; - -typedef list FILELIST; -typedef list::iterator FILELISTIT; -typedef list FILELISTADD; -typedef list::iterator FILELISTADDIT; - -struct AddDirectoryInfo -{ - AddDirectoryInfo(FILELIST& l) - : m_l(l) - { - } - FILELIST& m_l; - CZipString m_lpszFile; - bool m_bRecursive; - bool m_bAddEmpty; -}; - -void -DisplayUsage() -{ - printf("\ -\n\ -Zippie v2.2\n\ -Copyright (C) 2000 - 2003 Tadeusz Dracz\n\ -E-Mail: tdracz@artpol-software.com\n\ -Web : http://www.artpol-software.com\n\ -\n\ -This program is free software; you can redistribute it and/or\n\ -modify it under the terms of the GNU General Public License\n\ -as published by the Free Software Foundation; either version 2\n\ -of the License, or (at your option) any later version.\n\ -\n\ -This is a zipping and unzipping program.\n\ -It was created using ZipArchive library in the STL version.\n\ -\n\ -\n\ -USAGE: zippie \n\ -\n\ -Notes:\n\ - - the order of commands and switches doesn't matter\n\ - - if some files have spaces inside, put them inside quotation marks\n\ -\n\ -************ Default switches ************\n\ -\n\ --f [.zip]\n\ - file to create or open (can be with or without extension)\n\ - the extension .zip is added automatically if not present\n\ --st\n\ - use this switch if you're opening an existing disk spanning archive\n\ - in tdSpan mode on a removable device (or under Linux)\n\ - (doesn't matter for commands that modify the archive \n\ - e.g. add or delete commands)\n\ -\n\ -************ Add files to archive commands ************\n\ -\n\ --a \n\ - add to the ; separate them with spaces;\n\ - you can use wildcards (*?)\n\ --af \n\ - add files listed in (one file per line);\n\ - no wildcards allowed in the files\n\ --ax \n\ - prevent from being added to the ;\n\ - separate them with spaces; you can use wildcards (*?)\n\ --afx \n\ - prevent files listed in (one file per line) to be added \n\ - to the ; no wildcards allowed in the files\n\ -\n\ - you can use switches -a, -af, -ax, -afx simultaneously\n"); - printf("\ -\n\ --r\n\ - recurse subdirectories; don't include in the directories\n\ - from which no file is added; under linux put file masks into \n\ - quotation marks otherwise they will be automatically expaned by \n\ - the shell and the recursion will be one level only\n\ --re\n\ - recurse subdirectories and add all subdirectories even empty to the\n\ - ; see a note above about using file masks under Linux\n\ --u\n\ - this switch tells the program to not delete the if it\n\ - already exists (and if it is not a disk spanning archive), but add\n\ - the to it;\n\ - if this switch is not specified, there is a new archive created\n\ - even if one with the same name already exists (it is overwritten)\n\ --as []\n\ - (add smartly) if this switch is specified, in the disk spanning mode\n\ - the file is first compressed to a temporary directory to see whether \n\ - it is smaller after compression; if it is not it stored then without \n\ - a compression; (you can specify a where the temporary files \n\ - will be created, if you do not specify it, they will be created in \n\ - the directory specified by the TMP system variable or if this variable\n\ - is not defined the file will be created in the current directory;\n\ - in normal archive if there is a such a situation the file is removed\n\ - from the archive and then stored again but with no compression \n\ - (the argument is ignored)\n\ --c \n\ - set the compression level (from 0 to 9);\n\ - if not specified, 5 is assumed\n\ - 0 means no compression - only storing\n\ --v \n\ - create a disk spanning archive\n\ - if is 0 create archive in pkSpan mode,\n\ - if is greater than 0 create archive in tdSpan mode\n\ -\n"); - printf("\ -************ Extract commands ************\n\ -\n\ --xp \n\ - it specifies the path the files will be extracted to; if not present,\n\ - the current path is assumed\n\ --x \n\ - extract to the destination ;\n\ - separate them with spaces; wildcards are allowed\n\ --xr \n\ - extract files with the given to the destination \n\ - separate number with spaces; to specify a range of numbers \n\ - put between them a hyphen without spaces e.g. 3-6; \n\ - put before an exclamation mark to exclude the numbers from the set\n\ - (e.g. 2-20 !6-8 !10);\n\ - (use -lr command to list the files with numbers)\n\ --xf \n\ - extract files listed in (one file per line)\n\ - to the destination ; wildcards are allowed\n\ --xa \n\ - extract all files from the archive to the \n\ -\n\ - you can use switches -x , -xr and -xf (and even -xa) simultaneously\n\ -\n\ -************ Delete commands ************\n\ -\n\ --d \n\ - delete separate them with spaces; wildcards are allowed\n"); - printf("\ --dr \n\ - delete files with the given \n\ - separate number with spaces; to specify a range of numbers \n\ - put between them a hyphen without spaces e.g. 3-6 \n\ - put before an exclamation mark to exclude the numbers from the set\n\ - (e.g. 2-20 !6-8 !10);\n\ - (use -lr command to list the files with numbers)\n\ --df \n\ - delete files listed in (one file per line)\n\ - wildcards are allowed\n\ --da \n\ - delete all the files from the archive\n\ -\n\ - you can use switches -d , -dr and -df (and even -da) simultaneously\n\ -\n\ -************ Other commands ************\n\ -\n\ --t\n\ - test the \n\ --p \n\ - set the when adding files to \n\ - or extracting them; the is set for all the files\n\ - - you cannot set it separately for each file in one session\n\ --l\n\ - list the files inside \n\ --lr\n\ - list the files inside with the numbers\n\ --ll\n\ - list the files inside (only filenames)\n\ - when redirected to a file, it can be used then with command -xf\n\ -\n"); - printf("\ -************ Special switches ************\n\ -\n\ --cs \n\ - enable case sensitivity when:\n\ - - searching for files inside while using the command\n\ - -x or -xf (if not specified a search is non-case-sensitive)\n\ - - adding files to and trying to avoid the same\n\ - filenames in the archive\n\ --g \n\ - Set the global of the \n\ - (cannot be used on an existing disk spanning archive)\n\ - if the contains spaces, put the whole \n\ - inside quotation marks\n\ --rp \n\ - set root (see CZipArchive::SetRootPath() function description)\n\ --nfp\n\ - the same as bFullPath set to false in functions\n\ - CZipArchive::AddNewFile() and CZipArchive::ExtractFile()\n\ - (if not present, bFullPath is assumed to be true; if -rp specified\n\ - bFullPath is always false);\n\ --w\n\ - Wait for a key after finishing the work to let the user read the output\n\ - in some environments\n\ --dse\n\ - Display only errors when adding or extracting files\n\ -\n\ -************ Sample commands ************\n\ -\n\ -zippie -f a:\\archive -a * -v 0 -as -c 9 \n\ - (create a disk spanning archive adding all the files from the current \n\ - directory, smart add is used, compression level set to maximum)\n\ -\n\ -zippie -f a:\\archive -xp d:\\a -x zippie.cpp -xr 2-12 !5-7 !9\n\ - (extract file zippie.cpp from the archive and the files with numbers \n\ - from 2 to 12 and the file number 15 apart from 5 to 7 and 9)\n\ -\n\ -zippie -f example -xa\n\ - extract all files from example.zip file to the current directory\n\ -\n\ -"); -} - -char -ReadKey() -{ - fflush(stdin); - char c = (char)tolower(getchar()); - return c; -} - -struct SpanCallback : public CZipSpanCallback -{ - bool Callback(int iProgress) - { - printf("Insert disk number %d and hit ENTER to contuniue \n or press " - "'n' key followed by ENTER to abort (code = %d)\n", - m_uDiskNeeded, - iProgress); - return ReadKey() != 'n'; - } -}; - -void -FillFromFile(FILELIST& l, LPCTSTR lpszFile, bool bCheck) -{ - FILE* f = fopen(lpszFile, "rt"); - if (!f) { - printf("File %s could not be opened\n", lpszFile); - return; - } - fseek(f, 0, SEEK_END); - int iSize = ftell(f); - fseek(f, 0, SEEK_SET); - CZipAutoBuffer buf(iSize + 1); - iSize = fread(buf, 1, iSize, f); - fclose(f); - char* sEnd = buf + iSize; - char* sBeg = buf; - for (char* pos = buf;; pos++) { - bool bEnd = pos == sEnd; // there may be no newline at the end - if (strncmp(pos, "\n", 1) == 0 || bEnd) { - *pos = '\0'; - CZipString s = sBeg; - s.TrimLeft(" "); - s.TrimRight(" "); - if (!s.IsEmpty() && (!bCheck || ZipPlatform::FileExists(s) != 0)) - l.push_back(s); - if (bEnd) - break; - sBeg = pos + 1; - } - } -} - -bool -IsDots(LPCTSTR lpsz) -{ - return strcmp(lpsz, ".") == 0 || strcmp(lpsz, "..") == 0; -} - -void -AddDirectory(CZipString szPath, struct AddDirectoryInfo& info, bool bDoNotAdd) -{ - if (!szPath.IsEmpty()) - CZipPathComponent::AppendSeparator(szPath); - - bool bPathAdded = info.m_bAddEmpty || bDoNotAdd; - if (info.m_bAddEmpty && !szPath.IsEmpty() && !bDoNotAdd) - info.m_l.push_back(szPath); - -#ifdef __GNUC__ - DIR* dp = opendir(szPath.IsEmpty() ? "." : szPath); - if (!dp) - return; - struct dirent* entry; - while (entry = readdir(dp)) { - struct stat sStats; - CZipString szFullFileName = szPath + entry->d_name; - if (stat(szFullFileName, &sStats) == -1) - continue; - if (S_ISDIR(sStats.st_mode)) { - if (info.m_bRecursive) { - if (IsDots(entry->d_name)) - continue; - - AddDirectory(szFullFileName, info, false); - } - } else if (fnmatch(info.m_lpszFile, - entry->d_name, - FNM_NOESCAPE | FNM_PATHNAME) == 0) { - if (!bPathAdded) { - if (!szPath.IsEmpty()) - info.m_l.push_back(szPath); - bPathAdded = true; - } - info.m_l.push_back(szPath + entry->d_name); - } - } - closedir(dp); - -#else - CZipString szFullFileName = szPath + info.m_lpszFile; - struct _finddata_t c_file; - long hFile; - if ((hFile = _findfirst(szFullFileName, &c_file)) != -1L) { - do { - if (!(c_file.attrib & FILE_ATTRIBUTE_DIRECTORY)) { - // add it when the first file comes - if (!bPathAdded) { - if (!szPath.IsEmpty()) - info.m_l.push_back(szPath); - bPathAdded = true; - } - info.m_l.push_back(szPath + c_file.name); - } - } while (_findnext(hFile, &c_file) == 0L); - } - _findclose(hFile); - - if (info.m_bRecursive) { - szFullFileName = szPath + "*"; - if ((hFile = _findfirst(szFullFileName, &c_file)) != -1L) { - do { - if (c_file.attrib & FILE_ATTRIBUTE_DIRECTORY) { - if (IsDots(c_file.name)) - continue; - szFullFileName = szPath + c_file.name; - AddDirectory(szFullFileName, info, false); - } - } while (_findnext(hFile, &c_file) == 0L); - } - _findclose(hFile); - } -#endif -} - -void -ExpandFile(FILELIST& l, - LPCTSTR lpszPath, - bool bRecursive, - bool bAddEmpty, - bool bFullPath) -{ - // check if we need to expand it - // size_t pos = strcspn(lpszFile, "*?"); - // if (pos == strlen(lpszFile)) - // { - // l.push_back(lpszFile); - // return; - // } - - CZipPathComponent zpc(lpszPath); - CZipString szDir = zpc.GetFilePath(); - // if (szDir.IsEmpty()) - // if (!ZipPlatform::GetCurrentDirectory(szDir)) - // return; - struct AddDirectoryInfo adi(l); - adi.m_bAddEmpty = bAddEmpty; - adi.m_bRecursive = bRecursive; - adi.m_lpszFile = zpc.GetFileName(); - AddDirectory(szDir, adi, !bFullPath); // when not full path is specified for - // a single file with a path, do not - // add a directory then -} - -void -FindInZip(CZipArchive& zip, FILELIST& l, CZipWordArray& n) -{ - - for (FILELISTIT it = l.begin(); it != l.end(); ++it) - zip.FindMatches(*it, n); -} - -void -ProcessData(CZipArchive& zip, - CCmdLine& cmd, - CZipWordArray& vRevised, - bool bExtract) -{ - - if (cmd.HasSwitch(bExtract ? "-xa" : "-da")) { - int iMax = zip.GetCount(); - for (int i = 0; i < iMax; i++) - vRevised.Add(i); - } else { - CZipWordArray numbers; - CZipString temp = bExtract ? "-x" : "-d"; - int iCount = cmd.GetArgumentCount(temp); - if (iCount > 0) { - FILELIST lFiles; - for (int i = 0; i < iCount; i++) - lFiles.push_back(cmd.GetArgument(temp, i)); - FindInZip(zip, lFiles, numbers); - } - temp = bExtract ? "-xf" : "-df"; - if (cmd.GetArgumentCount(temp) > 0) { - FILELIST lFiles; - FillFromFile(lFiles, cmd.GetArgument(temp, 0), false); - FindInZip(zip, lFiles, numbers); - } - - temp = bExtract ? "-xr" : "-dr"; - iCount = cmd.GetArgumentCount(temp); - CZipWordArray notNumbers; - if (iCount > 0) { - for (int i = 0; i < iCount; i++) { - CZipString sz = cmd.GetArgument(temp, i); - bool bNot = !sz.IsEmpty() && sz[0] == '!'; - CZipWordArray& vN = bNot ? notNumbers : numbers; - if (bNot) - sz.TrimLeft('!'); - size_t pos = strcspn(sz, "-"); - if (pos == sz.GetLength()) - vN.Add(atoi(sz) - 1); - else { - int b = atoi(sz.Left(pos)); - int e = atoi(sz.Mid(pos + 1)); - for (int i = b; i <= e; i++) - vN.Add(i - 1); - } - } - } - int iSize = notNumbers.GetSize(); - if (iSize) { - for (int j = 0; j < iSize; ++j) - for (int i = numbers.GetSize(); i >= 0; i--) - if (numbers[i] == notNumbers[j]) - numbers.RemoveAt(i); - } - - int iMax = zip.GetCount() - 1; - for (int i = 0; i < numbers.GetSize(); ++i) { - int x = numbers[i]; - if (x < 0 || x > iMax) - continue; - bool bNew = true; - for (int j = 0; j < vRevised.GetSize(); ++j) - if (vRevised[j] == numbers[i]) { - bNew = false; - break; - } - if (bNew) - vRevised.Add(x); - } - } -} - -int -main(int argc, char* argv[]) -{ -#ifndef __GNUC__ - // set the locale the same as the system locale - // to handle local characters (non-English) properly by CZipString - std::locale::global(std::locale("")); -#endif - int iRet = 0; - - CCmdLine cmd; - CZipArchive zip; - CZipString szArchive; - try { - - if (cmd.SplitLine(argc, argv) < 1) - throw 0; - if (cmd.GetArgumentCount("-f") <= 0) - throw 0; - int iVolumeSize = 0; - int iMode = CZipArchive::zipOpen; - bool bIsAdding = - cmd.GetArgumentCount("-a") > 0 || cmd.GetArgumentCount("-af") > 0; - bool bIsExtracting = - cmd.GetArgumentCount("-x") > 0 || cmd.GetArgumentCount("-xr") > 0 || - cmd.GetArgumentCount("-xf") > 0 || cmd.HasSwitch("-xa"); - bool bIsDeleting = - cmd.GetArgumentCount("-d") > 0 || cmd.GetArgumentCount("-dr") > 0 || - cmd.GetArgumentCount("-df") > 0 || cmd.HasSwitch("-da"); - - szArchive = cmd.GetArgument("-f", 0); - CZipPathComponent zpc(szArchive); - if (zpc.GetFileExt().IsEmpty()) - szArchive += ".zip"; - bool bUpdateMode = cmd.HasSwitch("-u"); - bool bSetComment = cmd.GetArgumentCount("-g") > 0; - bool bIsListing = - cmd.HasSwitch("-l") || cmd.HasSwitch("-ll") || cmd.HasSwitch("-lr"); - bool bOnlyErrors = cmd.HasSwitch("-dse"); - if (bIsAdding) { - if (cmd.GetArgumentCount("-v") > 0) { - iMode = CZipArchive::zipCreateSpan; - iVolumeSize = atoi(cmd.GetArgument("-v", 0)); - } else { - if (!bUpdateMode || !ZipPlatform::FileExists(szArchive)) - iMode = CZipArchive::zipCreate; - } - } else if (bIsExtracting || cmd.HasSwitch("-t") || bIsListing) { - if (cmd.HasSwitch("-st")) - iVolumeSize = 1; - } else if (!bSetComment && !bIsDeleting) - throw 0; - - SpanCallback span; - zip.SetSpanCallback(&span); - - bool bAddEmpty = cmd.HasSwitch("-re"); - bool bRecursive = cmd.HasSwitch("-r") || bAddEmpty; - - bool bCaseSensitiveInZip = cmd.HasSwitch("-cs"); - pZipComp = GetCZipStrCompFunc(bCaseSensitiveInZip); - - zip.SetCaseSensitivity(bCaseSensitiveInZip); - try { - zip.Open(szArchive, iMode, iVolumeSize); - if (cmd.GetArgumentCount("-p") > 0) - zip.SetPassword(cmd.GetArgument("-p", 0)); - } catch (...) { - bool bContinue = false; - if (iMode == CZipArchive::zipOpen && !bIsDeleting && !bSetComment) { - try { - // try to open in read only mode (required if there is no - // write access to the storage) - zip.Open( - szArchive, CZipArchive::zipOpenReadOnly, iVolumeSize); - bContinue = true; - } catch (...) { - throw; - } - } - if (!bContinue) - throw; - } - - if (cmd.GetArgumentCount("-rp") > 0) - zip.SetRootPath(cmd.GetArgument("-rp", 0)); - - bool bFullPath = !cmd.HasSwitch("-nfp") && zip.GetRootPath().IsEmpty(); - - bool bIsSpan = zip.GetSpanMode() != 0; - if (bSetComment && !bIsSpan) { - CZipString sz = cmd.GetArgument("-g", 0); - sz.TrimLeft("\""); - sz.TrimRight("\""); - zip.SetGlobalComment(sz); - } - - if (bIsAdding) { - if (bUpdateMode && bIsSpan) { - printf("Cannot update an existing disk spanning archive\n"); - zip.Close(); - return 1; - } - int iLevel = atoi(cmd.GetSafeArgument("-c", 0, "5")); - int iSmartLevel; - if (cmd.HasSwitch("-as")) { - iSmartLevel = CZipArchive::zipsmSmartest; - zip.SetTempPath(cmd.GetSafeArgument("-as", 0, "")); - } else - iSmartLevel = CZipArchive::zipsmSafeSmart; - - FILELIST lFiles; - int iCount = cmd.GetArgumentCount("-a"); - if (iCount > 0) { - - for (int i = 0; i < iCount; i++) - - ExpandFile(lFiles, - cmd.GetArgument("-a", i), - bRecursive, - bAddEmpty, - bFullPath); - } - - iCount = cmd.GetArgumentCount("-af"); - if (iCount > 0) - FillFromFile(lFiles, cmd.GetArgument("-af", 0), true); - - FILELIST excl; - - iCount = cmd.GetArgumentCount("-ax"); - if (iCount > 0) { - for (int i = 0; i < iCount; i++) - - ExpandFile(excl, - cmd.GetArgument("-ax", i), - bRecursive, - bAddEmpty, - bFullPath); - } - - iCount = cmd.GetArgumentCount("-afx"); - if (iCount > 0) - FillFromFile(excl, cmd.GetArgument("-afx", 0), true); - - FILELISTADD rev; - for (FILELISTIT it = lFiles.begin(); it != lFiles.end(); ++it) { - // that is how the filename will look in the archive - CZipString sz = zip.PredictFileNameInZip(*it, bFullPath); - if (!sz.IsEmpty()) { - bool bAdd = true; - for (FILELISTIT itt = excl.begin(); itt != excl.end(); - ++itt) { - if (!((*itt).*pZipComp)(*it)) { - bAdd = false; - break; - } - } - if (bAdd) - rev.push_back(CZipAddFileInfo(*it, sz)); - } - } - lFiles.clear(); - excl.clear(); - - // remove duplicates - FILELISTADDIT it1; - for (it1 = rev.begin(); it1 != rev.end();) { - bool bErase = false; - FILELISTADDIT it2 = it1; - for (++it2; it2 != rev.end(); ++it2) { - int x = ((*it1).m_szFileNameInZip.* - pZipComp)((*it2).m_szFileNameInZip); - if (x == 0) { - bErase = true; - break; - } - } - if (bErase) - rev.erase(it1++); - else - ++it1; - } - - // sort - rev.sort(std::greater()); - printf("\n"); - for (it1 = rev.begin(); it1 != rev.end(); ++it1) { - if (zip.AddNewFile( - (*it1).m_szFilePath, iLevel, bFullPath, iSmartLevel)) { - if (!bOnlyErrors) - printf("%s added\n", (LPCTSTR)(*it1).m_szFileNameInZip); - } else - printf("%s not added\n", (LPCTSTR)(*it1).m_szFilePath); - } - } else if (bIsExtracting) { - CZipString szPath = cmd.GetSafeArgument("-xp", 0, "."); - - CZipWordArray vRevised; - ProcessData(zip, cmd, vRevised, true); - printf("\n"); - for (int k = 0; k < vRevised.GetSize(); ++k) { - int iFile = vRevised[k]; - try { - zip.ExtractFile(iFile, szPath, bFullPath); - CZipFileHeader fh; - if (zip.GetFileInfo(fh, iFile)) { - if (!bOnlyErrors) - printf("%s extracted\n", (LPCTSTR)fh.GetFileName()); - } - } catch (...) { - CZipFileHeader fh; - if (zip.GetFileInfo(fh, iFile)) - printf("Error extracting file %s\n", - (LPCTSTR)fh.GetFileName()); - else - printf("There are troubles with getting info from file " - "number %d\n", - iFile); - } - } - printf("\n"); - } else if (bIsDeleting) { - if (bIsSpan) { - printf( - "Cannot delete from an existing disk spanning archive\n"); - zip.Close(); - return 1; - } - CZipWordArray vRevised; - ProcessData(zip, cmd, vRevised, false); - try { - zip.DeleteFiles(vRevised); - } catch (...) { - printf("Error occured while deleting files\n"); - } - } else if (cmd.HasSwitch("-t")) { - FILELIST lFiles; - int iCount = zip.GetCount(); - for (int i = 0; i < iCount; i++) { - bool bOK = false; - try { - bOK = zip.TestFile(i); - printf("Tested: %d of %d \r", i, iCount); - } catch (...) { - } - if (!bOK) { - CZipFileHeader fh; - if (zip.GetFileInfo(fh, i)) - lFiles.push_back(fh.GetFileName()); - else { - char buf[50]; - sprintf(buf, - "There are troubles with getting info from " - "file number %d", - i); - lFiles.push_back(buf); - } - } - } - printf("\n"); - if (lFiles.size()) { - printf("There were errors found in the following files:\n"); - for (FILELISTIT it = lFiles.begin(); it != lFiles.end(); ++it) - printf("%s\n", (LPCTSTR)(*it)); - } else - printf("There were no errors found in the archive\n"); - } else if (bIsListing) { - bool bNumbers = cmd.HasSwitch("-lr"); - bool bDescription = !cmd.HasSwitch("-ll"); - int iCount = zip.GetCount(); - if (bDescription) - printf("\n File name\tSize\t\tRatio\tTime Stamp\n\n"); - for (int i = 0; i < iCount; i++) { - CZipFileHeader fh; - if (zip.GetFileInfo(fh, i)) { - if (bNumbers) - printf("%d. ", i + 1); - - printf("%s\n", (LPCTSTR)fh.GetFileName()); - if (bDescription) { - printf("\t\t"); - if (fh.IsDirectory()) - printf("\t\t"); - else { - printf("%u Bytes\t", fh.m_uUncomprSize); - printf("%.2f%%", fh.GetCompressionRatio()); - } - time_t t = fh.GetTime(); - printf("\t%s", ctime(&t)); - } - } else - printf("There are troubles with getting info from file " - "number %d\n", - i); - } - printf("\n"); - CZipString sz = zip.GetGlobalComment(); - if (!sz.IsEmpty()) - printf("Global archive comment:\n%s\n", (LPCTSTR)sz); - } - - zip.Close(); - } catch (int) { - DisplayUsage(); - iRet = 1; - } catch (CZipException e) { - printf("Error while processing archive %s\n%s\n", - (LPCTSTR)szArchive, - (LPCTSTR)e.GetErrorDescription()); - if (e.m_szFileName.IsEmpty()) - printf("\n"); - else - printf("Filename in error object: %s\n\n", (LPCTSTR)e.m_szFileName); - zip.Close(true); - iRet = 1; - } catch (...) { - printf("Unknown error while processing archive %s\n\n", - (LPCTSTR)szArchive); - zip.Close(true); - iRet = 1; - } - - if (cmd.HasSwitch("-w")) { - printf("\nPress to exit.\n"); - ReadKey(); - printf("\n"); - } - return iRet; -} diff --git a/src/smpackagee/ZipArchive/stl/zippie/zippie.dsp b/src/smpackagee/ZipArchive/stl/zippie/zippie.dsp deleted file mode 100644 index 288dc3bfb6..0000000000 --- a/src/smpackagee/ZipArchive/stl/zippie/zippie.dsp +++ /dev/null @@ -1,111 +0,0 @@ -# Microsoft Developer Studio Project File - Name="zippie" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=zippie - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "zippie.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "zippie.mak" CFG="zippie - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "zippie - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "zippie - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName ""$/zippie", BGAAAAAA" -# PROP Scc_LocalPath "." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "zippie - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE RSC /l 0x415 /d "NDEBUG" -# ADD RSC /l 0x415 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "zippie - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE RSC /l 0x415 /d "_DEBUG" -# ADD RSC /l 0x415 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "zippie - Win32 Release" -# Name "zippie - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\CmdLine.cpp -# End Source File -# Begin Source File - -SOURCE=.\zippie.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\CmdLine.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/src/smpackagee/ZipArchive/stl/zippie/zippie.dsw b/src/smpackagee/ZipArchive/stl/zippie/zippie.dsw deleted file mode 100644 index 032bc18743..0000000000 --- a/src/smpackagee/ZipArchive/stl/zippie/zippie.dsw +++ /dev/null @@ -1,44 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "ZipArchive"="..\..\ZipArchive_STL.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "zippie"=".\zippie.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name ZipArchive - End Project Dependency -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/src/smpackagee/ZipArchive/stl/zippie/zippie_DLL.dsp b/src/smpackagee/ZipArchive/stl/zippie/zippie_DLL.dsp deleted file mode 100644 index 6af7af75a5..0000000000 --- a/src/smpackagee/ZipArchive/stl/zippie/zippie_DLL.dsp +++ /dev/null @@ -1,112 +0,0 @@ -# Microsoft Developer Studio Project File - Name="zippie" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=zippie - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "zippie_DLL.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "zippie_DLL.mak" CFG="zippie - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "zippie - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "zippie - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName ""$/zippie", BGAAAAAA" -# PROP Scc_LocalPath "." -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "zippie - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "ZIP_HAS_DLL" /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE RSC /l 0x415 /d "NDEBUG" -# ADD RSC /l 0x415 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "zippie - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "ZIP_HAS_DLL" /FR /FD /GZ /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE RSC /l 0x415 /d "_DEBUG" -# ADD RSC /l 0x415 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "zippie - Win32 Release" -# Name "zippie - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\CmdLine.cpp -# End Source File -# Begin Source File - -SOURCE=.\zippie.cpp -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\CmdLine.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/src/smpackagee/ZipArchive/stl/zippie/zippie_DLL.dsw b/src/smpackagee/ZipArchive/stl/zippie/zippie_DLL.dsw deleted file mode 100644 index c78c2339c5..0000000000 --- a/src/smpackagee/ZipArchive/stl/zippie/zippie_DLL.dsw +++ /dev/null @@ -1,59 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "ZipArchive"="..\..\ZipArchive_STL_DLL.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name zlib - End Project Dependency -}}} - -############################################################################### - -Project: "zippie"=".\zippie_DLL.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ - Begin Project Dependency - Project_Dep_Name ZipArchive - End Project Dependency -}}} - -############################################################################### - -Project: "zlib"="..\..\zlib\zlib.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/src/smpackagee/res/smpackage.ico b/src/smpackagee/res/smpackage.ico deleted file mode 100644 index 7eef0bcbe6580a6f464d688906172c2d9de44262..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1078 zcmc&zF>b>!3}jLb9s)T}@Kod(893@u8ajANzT`op9^o+)S?=nU(FD@%0s)Sg^oyC8{H z9myetc;MEP)59v(LMa~xK8Yu^jIR*H22uCFiq5%C{s7(PJi>o15i^bmX4(vPxWAio z9ryY#AU_jfnd047-@`)XzL?%iS$gQyFP{44kS9X)fN{{QoL~hO-&=q&20Zr*cxFAt PkaNE{wR~2C$NfnjhSXWT diff --git a/src/smpackagee/res/smpackage.rc2 b/src/smpackagee/res/smpackage.rc2 deleted file mode 100644 index 50a7391dbf..0000000000 --- a/src/smpackagee/res/smpackage.rc2 +++ /dev/null @@ -1,13 +0,0 @@ -// -// SMPACKAGE.RC2 - resources Microsoft Visual C++ does not edit directly -// - -#ifdef APSTUDIO_INVOKED - #error this file is not editable by Microsoft Visual C++ -#endif //APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// Add manually edited resources here... - -///////////////////////////////////////////////////////////////////////////// diff --git a/src/smpackagee/resource.h b/src/smpackagee/resource.h deleted file mode 100644 index 4de5cc6a64..0000000000 --- a/src/smpackagee/resource.h +++ /dev/null @@ -1,105 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by smpackage.rc -// -#define IDD_SMPACKAGE_DIALOG 102 -#define IDD_MANAGER 102 -#define IDR_MAINFRAME 128 -#define IDD_INSTALL 129 -#define IDD_EXPORTER 130 -#define IDD_DIALOG_NAME 137 -#define IDD_EDIT_INSTALLATIONS 138 -#define IDD_MENU 139 -#define IDD_ENTER_COMMENT 146 -#define IDD_SHOW_COMMENT 147 -#define IDD_UNINSTALL_OLD_PACKAGES 148 -#define IDD_CHANGE_GAME_SETTINGS 149 -#define IDD_LANGUAGES 150 -#define IDD_CREATE_LANGUAGE 151 -#define IDB_BITMAP1 153 -#define IDC_LIST_SONGS 1000 -#define IDC_LIST 1000 -#define IDC_BUTTON_PLAY 1001 -#define IDC_BUTTON_EXPORT 1002 -#define IDC_BUTTON_EXPORT_AS_ONE 1002 -#define IDC_BUTTON_BACK 1003 -#define IDC_BUTTON_EXPORT_AS_INDIVIDUAL 1003 -#define IDC_BUTTON_OPEN 1004 -#define IDC_EDIT_MESSAGE1 1005 -#define IDC_EDIT_MESSAGE3 1006 -#define IDC_EDIT_MESSAGE2 1007 -#define IDC_TREE 1011 -#define IDC_EDIT 1012 -#define IDC_COMBO_DIR 1013 -#define IDC_BUTTON_EDIT 1014 -#define IDC_BUTTON_ADD 1018 -#define IDC_BUTTON_REMOVE 1019 -#define IDC_BUTTON_MAKE_DEFAULT 1020 -#define IDC_EXPORT_PACKAGES 1022 -#define IDC_LIST_THEMES 1023 -#define IDC_EDIT_INSTALLATIONS 1024 -#define IDC_BUTTON_CONVERT 1024 -#define IDC_BUTTON_ANALYZE 1025 -#define IDC_CHANGE_API 1025 -#define IDC_CHANGE_PREFERENCES 1025 -#define IDC_BUTTON_EDIT_METRICS 1026 -#define IDC_CREATE_SONG 1026 -#define IDC_BUTTON_ANALYZE_METRICS 1027 -#define IDC_OPEN_STEPMANIA_INI 1027 -#define IDC_OPEN_PREFERENCES 1027 -#define IDC_EDIT_VALUE 1028 -#define IDC_CLEAR_PREFERENCES 1028 -#define IDC_EDIT_DEFAULT 1029 -#define IDC_CLEAR_KEYMAPS 1029 -#define IDC_VIEW_STATISTICS 1030 -#define IDC_CLEAR_KEYMAPS2 1031 -#define IDC_CLEAR_CACHE 1031 -#define IDC_LANGUAGES 1032 -#define IDC_BUTTON_REFRESH 1035 -#define IDC_BUTTON_SAVE 1036 -#define IDC_BUTTON_OVERRIDE 1037 -#define IDC_BUTTON_HELP 1038 -#define IDC_BUTTON_CLOSE 1039 -#define IDC_DONTASK 1041 -#define IDC_DONTSHOW 1042 -#define IDC_PACKAGES 1044 -#define IDC_BUTTON1 1045 -#define IDC_BUTTON_DELETE 1046 -#define IDC_PROGRESS1 1047 -#define IDC_RADIO_DEFAULT 1048 -#define IDC_BUTTON_IMPORT 1048 -#define IDC_RADIO_OPENGL 1049 -#define IDC_RADIO_DIRECT3D 1050 -#define IDC_RADIO_SOUND_DEFAULT 1051 -#define IDC_RADIO_SOUND_NULL 1052 -#define IDC_CHECK_LOG_TO_DISK 1053 -#define IDC_CHECK_SHOW_LOG_WINDOW 1054 -#define IDC_EDIT_INSTALLATION 1054 -#define IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE 1055 -#define IDC_BUTTON_LAUNCH_GAME 1055 -#define IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE 1056 -#define IDC_RADIO_SOUND_WAVEOUT 1057 -#define IDC_BUTTON_CREATE 1057 -#define IDC_LIST_LANGUAGES 1058 -#define IDC_CHECK_FORCE_60HZ 1058 -#define IDC_STATIC_TOTAL_STRINGS 1060 -#define IDC_STATIC_NEED_TRANSLATION 1061 -#define IDC_COMBO_LANGUAGES 1065 -#define IDC_CHECK_EXPORT_ALREADY_TRANSLATED 1066 -#define IDC_STATIC_HEADER_TEXT 1067 -#define IDC_STATIC_MESSAGE2 1068 -#define IDC_STATIC_MESSAGE1 1069 -#define IDC_STATIC_ICON 1070 -#define IDC_SHOW_A_COMMENT 1071 -#define IDC_CHECK_LANGUAGE 1072 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 155 -#define _APS_NEXT_COMMAND_VALUE 32771 -#define _APS_NEXT_CONTROL_VALUE 1073 -#define _APS_NEXT_SYMED_VALUE 104 -#endif -#endif diff --git a/src/smpackagee/smpackage.ICO b/src/smpackagee/smpackage.ICO deleted file mode 100644 index de59ebc5d78d488ca7406aa4539306138b5af908..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6006 zcmeI0&rh328pj`(RfwxDwA+P1LSkaD{n{G>xK8>rp+~}rOTu-<6>U_B%NDA|YuS+; zG@v4po1+}6sxl`o5xH48fK)X(`4lA*GE%DcP&wE}ysG8d?=$nheqYHC={shvOwjZf23kr(r!u8Mp4qzzNFbbNuj(X;%ncDjtD9 z0KWr%6Z|sx1+ceq-2#6D{51Fw_+jv{ySod11N;*BS@0pS)W8Lvz!P`^PxEvH{s8MQRd=dOU_&xA>@OkiC;8(yef}aB)2QR@(@DjWP zFTqRj4g9^t-xK^jz~3_d<`rKCUjknQzYl&7JX_C$-U7V>dJ*&-=s4^jfjvvUv;H zyn$>^Bby;)a~OOXdfedWq?J zg6VpI=~~8g&Ce5+!I!`n!S93L1D^-qW%b!~9q^mrk!iVrfq5sWD9hkW;EUk*!S8`ba=Ij_D6yV#ZQxqMHH#~R zt6PGOkB{l~>(}(+#S41={5d^+`jj3&eoXm%o*q7YNLyQ5bno6hT3K14yLa!>;^HFR zxpRl+=H}?;&6^aD$0-~R)A{q~sjsh(%704w;n5?!$4R^|@XN0f{40Swha&mrS%k13 z3#+KM^VsgzQus5Lf{>|{Kb_0|i`ydQZ`x^55He$#MF@&tUF8SzExezLP<$qrUC#<` zy@l5fT>RVYr>*$4eZ-$#MdV%WQ!^1zNcsJ_TviRV`M71YEe#!(7ijl5QYi}g%d1x& zX%wsL>)Bi;o%W~wek9$W(_=tho_X*hi=4Um6nLe8j;xN}9jAJl&1PU99$=pxq|;7p zZ6k1ZSarV&ES<^Zke=-7y2lvY9Ux)hDZ5K#nkI+?H(JjOfl;fO8~o-UNDZUt8$R<$|+ ze0Xqh@LXhg@aomU@kon8=Xk4^Spi0a<`C{uD}0$imSD1Dyrdj3c`kB}`Dx_<{54G5 zamV~t|IX%v!Qhz5_h2Yof)bAyd4KzO)o{%(9K3V1L<4_ADpiTa-1)R-wPU
OZF zlX6T4qpWw1*Kx}00Rtbyda&0_<+$s5R@NCe9o!nP*OII7dY)q3Y+83*d(`m0aO`-6 z?O+%ZUDvaEAKP&~za8&7Tf+N(b*SCC^TIRYE;Yo1(i#k}4}9=4`UB&}@pi?4$68`f zSv-D#I)9_7HgRRbZ9*vAvhTsWS+3*vwwrxtSWeBtJ?)G8{29q^-@{jhze)IH@JB;B z+HENn_wPf+=J^xDI&F|UV6m#~!@TuP;_ZMNXs^3m+tqdiZ7J)LOqQqrp>LE_6x!|b zJ3df>Z_u|a^=3*IsQ%1RdcPqpl=GcOB0 z(kEH^8fx2i2vcjUM{7xzr!>R%3q%3tAp4kuJi{Dh4|9iB94syFjK%d?T!1<7${y^l zDZgd-gFWRR{TvT-vd}BpuPpR8bew^@9>SE?zw@)+{vi;O zpJ2bwM+t#S8zA&aM#}Uy`URT6-9@#9NS)nAH!N9wwnruLjHOFW;E0vo-p*z4HB(1I zVI2%LBi7V6GM7tpKU>ztwqUolWGtQX{_?Yi;8S0F|7bM&kES^(zi;cW8j*S#b5K>J=j#EQKSVSc~8f@+KE_Wv=q)PVqY z)P{lG`X{`%Z}HDfE>U9~`)6y%>hiC9t1)yBMYOitzwWL?jWIc9*n38of8CGyk&}_A z^36|N<5$3CBRt;J*2@!ftabTbi5Z5Y&F5i0+q!`2gmaq3cJlj_dO<7$t?N_xd409? z^YYJb=lH)8=`@ya`})%FhwjhizIFNa^k6+yLN>~OmGy7V$~yKSsMl!(8;=iW%0&IR zu$L(GHUfve_5N~yz4tUw@2LkGzWR)$(;1?FV@EO)NPpsmx SuOIr#4%=kgr!ZZoe)&I3EM-0b diff --git a/src/smpackagee/smpackage.clw b/src/smpackagee/smpackage.clw deleted file mode 100644 index ef17bb3487..0000000000 --- a/src/smpackagee/smpackage.clw +++ /dev/null @@ -1,321 +0,0 @@ -; CLW file contains information for the MFC ClassWizard - -[General Info] -Version=1 -LastClass=MainMenuDlg -LastTemplate=CDialog -NewFileInclude1=#include "stdafx.h" -NewFileInclude2=#include "smpackage.h" - -ClassCount=12 -Class1=CSmpackageApp -Class2=CSmpackageDlg - -ResourceCount=13 -Resource1=IDR_MAINFRAME -Resource2=IDD_ENTER_STRING -Class3=CSMPackageInstallDlg -Class4=CSmpackageExportDlg -Resource3=IDD_EXPORTER -Class5=EnterName -Resource4=IDD_EDIT_METRICS -Class6=EditInsallations -Resource5=IDD_CONVERT_THEME -Class7=MainMenuDlg -Resource6=IDD_MENU -Class8=ConvertThemeDlg -Resource7=IDD_SHOW_COMMENT -Class9=EditMetricsDlg -Resource8=IDD_ENTER_COMMENT -Resource9=IDD_DIALOG_NAME -Class10=EnterComment -Resource10=IDD_INSTALL -Class11=ShowComment -Resource11=IDD_UNINSTALL_OLD_PACKAGES -Resource12=IDD_EDIT_INSTALLATIONS -Class12=ChangeGameSettings -Resource13=IDD_CHANGE_GAME_SETTINGS - -[CLS:CSmpackageApp] -Type=0 -HeaderFile=smpackage.h -ImplementationFile=smpackage.cpp -Filter=N -LastObject=CSmpackageApp -BaseClass=CWinApp -VirtualFilter=AC - -[CLS:CSmpackageDlg] -Type=0 -HeaderFile=smpackageDlg.h -ImplementationFile=smpackageDlg.cpp -Filter=D -LastObject=CSmpackageDlg -BaseClass=CDialog -VirtualFilter=dWC - - - -[DLG:IDD_INSTALL] -Type=1 -Class=CSMPackageInstallDlg -ControlCount=10 -Control1=IDC_EDIT_MESSAGE1,edit,1342179460 -Control2=IDOK,button,1342242817 -Control3=IDCANCEL,button,1342242816 -Control4=IDC_BUTTON_BACK,button,1476460544 -Control5=IDC_STATIC,static,1342177294 -Control6=IDC_EDIT_MESSAGE3,edit,1342179460 -Control7=IDC_EDIT_MESSAGE2,edit,1352665220 -Control8=IDC_COMBO_DIR,combobox,1344339971 -Control9=IDC_BUTTON_EDIT,button,1342242816 -Control10=IDC_PROGRESS1,msctls_progress32,1082130432 - -[CLS:CSMPackageInstallDlg] -Type=0 -HeaderFile=SMPackageInstallDlg.h -ImplementationFile=SMPackageInstallDlg.cpp -BaseClass=CDialog -Filter=D -LastObject=CSMPackageInstallDlg -VirtualFilter=dWC - -[DLG:IDD_EXPORTER] -Type=1 -Class=CSmpackageExportDlg -ControlCount=10 -Control1=IDOK,button,1342242817 -Control2=IDC_BUTTON_PLAY,button,1342242816 -Control3=IDC_BUTTON_EXPORT_AS_ONE,button,1342242816 -Control4=IDC_STATIC,static,1342177294 -Control5=IDC_BUTTON_EXPORT_AS_INDIVIDUAL,button,1342242816 -Control6=IDC_TREE,SysTreeView32,1350631687 -Control7=IDC_COMBO_DIR,combobox,1344339971 -Control8=IDC_BUTTON_EDIT,button,1342242816 -Control9=IDC_STATIC,static,1342308352 -Control10=IDC_BUTTON_OPEN,button,1342242816 - -[CLS:CSmpackageExportDlg] -Type=0 -HeaderFile=SmpackageExportDlg.h -ImplementationFile=SmpackageExportDlg.cpp -BaseClass=CDialog -Filter=D -LastObject=CSmpackageExportDlg -VirtualFilter=dWC - -[CLS:EnterName] -Type=0 -HeaderFile=EnterName.h -ImplementationFile=EnterName.cpp -BaseClass=CDialog -Filter=D -VirtualFilter=dWC -LastObject=IDC_EDIT - -[DLG:IDD_EDIT_INSTALLATIONS] -Type=1 -Class=EditInsallations -ControlCount=10 -Control1=IDOK,button,1342242817 -Control2=IDCANCEL,button,1342242816 -Control3=IDC_LIST,listbox,1352728833 -Control4=IDC_EDIT,edit,1350631552 -Control5=IDC_BUTTON_ADD,button,1342242816 -Control6=IDC_BUTTON_REMOVE,button,1342242816 -Control7=IDC_BUTTON_MAKE_DEFAULT,button,1342242816 -Control8=IDC_STATIC,button,1342177287 -Control9=IDC_STATIC,button,1342177287 -Control10=IDC_STATIC,static,1342308352 - -[CLS:EditInsallations] -Type=0 -HeaderFile=EditInsallations.h -ImplementationFile=EditInsallations.cpp -BaseClass=CDialog -Filter=D -VirtualFilter=dWC -LastObject=EditInsallations - -[DLG:IDD_MENU] -Type=1 -Class=MainMenuDlg -ControlCount=20 -Control1=IDOK,button,1342242817 -Control2=IDC_STATIC,static,1342177294 -Control3=IDC_STATIC,static,1342308354 -Control4=IDC_EDIT_INSTALLATION,edit,1350633600 -Control5=IDC_STATIC,button,1342177287 -Control6=IDC_EDIT_INSTALLATIONS,button,1342242816 -Control7=IDC_STATIC,static,1342308352 -Control8=IDC_STATIC,button,1342177287 -Control9=IDC_EXPORT_PACKAGES,button,1342242816 -Control10=IDC_STATIC,static,1342308352 -Control11=IDC_STATIC,button,1342177287 -Control12=IDC_ANALYZE_ELEMENTS,button,1342242816 -Control13=IDC_STATIC,static,1342308352 -Control14=IDC_STATIC,button,1342177287 -Control15=IDC_CHANGE_API,button,1342242816 -Control16=IDC_OPEN_STEPMANIA_INI,button,1342242816 -Control17=IDC_STATIC,static,1342308352 -Control18=IDC_STATIC,button,1342177287 -Control19=IDC_CREATE_SONG,button,1342242816 -Control20=IDC_STATIC,static,1342308352 - -[CLS:MainMenuDlg] -Type=0 -HeaderFile=MainMenuDlg.h -ImplementationFile=MainMenuDlg.cpp -BaseClass=CDialog -Filter=D -VirtualFilter=dWC -LastObject=MainMenuDlg - -[DLG:IDD_CONVERT_THEME] -Type=1 -Class=ConvertThemeDlg -ControlCount=13 -Control1=IDOK,button,1342242817 -Control2=IDC_STATIC,static,1342177294 -Control3=IDC_LIST_THEMES,listbox,1352728835 -Control4=IDC_BUTTON_CONVERT,button,1476460544 -Control5=IDC_STATIC,static,1342308352 -Control6=IDC_STATIC,button,1342177287 -Control7=IDC_STATIC,static,1342308352 -Control8=IDC_BUTTON_ANALYZE,button,1476460544 -Control9=IDC_STATIC,button,1342177287 -Control10=IDC_STATIC,static,1342308352 -Control11=IDC_BUTTON_EDIT_METRICS,button,1476460544 -Control12=IDC_STATIC,static,1342308352 -Control13=IDC_BUTTON_ANALYZE_METRICS,button,1476460544 - -[CLS:ConvertThemeDlg] -Type=0 -HeaderFile=onvertThemeDlg.h -ImplementationFile=onvertThemeDlg.cpp -BaseClass=CDialog -Filter=D -LastObject=IDC_LIST_THEMES -VirtualFilter=dWC - -[DLG:IDD_EDIT_METRICS] -Type=1 -Class=EditMetricsDlg -ControlCount=11 -Control1=IDC_BUTTON_CLOSE,button,1342242816 -Control2=IDC_STATIC,static,1342177294 -Control3=IDC_EDIT_VALUE,edit,1484849220 -Control4=IDC_STATIC,static,1342308352 -Control5=IDC_EDIT_DEFAULT,edit,1350633540 -Control6=IDC_STATIC,static,1342308352 -Control7=IDC_BUTTON_OVERRIDE,button,1476460544 -Control8=IDC_BUTTON_REMOVE,button,1476460544 -Control9=IDC_TREE,SysTreeView32,1350631461 -Control10=IDC_BUTTON_SAVE,button,1342242816 -Control11=IDC_BUTTON_HELP,button,1342242816 - -[CLS:EditMetricsDlg] -Type=0 -HeaderFile=EditMetricsDlg.h -ImplementationFile=EditMetricsDlg.cpp -BaseClass=CDialog -Filter=D -VirtualFilter=dWC -LastObject=EditMetricsDlg - -[DLG:IDD_ENTER_STRING] -Type=1 -Class=EnterName -ControlCount=4 -Control1=IDC_STATIC,static,1342308352 -Control2=IDC_EDIT,edit,1350631552 -Control3=IDOK,button,1342242817 -Control4=IDCANCEL,button,1342242816 - -[DLG:IDD_ENTER_COMMENT] -Type=1 -Class=EnterComment -ControlCount=5 -Control1=65535,static,1342308352 -Control2=IDC_EDIT,edit,1350631556 -Control3=IDOK,button,1342242817 -Control4=IDCANCEL,button,1342242816 -Control5=IDC_DONTASK,button,1342242819 - -[DLG:IDD_DIALOG_NAME] -Type=1 -Class=? -ControlCount=5 -Control1=IDC_STATIC,static,1342308352 -Control2=IDC_EDIT,edit,1350631552 -Control3=IDOK,button,1342242817 -Control4=IDCANCEL,button,1342242816 -Control5=IDC_STATIC,static,1342308352 - -[CLS:EnterComment] -Type=0 -HeaderFile=EnterComment.h -ImplementationFile=EnterComment.cpp -BaseClass=CDialog -Filter=D -LastObject=IDC_EDIT -VirtualFilter=dWC - -[DLG:IDD_SHOW_COMMENT] -Type=1 -Class=ShowComment -ControlCount=4 -Control1=IDC_EDIT,edit,1350633604 -Control2=IDOK,button,1342242817 -Control3=IDCANCEL,button,1342242816 -Control4=IDC_DONTSHOW,button,1342242819 - -[CLS:ShowComment] -Type=0 -HeaderFile=ShowComment.h -ImplementationFile=ShowComment.cpp -BaseClass=CDialog -Filter=D -VirtualFilter=dWC -LastObject=IDC_DONTSHOW - -[DLG:IDD_UNINSTALL_OLD_PACKAGES] -Type=1 -Class=? -ControlCount=6 -Control1=IDOK,button,1342242817 -Control2=IDCANCEL,button,1342242816 -Control3=IDC_STATIC,static,1342308352 -Control4=IDC_PACKAGES,edit,1352730756 -Control5=IDC_BUTTON1,button,1342242816 -Control6=IDC_STATIC,static,1342308353 - -[DLG:IDD_CHANGE_GAME_SETTINGS] -Type=1 -Class=ChangeGameSettings -ControlCount=15 -Control1=IDOK,button,1342242817 -Control2=IDCANCEL,button,1342242816 -Control3=IDC_STATIC,button,1342177287 -Control4=IDC_RADIO_DEFAULT,button,1342308361 -Control5=IDC_RADIO_OPENGL,button,1342177289 -Control6=IDC_RADIO_DIRECT3D,button,1342177289 -Control7=IDC_STATIC,button,1342177287 -Control8=IDC_RADIO_SOUND_DEFAULT,button,1342308361 -Control9=IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE,button,1342177289 -Control10=IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE,button,1342177289 -Control11=IDC_RADIO_SOUND_NULL,button,1342177289 -Control12=IDC_STATIC,button,1342177287 -Control13=IDC_CHECK_LOG_TO_DISK,button,1342242819 -Control14=IDC_CHECK_SHOW_LOG_WINDOW,button,1342242819 -Control15=IDC_STATIC,static,1342308352 - -[CLS:ChangeGameSettings] -Type=0 -HeaderFile=ChangeGameSettings.h -ImplementationFile=ChangeGameSettings.cpp -BaseClass=CDialog -Filter=D -LastObject=IDCANCEL -VirtualFilter=dWC - diff --git a/src/smpackagee/smpackage.cpp b/src/smpackagee/smpackage.cpp deleted file mode 100644 index 45c09f3b24..0000000000 --- a/src/smpackagee/smpackage.cpp +++ /dev/null @@ -1,197 +0,0 @@ -#define CO_EXIST_WITH_MFC -#include "global.h" -#include "stdafx.h" -#include "smpackage.h" -#include "smpackageExportDlg.h" -#include "smpackageInstallDlg.h" -#include "RageUtil.h" -#include "smpackageUtil.h" -#include "MainMenuDlg.h" -#include "RageFileManager.h" -#include "LuaManager.h" -#include "ThemeManager.h" -#include "SpecialFiles.h" -#include "IniFile.h" -#include "LocalizedString.h" -#include "arch/Dialog/Dialog.h" - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -BEGIN_MESSAGE_MAP(CSmpackageApp, CWinApp) -//{{AFX_MSG_MAP(CSmpackageApp) -//}}AFX_MSG_MAP -ON_COMMAND(ID_HELP, CWinApp::OnHelp) -END_MESSAGE_MAP() - -CSmpackageApp::CSmpackageApp() -{ - // Place all significant initialization in InitInstance -} - -CSmpackageApp theApp; -extern const char* const version_date = ""; -extern const char* const version_time = ""; - -#include "RageLog.h" -#include "RageFileManager.h" -#include "archutils/Win32/SpecialDirs.h" -#include "ProductInfo.h" -#include "archutils/Win32/CommandLine.h" -extern RString -GetLastErrorString(); - -static LocalizedString STATS_XML_NOT_YET_CREATED("CSmpackageApp", - "The file Stats.xml has not " - "yet been created. It will " - "be created once the game is " - "run."); -static LocalizedString FAILED_TO_OPEN("CSmpackageApp", - "Failed to open '%s': %s"); -static LocalizedString THE_FILE_DOES_NOT_EXIST( - "CSmpackageApp", - "The file '%s' does not exist. Aborting installation."); -BOOL -CSmpackageApp::InitInstance() -{ - char** argv; - int argc = GetWin32CmdLine(argv); - - /* Almost everything uses this to read and write files. Load this early. */ - FILEMAN = new RageFileManager(argv[0]); - FILEMAN->MountInitialFilesystems(); - - /* Set this up next. Do this early, since it's needed for - * RageException::Throw. */ - LOG = new RageLog; - - TCHAR szCurrentDirectory[MAX_PATH]; - GetCurrentDirectory(ARRAYLEN(szCurrentDirectory), szCurrentDirectory); - if (CAN_INSTALL_PACKAGES && - SMPackageUtil::IsValidInstallDir(szCurrentDirectory)) { - SMPackageUtil::AddGameInstallDir( - szCurrentDirectory); // add this if it doesn't already exist - SMPackageUtil::SetDefaultInstallDir(szCurrentDirectory); - } - - FILEMAN->Remount("/", szCurrentDirectory); - - LUA = new LuaManager; - THEME = new ThemeManager; - - // TODO: Use PrefsManager to get the current language instead? PrefsManager - // would need to be split up to reduce dependencies - RString sTheme = SpecialFiles::BASE_THEME_NAME; - - { - RString sType = "Preferences"; - GetFileContents(SpecialFiles::TYPE_TXT_FILE, sType, true); - IniFile ini; - if (ini.ReadFile(SpecialFiles::STATIC_INI_PATH)) { - while (1) { - if (ini.GetValue(sType, "Theme", sTheme)) - break; - if (ini.GetValue(sType, "Fallback", sType)) - continue; - break; - } - } - } - - RString sLanguage; - bool bPseudoLocalize = false; - bool bShowLogOutput = false; - bool bLogToDisk = false; - { - IniFile ini; - if (ini.ReadFile(SpecialFiles::PREFERENCES_INI_PATH)) { - ini.GetValue("Options", "Theme", sTheme); - ini.GetValue("Options", "Language", sLanguage); - ini.GetValue("Options", "PseudoLocalize", bPseudoLocalize); - ini.GetValue("Options", "ShowLogOutput", bShowLogOutput); - ini.GetValue("Options", "LogToDisk", bLogToDisk); - } - } - THEME->SwitchThemeAndLanguage(sTheme, sLanguage, bPseudoLocalize); - LOG->SetShowLogOutput(bShowLogOutput); - LOG->SetLogToDisk(bLogToDisk); - LOG->SetInfoToDisk(true); - - // check for --machine-profile-stats and launch Stats.xml - for (int i = 0; i < argc; i++) { - CString sArg = argv[i]; - if (sArg == "--machine-profile-stats") { - RString sOSFile = SpecialDirs::GetAppDataDir() + PRODUCT_ID + - "/Save/MachineProfile/Stats.xml"; - HINSTANCE hinst = - ::ShellExecute(NULL, "open", sOSFile, "", "", SW_SHOWNORMAL); - // See MSDN for an explanation of this return value - if ((int)hinst == SE_ERR_FNF) - Dialog::OK(STATS_XML_NOT_YET_CREATED); - else if ((int)hinst <= 32) - Dialog::OK(ssprintf(FAILED_TO_OPEN.GetValue(), - sOSFile.c_str(), - GetLastErrorString().c_str())); - exit(1); // better way to quit? - } - } - - // check if there's a .smzip command line argument and install it - for (int i = 0; i < argc; i++) { - RString sPath = argv[i]; - TrimLeft(sPath); - TrimRight(sPath); - RString sPathLower = sPath; - sPathLower.MakeLower(); - - // test to see if this is a smzip file - if (sPathLower.Right(3).CompareNoCase("zip") == 0) { - // We found a zip package. Prompt the user to install it! - CSMPackageInstallDlg dlg(sPath); - int nResponse = dlg.DoModal(); - if (nResponse == IDCANCEL) - exit(1); // better way to exit? - } - } - - { - MainMenuDlg dlg; - int nResponse = dlg.DoModal(); - } - - SAFE_DELETE(THEME); - SAFE_DELETE(LUA); - SAFE_DELETE(FILEMAN); - - // Since the dialog has been closed, return FALSE so that we exit the - // application, rather than start the application's message pump. - return FALSE; -} - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/smpackage.h b/src/smpackagee/smpackage.h deleted file mode 100644 index 0cb24de49b..0000000000 --- a/src/smpackagee/smpackage.h +++ /dev/null @@ -1,70 +0,0 @@ -// smpackage.h : main header file for the SMPACKAGE application - -#if !defined(AFX_SMPACKAGE_H__FBCA9E6C_86A9_4271_8304_83CC34A31687__INCLUDED_) -#define AFX_SMPACKAGE_H__FBCA9E6C_86A9_4271_8304_83CC34A31687__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#ifndef __AFXWIN_H__ -#error include 'stdafx.h' before including this file for PCH -#endif - -#include "resource.h" // main symbols - -///////////////////////////////////////////////////////////////////////////// -// CSmpackageApp: -// See smpackage.cpp for the implementation of this class - -class CSmpackageApp : public CWinApp -{ - public: - CSmpackageApp(); - - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CSmpackageApp) - public: - virtual BOOL InitInstance(); - //}}AFX_VIRTUAL - - // Implementation - - //{{AFX_MSG(CSmpackageApp) - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -///////////////////////////////////////////////////////////////////////////// - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before -// the previous line. - -#endif // !defined(AFX_SMPACKAGE_H__FBCA9E6C_86A9_4271_8304_83CC34A31687__INCLUDED_) - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/src/smpackagee/smpackage.rc b/src/smpackagee/smpackage.rc deleted file mode 100644 index eb7dfc6c03..0000000000 --- a/src/smpackagee/smpackage.rc +++ /dev/null @@ -1,499 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "#define _AFX_NO_SPLITTER_RESOURCES\r\n" - "#define _AFX_NO_OLE_RESOURCES\r\n" - "#define _AFX_NO_TRACKER_RESOURCES\r\n" - "#define _AFX_NO_PROPERTY_RESOURCES\r\n" - "\r\n" - "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n" - "#ifdef _WIN32\r\n" - "LANGUAGE 9, 1\r\n" - "#pragma code_page(1252)\r\n" - "#endif //_WIN32\r\n" - "#include ""res\\smpackage.rc2"" // non-Microsoft Visual C++ edited resources\r\n" - "#include ""afxres.rc"" // Standard components\r\n" - "#endif\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDR_MAINFRAME ICON "smpackage.ICO" - -///////////////////////////////////////////////////////////////////////////// -// -// Dialog -// - -IDD_INSTALL DIALOGEX 0, 0, 332, 234 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION -CAPTION "Install a package" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - EDITTEXT IDC_EDIT_MESSAGE1,7,57,320,14,ES_MULTILINE | - ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | NOT - WS_TABSTOP - DEFPUSHBUTTON "Finish >",IDOK,200,215,55,15 - PUSHBUTTON "Cancel",IDCANCEL,275,215,50,15 - PUSHBUTTON "< Back",IDC_BUTTON_BACK,145,215,55,15,WS_DISABLED - EDITTEXT IDC_EDIT_MESSAGE2,5,90,320,87,ES_MULTILINE | - ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL | NOT - WS_TABSTOP - COMBOBOX IDC_COMBO_DIR,22,195,204,105,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Edit Installations",IDC_BUTTON_EDIT,233,194,85,14 - CONTROL "",IDC_PROGRESS1,"msctls_progress32",NOT WS_VISIBLE | - WS_BORDER,7,72,318,14 - LTEXT "You have chosen to install the package:", - IDC_STATIC_MESSAGE1,7,41,318,10 - LTEXT "This package contains the following files:", - IDC_STATIC_MESSAGE2,7,76,318,10 - LTEXT "The package will be installed in the following program folder:", - IDC_STATIC,7,181,318,10 - CONTROL "",IDC_STATIC,"Static",SS_WHITERECT,0,0,331,33 - LTEXT "Install a package",IDC_STATIC_HEADER_TEXT,6,4,273,20 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,0,33,331,1 - ICON IDR_MAINFRAME,IDC_STATIC_ICON,295,6,21,20,0, - WS_EX_TRANSPARENT -END - -IDD_EXPORTER DIALOGEX 0, 0, 349, 222 -STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | - WS_VISIBLE | WS_CAPTION | WS_SYSMENU -EXSTYLE WS_EX_APPWINDOW -CAPTION "Export Packages" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Close",IDOK,284,201,57,14 - PUSHBUTTON "Launch Game",IDC_BUTTON_PLAY,7,200,70,15 - PUSHBUTTON "Export As One",IDC_BUTTON_EXPORT_AS_ONE,255,87,86,15 - PUSHBUTTON "Export As Individual",IDC_BUTTON_EXPORT_AS_INDIVIDUAL, - 255,120,86,15 - CONTROL "Tree2",IDC_TREE,"SysTreeView32",TVS_HASBUTTONS | - TVS_HASLINES | TVS_LINESATROOT | TVS_CHECKBOXES | - WS_BORDER | WS_TABSTOP,7,43,239,151 - COMBOBOX IDC_COMBO_DIR,16,17,229,105,CBS_DROPDOWNLIST | - WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Edit Installations",IDC_BUTTON_EDIT,250,16,85,14 - PUSHBUTTON "Open Program Folder",IDC_BUTTON_OPEN,88,200,93,15 - GROUPBOX "Installation",IDC_STATIC,7,7,334,29 -END - -IDD_DIALOG_NAME DIALOGEX 0, 0, 261, 58 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Name Your Package" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - LTEXT "Enter a name for your new package:",IDC_STATIC,7,7,188, - 12 - EDITTEXT IDC_EDIT,17,20,178,13,ES_AUTOHSCROLL - DEFPUSHBUTTON "OK",IDOK,200,7,54,14 - PUSHBUTTON "Cancel",IDCANCEL,200,24,54,14 - LTEXT "Note: leave off the "".smzip"" extension",IDC_STATIC,18, - 38,179,12 -END - -IDD_EDIT_INSTALLATIONS DIALOGEX 0, 0, 243, 221 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Edit Installations" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",IDOK,125,199,50,14 - PUSHBUTTON "Cancel",IDCANCEL,185,199,50,14 - LISTBOX IDC_LIST,17,30,136,80,LBS_NOINTEGRALHEIGHT | WS_VSCROLL | - WS_TABSTOP - EDITTEXT IDC_EDIT,19,167,136,13,ES_AUTOHSCROLL - PUSHBUTTON "Add",IDC_BUTTON_ADD,165,167,50,14 - PUSHBUTTON "Remove",IDC_BUTTON_REMOVE,160,54,68,15,WS_DISABLED - PUSHBUTTON "Make Default",IDC_BUTTON_MAKE_DEFAULT,160,34,68,15, - WS_DISABLED - GROUPBOX "Add New Installation",IDC_STATIC,7,130,228,59 - GROUPBOX "Current Installations",IDC_STATIC,7,7,228,114 - LTEXT "Enter the complete path to a StepMania or DWI installation\r\ne.g. ""C:\\Program Files\\StepMania""", - IDC_STATIC,18,144,196,17 - LTEXT "The top installation is the default.",IDC_STATIC,19,17, - 196,12 -END - -IDD_MENU DIALOGEX 0, 0, 332, 284 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "StepMania Tools Main Menu" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - CONTROL "",IDC_STATIC,"Static",SS_WHITERECT,0,0,331,33 - LTEXT "StepMania Tools Main Menu",IDC_STATIC_HEADER_TEXT,6,4, - 273,20 - DEFPUSHBUTTON "Exit",IDOK,275,263,50,14 - GROUPBOX "Installation",IDC_STATIC,7,41,318,28 - PUSHBUTTON "Edit Installations",IDC_EDIT_INSTALLATIONS,233,49,83,15 - GROUPBOX "Create and Share",IDC_STATIC,7,176,318,78 - PUSHBUTTON "Export Packages",IDC_EXPORT_PACKAGES,14,190,91,15 - LTEXT "Create .smzip package files to share with other users.", - IDC_STATIC,109,190,213,18 - PUSHBUTTON "Create Song",IDC_CREATE_SONG,14,211,91,15 - LTEXT "Create a new song in from your favorite mp3 or ogg music file.", - IDC_STATIC,109,211,213,20 - GROUPBOX "Troubleshooting",IDC_STATIC,7,73,318,99 - PUSHBUTTON "Change Preferences",IDC_CHANGE_PREFERENCES,14,85,91,15 - PUSHBUTTON "Open Preferences",IDC_OPEN_PREFERENCES,14,127,91,15 - LTEXT "Change the graphics API, sound API, and other settings that the game will use.", - IDC_STATIC,110,85,213,18 - PUSHBUTTON "Clear Preferences",IDC_CLEAR_PREFERENCES,14,106,91,15 - PUSHBUTTON "Clear Mappings",IDC_CLEAR_KEYMAPS,14,148,91,15 - EDITTEXT IDC_EDIT_INSTALLATION,16,51,210,12,ES_AUTOHSCROLL | - ES_READONLY - LTEXT "Erase all of your keyboard and joystick mappings if you've made a mistake.", - IDC_STATIC,109,148,213,18 - PUSHBUTTON "Launch Game",IDC_BUTTON_LAUNCH_GAME,183,263,76,14 - PUSHBUTTON "Languages",IDC_LANGUAGES,14,232,91,15 - LTEXT "Create a new or manage existing language translations.", - IDC_STATIC,109,232,213,20 - LTEXT "Open the preferences file to make changes by hand.", - IDC_STATIC,109,127,213,18 - LTEXT "Clear all preferences if you've made changes and the game won't start.", - IDC_STATIC,109,106,213,18 - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,0,33,331,1 - ICON IDR_MAINFRAME,IDC_STATIC_ICON,295,6,21,20,0, - WS_EX_TRANSPARENT -END - -IDD_ENTER_COMMENT DIALOGEX 0, 0, 324, 203 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Add A Comment" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - LTEXT "You can add a message to display before a user installs your package.", - IDC_STATIC,7,7,252,18 - CONTROL "Show a comment",IDC_SHOW_A_COMMENT,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,19,39,185,12 - EDITTEXT IDC_EDIT,17,53,232,123,ES_MULTILINE | ES_AUTOHSCROLL - CONTROL "Don't display this dialog in the future",IDC_DONTASK, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,185,145,11 - DEFPUSHBUTTON "OK",IDOK,267,7,50,14 - PUSHBUTTON "Cancel",IDCANCEL,267,24,50,14 - GROUPBOX "Package Comment",IDC_STATIC,7,29,252,152 -END - -IDD_SHOW_COMMENT DIALOGEX 0, 0, 246, 186 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Package Comment" -FONT 8, "MS Sans Serif", 0, 0, 0x1 -BEGIN - EDITTEXT IDC_EDIT,7,7,232,137,ES_MULTILINE | ES_AUTOHSCROLL | - ES_READONLY - DEFPUSHBUTTON "OK",IDOK,72,165,50,14 - PUSHBUTTON "Cancel",IDCANCEL,128,165,50,14 - CONTROL "Don't display this dialog in the future",IDC_DONTSHOW, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,149,145,11 -END - -IDD_UNINSTALL_OLD_PACKAGES DIALOGEX 0, 0, 228, 152 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | - WS_SYSMENU -CAPTION "Uninstall Old Packages" -FONT 8, "MS Shell Dlg", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "&Yes",IDOK,31,131,50,14 - PUSHBUTTON "Cancel",IDCANCEL,147,131,50,14 - LTEXT "The following packages are already installed. It is strongly recommended that they be deleted before installing this package.", - IDC_STATIC,7,7,214,27 - EDITTEXT IDC_PACKAGES,31,36,165,77,ES_MULTILINE | ES_AUTOHSCROLL | - ES_READONLY | WS_VSCROLL - PUSHBUTTON "&No",IDC_BUTTON1,87,131,49,14 - CTEXT "Delete old packages?",IDC_STATIC,31,117,166,12 -END - -IDD_CHANGE_GAME_SETTINGS DIALOGEX 0, 0, 162, 298 -STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU -CAPTION "Change Game Settings" -FONT 8, "MS Sans Serif", 0, 0, 0x0 -BEGIN - DEFPUSHBUTTON "OK",IDOK,49,276,50,14 - PUSHBUTTON "Cancel",IDCANCEL,104,276,50,14 - GROUPBOX "Graphics API",IDC_STATIC,7,7,147,66 - CONTROL "Default (recommended)",IDC_RADIO_DEFAULT,"Button", - BS_AUTORADIOBUTTON | WS_GROUP,21,22,129,12 - CONTROL "OpenGL",IDC_RADIO_OPENGL,"Button",BS_AUTORADIOBUTTON,21, - 38,129,12 - CONTROL "Direct3D",IDC_RADIO_DIRECT3D,"Button", - BS_AUTORADIOBUTTON,21,54,129,12 - GROUPBOX "Sound API",IDC_STATIC,7,77,147,100 - CONTROL "Default (recommended)",IDC_RADIO_SOUND_DEFAULT,"Button", - BS_AUTORADIOBUTTON | WS_GROUP,21,92,129,12 - CONTROL "DirectSound Hardware", - IDC_RADIO_SOUND_DIRECTSOUND_HARDWARE,"Button", - BS_AUTORADIOBUTTON,21,108,129,12 - CONTROL "DirectSound Software", - IDC_RADIO_SOUND_DIRECTSOUND_SOFTWARE,"Button", - BS_AUTORADIOBUTTON,21,124,129,12 - CONTROL "WaveOut",IDC_RADIO_SOUND_WAVEOUT,"Button", - BS_AUTORADIOBUTTON,21,140,129,12 - CONTROL "Null (no sound)",IDC_RADIO_SOUND_NULL,"Button", - BS_AUTORADIOBUTTON,21,156,129,12 - GROUPBOX "Other",IDC_STATIC,7,181,147,62 - CONTROL "Log to Disk",IDC_CHECK_LOG_TO_DISK,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,21,210,129,10 - CONTROL "Show Log Window",IDC_CHECK_SHOW_LOG_WINDOW,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,21,225,129,10 - LTEXT "Tip: Change these only if you experience problems when using the default settings.", - IDC_STATIC,7,247,147,26 - CONTROL "Force 60Hz Refresh",IDC_CHECK_FORCE_60HZ,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,21,195,129,10 -END - -IDD_LANGUAGES DIALOGEX 0, 0, 337, 189 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | - WS_SYSMENU -CAPTION "Language Translations" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "Close",IDOK,280,168,50,14 - LTEXT "Themes",IDC_STATIC,7,7,101,10 - LTEXT "Languages",IDC_STATIC,118,7,98,10 - PUSHBUTTON "Create Language",IDC_BUTTON_CREATE,230,41,91,15 - PUSHBUTTON "Delete Language",IDC_BUTTON_DELETE,230,62,91,15 - PUSHBUTTON "Export CSV",IDC_BUTTON_EXPORT,230,83,91,15 - PUSHBUTTON "Import CSV",IDC_BUTTON_IMPORT,230,123,91,15 - LTEXT "1) Create a new language\n2) Export the theme strings to a CSV\n3) Edit the CSV using Excel or a text editor\n4) Import the CSV file back into the same language", - IDC_STATIC,7,145,258,37 - LTEXT "Selection details",IDC_STATIC,230,7,100,9 - LTEXT "Total Strings:",IDC_STATIC,221,17,89,10 - LTEXT "Need translation:",IDC_STATIC,221,28,89,10 - LTEXT "",IDC_STATIC_TOTAL_STRINGS,307,18,26,10 - LTEXT "",IDC_STATIC_NEED_TRANSLATION,307,27,26,10 - LISTBOX IDC_LIST_THEMES,7,18,102,121,LBS_SORT | - LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - LISTBOX IDC_LIST_LANGUAGES,116,17,100,121,LBS_SORT | - LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP - CONTROL "Export already translated strings", - IDC_CHECK_EXPORT_ALREADY_TRANSLATED,"Button", - BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,221,100,109, - 16 - PUSHBUTTON "Check Language",IDC_CHECK_LANGUAGE,230,143,91,13 -END - -IDD_CREATE_LANGUAGE DIALOGEX 0, 0, 191, 47 -STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | - WS_SYSMENU -CAPTION "Create Language" -FONT 8, "MS Shell Dlg", 400, 0, 0x1 -BEGIN - DEFPUSHBUTTON "OK",IDOK,128,7,56,14 - PUSHBUTTON "Cancel",IDCANCEL,128,27,56,14 - LTEXT "Choose a language",IDC_STATIC,7,7,110,11 - COMBOBOX IDC_COMBO_LANGUAGES,17,24,100,110,CBS_DROPDOWNLIST | - CBS_SORT | WS_VSCROLL | WS_TABSTOP -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "FileDescription", "StepMania Tools" - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "smpackage" - VALUE "LegalCopyright", "Copyright (C) StepMania team" - VALUE "OriginalFilename", "tools.exe" - VALUE "ProductName", "StepMania Tools" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// DESIGNINFO -// - -#ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO -BEGIN - IDD_INSTALL, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 325 - TOPMARGIN, 7 - BOTTOMMARGIN, 227 - END - - IDD_EXPORTER, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 341 - TOPMARGIN, 7 - BOTTOMMARGIN, 215 - END - - IDD_DIALOG_NAME, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 254 - TOPMARGIN, 7 - BOTTOMMARGIN, 51 - END - - IDD_EDIT_INSTALLATIONS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 235 - TOPMARGIN, 7 - BOTTOMMARGIN, 213 - END - - IDD_MENU, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 325 - TOPMARGIN, 7 - BOTTOMMARGIN, 277 - END - - IDD_ENTER_COMMENT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 317 - TOPMARGIN, 7 - BOTTOMMARGIN, 196 - END - - IDD_SHOW_COMMENT, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 239 - TOPMARGIN, 7 - BOTTOMMARGIN, 179 - END - - IDD_UNINSTALL_OLD_PACKAGES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 221 - TOPMARGIN, 7 - BOTTOMMARGIN, 145 - END - - IDD_CHANGE_GAME_SETTINGS, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 154 - TOPMARGIN, 7 - BOTTOMMARGIN, 290 - END - - IDD_LANGUAGES, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 330 - TOPMARGIN, 7 - BOTTOMMARGIN, 182 - END - - IDD_CREATE_LANGUAGE, DIALOG - BEGIN - LEFTMARGIN, 7 - RIGHTMARGIN, 184 - TOPMARGIN, 7 - BOTTOMMARGIN, 40 - END -END -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// -#define _AFX_NO_SPLITTER_RESOURCES -#define _AFX_NO_OLE_RESOURCES -#define _AFX_NO_TRACKER_RESOURCES -#define _AFX_NO_PROPERTY_RESOURCES - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE 9, 1 -#pragma code_page(1252) -#endif //_WIN32 -#include "res\smpackage.rc2" // non-Microsoft Visual C++ edited resources -#include "afxres.rc" // Standard components -#endif - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/src/smpackagee/smpackageUtil.h b/src/smpackagee/smpackageUtil.h deleted file mode 100644 index 6beba92b82..0000000000 --- a/src/smpackagee/smpackageUtil.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef SMPackageUtil_H -#define SMPackageUtil_H - -struct LanguageInfo; - -namespace SMPackageUtil { -void -WriteGameInstallDirs(const vector& asInstallDirsToWrite); -void -GetGameInstallDirs(vector& asInstallDirsOut); -void -AddGameInstallDir(const RString& sNewInstallDir); -void -SetDefaultInstallDir(int iInstallDirIndex); -void -SetDefaultInstallDir(const RString& sInstallDir); -bool -IsValidInstallDir(const RString& sInstallDir); - -bool -GetPref(const RString& name, bool& val); -bool -SetPref(const RString& name, bool val); - -RString -GetPackageDirectory(const RString& path); -bool -IsValidPackageDirectory(const RString& path); - -bool -LaunchGame(); - -RString -GetLanguageDisplayString(const RString& sIsoCode); -RString -GetLanguageCodeFromDisplayString(const RString& sDisplayString); - -void -StripIgnoredSmzipFiles(vector& vsFilesInOut); - -bool -GetFileContentsOsAbsolute(const RString& sAbsoluteOsFile, RString& sOut); - -bool -DoesOsAbsoluteFileExist(const RString& sOsAbsoluteFile); -} - -#include "RageFile.h" - -class RageFileOsAbsolute : public RageFile -{ - public: - bool Open(const RString& path, int mode = READ); - ~RageFileOsAbsolute(); - - private: - RString m_sOsDir; -}; - -#endif - -/* - * (c) 2002-2005 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */