├── .gitignore ├── .gitmodules ├── COPYING ├── README.md ├── assets ├── application.ini ├── branding │ ├── content │ │ ├── icon48.png │ │ └── icon64.png │ └── locale │ │ ├── brand.dtd │ │ └── brand.properties ├── chrome.manifest ├── console │ ├── content │ │ ├── console.css │ │ ├── console.js │ │ ├── console.xul │ │ └── consoleBindings.xml │ ├── jsconsole-clhandler.js │ ├── jsconsole-clhandler.manifest │ ├── jsconsole.manifest │ ├── locale │ │ └── en-US │ │ │ ├── console.dtd │ │ │ └── console.properties │ └── skin │ │ └── osx │ │ └── console.css ├── devtools.manifest ├── icons │ └── default │ │ ├── default16.png │ │ ├── default256.png │ │ ├── default32.png │ │ ├── default48.png │ │ └── main-window.ico ├── mac │ └── chrome │ │ └── skin │ │ └── preferences │ │ └── preferences.css ├── multilocale.txt ├── prefs.js ├── unix │ └── skin │ │ └── preferences │ │ └── preferences.css ├── updater.ini └── win │ └── skin │ └── preferences │ └── preferences.css ├── build.sh ├── config.sh ├── fetch_mar_tools ├── fetch_pdftools ├── fetch_xulrunner.sh ├── linux ├── set_launcher_icon ├── updater-i686 ├── updater-x86_64 ├── zotero └── zotero.desktop ├── mac ├── Contents │ ├── Info.plist │ ├── PkgInfo │ └── Resources │ │ └── zotero.icns ├── DSStore ├── entitlements.xml ├── mozconfig ├── mozilla-52.patch ├── mozilla-54.patch ├── mozilla-60.patch ├── pkg-dmg ├── updater.tar.bz2 └── zotero ├── scripts ├── 4.0_beta_build_and_deploy ├── 4.0_release_build_and_deploy ├── 5.0_beta_build_and_deploy ├── 5.0_dev_build_and_deploy ├── 5.0_release_build_and_deploy ├── build_and_deploy ├── build_and_run ├── check_requirements ├── dir_build ├── fetch_rcedit ├── get_commit_files ├── get_repo_branch_hash ├── manage_incrementals ├── notarization_info ├── notarization_stapler ├── notarize_mac_app ├── optimizejars.py └── upload_builds ├── update-packaging ├── add_version_info ├── build_autoupdate.sh ├── common.sh ├── make_full_update.sh ├── make_incremental_update.sh ├── make_incremental_updates.py ├── removed-files_linux-i686 ├── removed-files_linux-x86_64 ├── removed-files_mac └── removed-files_win32 └── win ├── download-nsis-plugins ├── installer ├── 7zstub │ ├── firefox │ │ └── 7zSD.sfx │ └── src │ │ ├── 7zip │ │ ├── Archive │ │ │ ├── 7z │ │ │ │ ├── 7zCompressionMode.cpp │ │ │ │ ├── 7zCompressionMode.h │ │ │ │ ├── 7zDecode.cpp │ │ │ │ ├── 7zDecode.h │ │ │ │ ├── 7zExtract.cpp │ │ │ │ ├── 7zFolderOutStream.cpp │ │ │ │ ├── 7zFolderOutStream.h │ │ │ │ ├── 7zHandler.cpp │ │ │ │ ├── 7zHandler.h │ │ │ │ ├── 7zHeader.cpp │ │ │ │ ├── 7zHeader.h │ │ │ │ ├── 7zIn.cpp │ │ │ │ ├── 7zIn.h │ │ │ │ ├── 7zItem.h │ │ │ │ ├── 7zMethodID.cpp │ │ │ │ ├── 7zMethodID.h │ │ │ │ ├── 7zMethods.cpp │ │ │ │ ├── 7zMethods.h │ │ │ │ ├── 7zProperties.cpp │ │ │ │ └── 7zProperties.h │ │ │ ├── Archive.def │ │ │ ├── Common │ │ │ │ ├── CoderMixer2.cpp │ │ │ │ ├── CoderMixer2.h │ │ │ │ ├── CoderMixer2MT.cpp │ │ │ │ ├── CoderMixer2MT.h │ │ │ │ ├── CrossThreadProgress.cpp │ │ │ │ ├── CrossThreadProgress.h │ │ │ │ ├── FilterCoder.cpp │ │ │ │ ├── FilterCoder.h │ │ │ │ ├── ItemNameUtils.cpp │ │ │ │ ├── ItemNameUtils.h │ │ │ │ ├── OutStreamWithCRC.cpp │ │ │ │ └── OutStreamWithCRC.h │ │ │ └── IArchive.h │ │ ├── Bundles │ │ │ └── SFXSetup-moz │ │ │ │ ├── ExtractCallback.cpp │ │ │ │ ├── ExtractCallback.h │ │ │ │ ├── ExtractEngine.cpp │ │ │ │ ├── ExtractEngine.h │ │ │ │ ├── Main.cpp │ │ │ │ ├── SFXSetup-moz.dsp │ │ │ │ ├── SFXSetup-moz.dsw │ │ │ │ ├── StdAfx.cpp │ │ │ │ ├── StdAfx.h │ │ │ │ ├── makefile │ │ │ │ ├── resource.h │ │ │ │ ├── resource.rc │ │ │ │ └── setup.ico │ │ ├── Common │ │ │ ├── FilePathAutoRename.cpp │ │ │ ├── FilePathAutoRename.h │ │ │ ├── FileStreams.cpp │ │ │ ├── FileStreams.h │ │ │ ├── InBuffer.cpp │ │ │ ├── InBuffer.h │ │ │ ├── InOutTempBuffer.cpp │ │ │ ├── InOutTempBuffer.h │ │ │ ├── LSBFDecoder.cpp │ │ │ ├── LSBFDecoder.h │ │ │ ├── LSBFEncoder.cpp │ │ │ ├── LSBFEncoder.h │ │ │ ├── LimitedStreams.cpp │ │ │ ├── LimitedStreams.h │ │ │ ├── LockedStream.cpp │ │ │ ├── LockedStream.h │ │ │ ├── MSBFDecoder.h │ │ │ ├── MSBFEncoder.h │ │ │ ├── OffsetStream.cpp │ │ │ ├── OffsetStream.h │ │ │ ├── OutBuffer.cpp │ │ │ ├── OutBuffer.h │ │ │ ├── ProgressUtils.cpp │ │ │ ├── ProgressUtils.h │ │ │ ├── StdAfx.h │ │ │ ├── StreamBinder.cpp │ │ │ ├── StreamBinder.h │ │ │ ├── StreamObjects.cpp │ │ │ ├── StreamObjects.h │ │ │ ├── StreamUtils.cpp │ │ │ └── StreamUtils.h │ │ ├── Compress │ │ │ ├── Branch │ │ │ │ ├── BranchCoder.cpp │ │ │ │ ├── BranchCoder.h │ │ │ │ ├── BranchTypes.h │ │ │ │ ├── BranchX86.c │ │ │ │ ├── BranchX86.h │ │ │ │ ├── x86.cpp │ │ │ │ ├── x86.h │ │ │ │ ├── x86_2.cpp │ │ │ │ └── x86_2.h │ │ │ ├── Copy │ │ │ │ ├── CopyCoder.cpp │ │ │ │ └── CopyCoder.h │ │ │ ├── LZ │ │ │ │ ├── LZOutWindow.cpp │ │ │ │ └── LZOutWindow.h │ │ │ ├── LZMA │ │ │ │ ├── LZMA.h │ │ │ │ ├── LZMADecoder.cpp │ │ │ │ └── LZMADecoder.h │ │ │ └── RangeCoder │ │ │ │ ├── RangeCoder.h │ │ │ │ ├── RangeCoderBit.cpp │ │ │ │ ├── RangeCoderBit.h │ │ │ │ ├── RangeCoderBitTree.h │ │ │ │ └── RangeCoderOpt.h │ │ ├── FileManager │ │ │ ├── FormatUtils.cpp │ │ │ ├── FormatUtils.h │ │ │ └── Resource │ │ │ │ └── ProgressDialog │ │ │ │ ├── ProgressDialog.cpp │ │ │ │ ├── ProgressDialog.h │ │ │ │ ├── StdAfx.h │ │ │ │ ├── resource.h │ │ │ │ └── resource.rc │ │ ├── GuiCommon.rc │ │ ├── ICoder.h │ │ ├── IPassword.h │ │ ├── IProgress.h │ │ ├── IStream.h │ │ ├── MyVersion.h │ │ ├── MyVersionInfo.rc │ │ ├── PropID.h │ │ └── UI │ │ │ ├── Common │ │ │ ├── ArchiveOpenCallback.cpp │ │ │ ├── ArchiveOpenCallback.h │ │ │ ├── ArchiverInfo.cpp │ │ │ ├── ArchiverInfo.h │ │ │ ├── DefaultName.cpp │ │ │ ├── DefaultName.h │ │ │ ├── OpenArchive.cpp │ │ │ └── OpenArchive.h │ │ │ ├── Explorer │ │ │ ├── MyMessages.cpp │ │ │ └── MyMessages.h │ │ │ └── GUI │ │ │ ├── OpenCallbackGUI.cpp │ │ │ └── OpenCallbackGUI.h │ │ ├── Common │ │ ├── Alloc.cpp │ │ ├── Alloc.h │ │ ├── Buffer.h │ │ ├── CRC.cpp │ │ ├── CRC.h │ │ ├── ComTry.h │ │ ├── CommandLineParser.cpp │ │ ├── CommandLineParser.h │ │ ├── Defs.h │ │ ├── DynamicBuffer.h │ │ ├── IntToString.cpp │ │ ├── IntToString.h │ │ ├── MyCom.h │ │ ├── MyUnknown.h │ │ ├── MyWindows.cpp │ │ ├── MyWindows.h │ │ ├── NewHandler.cpp │ │ ├── NewHandler.h │ │ ├── Random.cpp │ │ ├── Random.h │ │ ├── StdInStream.cpp │ │ ├── StdInStream.h │ │ ├── StdOutStream.cpp │ │ ├── StdOutStream.h │ │ ├── String.cpp │ │ ├── String.h │ │ ├── StringConvert.cpp │ │ ├── StringConvert.h │ │ ├── TextConfig.cpp │ │ ├── TextConfig.h │ │ ├── Types.h │ │ ├── UTFConvert.cpp │ │ ├── UTFConvert.h │ │ ├── Vector.cpp │ │ ├── Vector.h │ │ ├── Wildcard.cpp │ │ └── Wildcard.h │ │ ├── DOC │ │ ├── 7zC.txt │ │ ├── copying.txt │ │ ├── lzma.txt │ │ └── readme.txt │ │ └── Windows │ │ ├── COM.cpp │ │ ├── COM.h │ │ ├── Control │ │ ├── Dialog.cpp │ │ ├── Dialog.h │ │ └── ProgressBar.h │ │ ├── DLL.cpp │ │ ├── DLL.h │ │ ├── Defs.h │ │ ├── Error.cpp │ │ ├── Error.h │ │ ├── FileDir.cpp │ │ ├── FileDir.h │ │ ├── FileFind.cpp │ │ ├── FileFind.h │ │ ├── FileIO.cpp │ │ ├── FileIO.h │ │ ├── FileName.cpp │ │ ├── FileName.h │ │ ├── Handle.h │ │ ├── PropVariant.cpp │ │ ├── PropVariant.h │ │ ├── PropVariantConversions.cpp │ │ ├── PropVariantConversions.h │ │ ├── ResourceString.cpp │ │ ├── ResourceString.h │ │ ├── Synchronization.cpp │ │ ├── Synchronization.h │ │ ├── Thread.h │ │ ├── Time.h │ │ ├── Window.cpp │ │ └── Window.h ├── LICENSE ├── app.tag ├── baseLocale.nlf ├── baseLocale.nsh ├── branding.nsi ├── common.nsh ├── customLocale.nsh ├── defines.nsi ├── installer.nsi ├── locales.nsi ├── overrideLocale.nsh ├── overrides.nsh ├── setup.ico ├── shared.nsh ├── uninstaller.nsi └── updater_append.ini ├── mozconfig ├── mozilla-60.patch ├── updater.exe ├── zotero_win32.exe └── zotero_win64.exe /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | cache 3 | config-custom.sh 4 | dist 5 | staging 6 | xulrunner 7 | pdftools 8 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "modules/zotero-word-for-mac-integration"] 2 | path = modules/zotero-word-for-mac-integration 3 | url = https://github.com/zotero/zotero-word-for-mac-integration.git 4 | [submodule "modules/zotero-word-for-windows-integration"] 5 | path = modules/zotero-word-for-windows-integration 6 | url = https://github.com/zotero/zotero-word-for-windows-integration.git 7 | [submodule "modules/zotero-libreoffice-integration"] 8 | path = modules/zotero-libreoffice-integration 9 | url = https://github.com/zotero/zotero-libreoffice-integration.git 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zotero Standalone build utility 2 | These files are used to bundle the [Zotero core](https://github.com/zotero/zotero) into distributable bundles for Mac, Windows, and Linux. 3 | 4 | Instructions for building and packaging are available on the [Zotero wiki](https://www.zotero.org/support/dev/client_coding/building_the_standalone_client). 5 | -------------------------------------------------------------------------------- /assets/application.ini: -------------------------------------------------------------------------------- 1 | [App] 2 | Vendor=Zotero 3 | Name=Zotero 4 | Version={{VERSION}} 5 | BuildID={{BUILDID}} 6 | Copyright=Copyright (c) 2006-2018 Contributors 7 | ID=zotero@chnm.gmu.edu 8 | 9 | [Gecko] 10 | MinVersion=60.0 11 | MaxVersion=60.* 12 | 13 | [XRE] 14 | EnableExtensionManager=1 15 | EnableProfileMigrator=1 16 | -------------------------------------------------------------------------------- /assets/branding/content/icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/assets/branding/content/icon48.png -------------------------------------------------------------------------------- /assets/branding/content/icon64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/assets/branding/content/icon64.png -------------------------------------------------------------------------------- /assets/branding/locale/brand.dtd: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /assets/branding/locale/brand.properties: -------------------------------------------------------------------------------- 1 | brandShortName=Zotero 2 | brandFullName=Zotero 3 | vendorShortName=Center for History and New Media -------------------------------------------------------------------------------- /assets/chrome.manifest: -------------------------------------------------------------------------------- 1 | locale branding en-US chrome/branding/locale/ 2 | content branding chrome/branding/content/ 3 | skin browser preferences chrome/skin/ 4 | 5 | overlay chrome://mozapps/content/extensions/extensions.xul chrome://zotero/content/standalone/extensionsOverlay.xul 6 | overlay chrome://mozapps/content/update/updates.xul chrome://zotero/content/standalone/updatesOverlay.xul 7 | style chrome://global/content/customizeToolbar.xul chrome://zotero/skin/zotero.css 8 | -------------------------------------------------------------------------------- /assets/console/content/console.css: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 | 5 | 6 | .console-box { 7 | -moz-binding: url("chrome://global/content/consoleBindings.xml#console-box"); 8 | overflow: auto; 9 | } 10 | 11 | .console-rows { 12 | -moz-user-focus: normal; 13 | } 14 | 15 | .console-row[type="error"], 16 | .console-row[type="warning"], 17 | .console-row[type="message"][typetext] { 18 | -moz-binding: url("chrome://global/content/consoleBindings.xml#error"); 19 | } 20 | 21 | .console-row[type="message"] { 22 | -moz-binding: url("chrome://global/content/consoleBindings.xml#message"); 23 | } 24 | 25 | .console-msg-text, 26 | .console-error-msg { 27 | white-space: pre-wrap; 28 | } 29 | 30 | .console-error-source { 31 | -moz-binding: url("chrome://global/content/consoleBindings.xml#console-error-source"); 32 | } 33 | 34 | .console-dots { 35 | width: 1px; 36 | } 37 | 38 | /* :::::::::: hiding and showing of rows for each mode :::::::::: */ 39 | 40 | .console-box[mode="Warnings"] > .console-box-internal > .console-rows 41 | > .console-row[type="error"], 42 | .console-box[mode="Messages"] > .console-box-internal > .console-rows 43 | > .console-row[type="error"] 44 | { 45 | display: none; 46 | } 47 | 48 | .console-box[mode="Errors"] > .console-box-internal > .console-rows 49 | > .console-row[type="warning"], 50 | .console-box[mode="Messages"] > .console-box-internal > .console-rows 51 | > .console-row[type="warning"] 52 | { 53 | display: none; 54 | } 55 | 56 | .console-box[mode="Errors"] > .console-box-internal > .console-rows 57 | > .console-row[type="message"], 58 | .console-box[mode="Warnings"] > .console-box-internal > .console-rows 59 | > .console-row[type="message"] 60 | { 61 | display: none; 62 | } 63 | 64 | .filtered-by-string { 65 | display: none; 66 | } 67 | 68 | /* If line number is 0, hide the line number section */ 69 | .lineNumberRow[line="0"] { 70 | display: none; 71 | } 72 | 73 | #TextboxEval { 74 | direction: ltr; 75 | } 76 | -------------------------------------------------------------------------------- /assets/console/jsconsole-clhandler.js: -------------------------------------------------------------------------------- 1 | /* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */ 2 | /* vim:sw=4:sr:sta:et:sts: */ 3 | 4 | /* This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 7 | 8 | const Cc = Components.classes; 9 | const Ci = Components.interfaces; 10 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); 11 | 12 | function jsConsoleHandler() {} 13 | jsConsoleHandler.prototype = { 14 | handle: function clh_handle(cmdLine) { 15 | if (!cmdLine.handleFlag("jsconsole", false)) 16 | return; 17 | 18 | var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. 19 | getService(Ci.nsIWindowMediator); 20 | var console = wm.getMostRecentWindow("global:console"); 21 | if (!console) { 22 | var wwatch = Cc["@mozilla.org/embedcomp/window-watcher;1"]. 23 | getService(Ci.nsIWindowWatcher); 24 | wwatch.openWindow(null, "chrome://global/content/console.xul", "_blank", 25 | "chrome,dialog=no,all", cmdLine); 26 | } else { 27 | console.focus(); // the Error console was already open 28 | } 29 | 30 | if (cmdLine.state == Ci.nsICommandLine.STATE_REMOTE_AUTO) 31 | cmdLine.preventDefault = true; 32 | }, 33 | 34 | helpInfo : " --jsconsole Open the Error console.\n", 35 | 36 | classID: Components.ID("{2cd0c310-e127-44d0-88fc-4435c9ab4d4b}"), 37 | QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), 38 | }; 39 | 40 | this.NSGetFactory = XPCOMUtils.generateNSGetFactory([jsConsoleHandler]); 41 | -------------------------------------------------------------------------------- /assets/console/jsconsole-clhandler.manifest: -------------------------------------------------------------------------------- 1 | component {2cd0c310-e127-44d0-88fc-4435c9ab4d4b} components/jsconsole-clhandler.js 2 | contract @mozilla.org/toolkit/console-clh;1 {2cd0c310-e127-44d0-88fc-4435c9ab4d4b} 3 | category command-line-handler t-jsconsole @mozilla.org/toolkit/console-clh;1 4 | -------------------------------------------------------------------------------- /assets/console/jsconsole.manifest: -------------------------------------------------------------------------------- 1 | override chrome://global/content/console.xul chrome/console/console.xul 2 | override chrome://global/content/consoleBindings.xml chrome/console/consoleBindings.xml 3 | override chrome://global/content/console.js chrome/console/console.js 4 | override chrome://global/content/console.css chrome/console/console.css 5 | override chrome://global/skin/console/console.css chrome/console/skin/console.css 6 | override chrome://global/locale/console.dtd chrome/console/locale/console.dtd 7 | override chrome://global/locale/console.properties chrome/console/locale/console.properties 8 | 9 | -------------------------------------------------------------------------------- /assets/console/locale/en-US/console.dtd: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | Last Sort Order"> 32 | 33 | First Sort Order"> 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /assets/console/locale/en-US/console.properties: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | typeError=Error: 6 | typeWarning=Warning: 7 | typeMessage=Message: 8 | errFile=Source File: %S 9 | errLine=Line: %S 10 | errLineCol=Line: %S, Column: %S 11 | errCode=Source Code: 12 | errTime=Timestamp: %S 13 | 14 | # LOCALIZATION NOTE (evaluationContextChanged): The message displayed when the 15 | # browser console's evaluation context (window against which input is evaluated) 16 | # changes. 17 | evaluationContextChanged=The console's evaluation context changed, probably because the target window was closed or because you opened a main window from the browser console's window. 18 | -------------------------------------------------------------------------------- /assets/devtools.manifest: -------------------------------------------------------------------------------- 1 | locale devtools en-US chrome/locale/en-US/devtools/client/ 2 | locale devtools-shared en-US chrome/locale/en-US/devtools/shared/ 3 | content devtools chrome/devtools/content/ 4 | resource devtools chrome/devtools/modules/devtools/ 5 | interfaces components/interfaces.xpt 6 | -------------------------------------------------------------------------------- /assets/icons/default/default16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/assets/icons/default/default16.png -------------------------------------------------------------------------------- /assets/icons/default/default256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/assets/icons/default/default256.png -------------------------------------------------------------------------------- /assets/icons/default/default32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/assets/icons/default/default32.png -------------------------------------------------------------------------------- /assets/icons/default/default48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/assets/icons/default/default48.png -------------------------------------------------------------------------------- /assets/icons/default/main-window.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/assets/icons/default/main-window.ico -------------------------------------------------------------------------------- /assets/multilocale.txt: -------------------------------------------------------------------------------- 1 | en-US,ar,bg-BG,br,ca-AD,cs-CZ,da-DK,de,el-GR,en-AU,en-CA,en-GB,en-NZ,es-ES,et-EE,eu-ES,fa,fi-FI,fr-FR,gl-ES,hu-HU,id-ID,is-IS,it-IT,ja-JP,km,ko-KR,lt-LT,nb-NO,nl-NL,pl-PL,pt-BR,pt-PT,ro-RO,ru-RU,sk-SK,sl-SI,sr-RS,sv-SE,th-TH,tr-TR,uk-UA,vi-VN,zh-CN,zh-TW 2 | -------------------------------------------------------------------------------- /assets/updater.ini: -------------------------------------------------------------------------------- 1 | ; This file is in the UTF-8 encoding 2 | [Strings] 3 | Title=Zotero Update 4 | Info=Zotero is installing your updates and will start in a few moments… -------------------------------------------------------------------------------- /config.sh: -------------------------------------------------------------------------------- 1 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 2 | 3 | # Version of Gecko to build with 4 | GECKO_VERSION_MAC="60.9.0esr" 5 | GECKO_VERSION_LINUX="60.9.0esr" 6 | GECKO_VERSION_WIN="60.9.0esr" 7 | 8 | # URL prefix for custom builds of Firefox components 9 | custom_components_url="https://download.zotero.org/dev/" 10 | 11 | # Paths to Gecko runtimes 12 | MAC_RUNTIME_PATH="$DIR/xulrunner/Firefox.app" 13 | WIN32_RUNTIME_PATH="$DIR/xulrunner/firefox-win32" 14 | LINUX_i686_RUNTIME_PATH="$DIR/xulrunner/firefox-i686" 15 | LINUX_x86_64_RUNTIME_PATH="$DIR/xulrunner/firefox-x86_64" 16 | 17 | PDF_TOOLS_VERSION="0.0.5" 18 | PDF_TOOLS_URL="https://zotero-download.s3.amazonaws.com/pdftools/pdftools-$PDF_TOOLS_VERSION.tar.gz" 19 | 20 | # Whether to sign builds 21 | SIGN=0 22 | 23 | # OS X Developer ID certificate information 24 | DEVELOPER_ID=F0F1FE48DB909B263AC51C8215374D87FDC12121 25 | # Keychain and keychain password, if not building via the GUI 26 | KEYCHAIN="" 27 | KEYCHAIN_PASSWORD="" 28 | NOTARIZATION_BUNDLE_ID="" 29 | NOTARIZATION_USER="" 30 | NOTARIZATION_TEAM_ID="" 31 | NOTARIZATION_PASSWORD="" 32 | 33 | # Paths for Windows installer build 34 | NSIS_DIR='C:\Program Files (x86)\NSIS\Unicode\' 35 | 36 | # Paths for Windows installer build only necessary for signed binaries 37 | SIGNTOOL='C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\signtool.exe' 38 | SIGNATURE_DESC='Zotero' 39 | SIGNATURE_URL='https://www.zotero.org/' 40 | SIGNTOOL_CERT_SUBJECT="Corporation for Digital Scholarship" 41 | SIGNTOOL_TIMESTAMP_SERVER="http://timestamp.sectigo.com" 42 | SIGNTOOL_DELAY=15 43 | 44 | # Directory for Zotero code repos 45 | repo_dir=$( cd "$DIR"/.. && pwd ) 46 | # Directory for Zotero source code 47 | ZOTERO_SOURCE_DIR="$repo_dir"/zotero-client 48 | # Directory for Zotero build files (needed for scripts/*_build_and_deploy) 49 | ZOTERO_BUILD_DIR="$repo_dir"/zotero-build 50 | # Directory for unpacked binaries 51 | STAGE_DIR="$DIR/staging" 52 | # Directory for packed binaries 53 | DIST_DIR="$DIR/dist" 54 | 55 | SOURCE_REPO_URL="https://github.com/zotero/zotero" 56 | S3_BUCKET="zotero-download" 57 | S3_CI_ZIP_PATH="ci/client" 58 | S3_DIST_PATH="client" 59 | 60 | DEPLOY_HOST="deploy.zotero" 61 | DEPLOY_PATH="www/www-production/public/download/client/manifests" 62 | DEPLOY_CMD="ssh $DEPLOY_HOST update-site-files" 63 | 64 | BUILD_PLATFORMS="" 65 | NUM_INCREMENTALS=6 66 | 67 | if [ "`uname`" = "Darwin" ]; then 68 | alias mktemp='mktemp -t tmp' 69 | shopt -s expand_aliases 70 | fi 71 | 72 | # Make utilities (mar/mbsdiff) available in the path 73 | PATH="$DIR/xulrunner/bin:$PATH" 74 | 75 | if [ -f "$DIR/config-custom.sh" ]; then 76 | . "$DIR/config-custom.sh" 77 | fi 78 | 79 | unset DIR 80 | -------------------------------------------------------------------------------- /fetch_mar_tools: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$SCRIPT_DIR" 6 | 7 | cd "$ROOT_DIR" 8 | 9 | mkdir -p "xulrunner/bin" 10 | if [ "`uname`" = "Darwin" ]; then 11 | # Mozilla has Linux executables where the Mac files should be, so supply our own Mac builds 12 | curl -o "xulrunner/bin/mar" https://zotero-download.s3.us-east-1.amazonaws.com/tools/mac/60.8.0esr/mar 13 | curl -o "xulrunner/bin/mbsdiff" https://zotero-download.s3.us-east-1.amazonaws.com/tools/mac/60.8.0esr/mbsdiff 14 | elif [ "`uname -o 2> /dev/null`" = "Cygwin" ]; then 15 | curl -o "xulrunner/bin/mar.exe" https://ftp.mozilla.org/pub/firefox/nightly/2018/03/2018-03-01-10-01-39-mozilla-central/mar-tools/win64/mar.exe 16 | curl -o "xulrunner/bin/mbsdiff.exe" https://ftp.mozilla.org/pub/firefox/nightly/2018/03/2018-03-01-10-01-39-mozilla-central/mar-tools/win64/mbsdiff.exe 17 | else 18 | curl -o "xulrunner/bin/mar" https://ftp.mozilla.org/pub/firefox/nightly/2018/03/2018-03-01-10-01-39-mozilla-central/mar-tools/linux64/mar 19 | curl -o "xulrunner/bin/mbsdiff" https://ftp.mozilla.org/pub/firefox/nightly/2018/03/2018-03-01-10-01-39-mozilla-central/mar-tools/linux64/mbsdiff 20 | fi 21 | chmod 755 xulrunner/bin/mar xulrunner/bin/mbsdiff 22 | -------------------------------------------------------------------------------- /fetch_pdftools: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | # Copyright (c) 2018 Zotero 5 | # Center for History and New Media 6 | # George Mason University, Fairfax, Virginia, USA 7 | # http://zotero.org 8 | # 9 | # This program is free software: you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation, either version 3 of the License, or 12 | # (at your option) any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 23 | 24 | cd "$SCRIPT_DIR" 25 | . config.sh 26 | 27 | rm -rf pdftools 28 | mkdir pdftools 29 | cd pdftools 30 | 31 | curl -o pdftools.tar.gz $PDF_TOOLS_URL 32 | tar -zxvf pdftools.tar.gz 33 | rm pdftools.tar.gz 34 | 35 | echo Done 36 | -------------------------------------------------------------------------------- /linux/set_launcher_icon: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # 4 | # Run this to update the launcher file with the current path to the application icon 5 | # 6 | 7 | APPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | if [ -w "$APPDIR"/zotero.desktop ]; then 9 | sed -i -e "s@^Icon=.*@Icon=$APPDIR/chrome/icons/default/default256.png@" "$APPDIR"/zotero.desktop 10 | else 11 | echo "$APPDIR"/zotero.desktop is not writable 12 | exit 1 13 | fi 14 | -------------------------------------------------------------------------------- /linux/updater-i686: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/linux/updater-i686 -------------------------------------------------------------------------------- /linux/updater-x86_64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/linux/updater-x86_64 -------------------------------------------------------------------------------- /linux/zotero: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Increase open files limit 4 | # 5 | # Mozilla file functions (OS.File.move()/copy(), NetUtil.asyncFetch/asyncCopy()) can leave file 6 | # descriptors open for a few seconds (even with an explicit inputStream.close() in the case of 7 | # the latter), so a source installation that copies ~500 translators and styles (with fds for 8 | # source and target) can exceed the default 1024 limit. 9 | # Current hard-limit on Ubuntu 16.10 is 4096 10 | ulimit -n 4096 11 | 12 | CALLDIR="$(dirname "$(readlink -f "$0")")" 13 | "$CALLDIR/zotero-bin" -app "$CALLDIR/application.ini" "$@" 14 | -------------------------------------------------------------------------------- /linux/zotero.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Zotero 3 | Exec=bash -c "$(dirname $(realpath $(echo %k | sed -e 's/^file:\\/\\///')))/zotero -url %U" 4 | Icon=zotero.ico 5 | Type=Application 6 | Terminal=false 7 | Categories=Office; 8 | MimeType=text/plain;x-scheme-handler/zotero;application/x-research-info-systems;text/x-research-info-systems;text/ris;application/x-endnote-refer;application/x-inst-for-Scientific-info;application/mods+xml;application/rdf+xml;application/x-bibtex;text/x-bibtex;application/marc;application/vnd.citationstyles.style+xml 9 | X-GNOME-SingleWindow=true 10 | -------------------------------------------------------------------------------- /mac/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPLZOTR -------------------------------------------------------------------------------- /mac/Contents/Resources/zotero.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/mac/Contents/Resources/zotero.icns -------------------------------------------------------------------------------- /mac/DSStore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/mac/DSStore -------------------------------------------------------------------------------- /mac/entitlements.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | 13 | 14 | 15 | com.apple.security.cs.allow-jit 16 | 17 | 18 | com.apple.security.cs.allow-unsigned-executable-memory 19 | 20 | 21 | com.apple.security.cs.disable-executable-page-protection 22 | 23 | 24 | com.apple.security.cs.disable-library-validation 25 | 26 | 28 | com.apple.security.cs.allow-dyld-environment-variables 29 | 30 | 34 | com.apple.security.get-task-allow 35 | 36 | 37 | 38 | com.apple.security.device.audio-input 39 | 40 | 41 | 42 | com.apple.security.device.camera 43 | 44 | 45 | 46 | com.apple.security.personal-information.location 47 | 48 | 51 | com.apple.security.automation.apple-events 52 | 53 | 54 | -------------------------------------------------------------------------------- /mac/mozconfig: -------------------------------------------------------------------------------- 1 | ac_add_options --with-macos-sdk=$HOME/tmp/MacOSX10.11.sdk 2 | 3 | export PATH="/usr/local/opt/llvm@7/bin:$PATH" 4 | export LDFLAGS="-L/usr/local/opt/llvm@7/lib" 5 | export CPPFLAGS="-I/usr/local/opt/llvm@7/include" 6 | export CXXFLAGS="$CXXFLAGS -stdlib=libc++" 7 | mk_add_options AUTOCONF=/usr/local/Cellar/autoconf@2.13/2.13/bin/autoconf213 8 | 9 | # These probably don't all affect the stub, but they can't hurt 10 | export BUILDING_RELEASE=1 11 | export MOZILLA_OFFICIAL=1 12 | export MOZ_TELEMETRY_REPORTING=0 13 | ac_add_options --enable-official-branding 14 | ac_add_options --disable-tests 15 | ac_add_options --disable-debug 16 | -------------------------------------------------------------------------------- /mac/mozilla-54.patch: -------------------------------------------------------------------------------- 1 | diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp 2 | --- a/browser/app/nsBrowserApp.cpp 3 | +++ b/browser/app/nsBrowserApp.cpp 4 | @@ -170,7 +170,13 @@ static int do_main(int argc, char* argv[ 5 | { 6 | // Allow firefox.exe to launch XULRunner apps via -app 7 | // Note that -app must be the *first* argument. 8 | - const char *appDataFile = getenv("XUL_APP_FILE"); 9 | + UniqueFreePtr iniPath = BinaryPath::GetApplicationIni(); 10 | + if (!iniPath) { 11 | + Output("Couldn't find application.ini.\n"); 12 | + return 255; 13 | + } 14 | + char *appDataFile = iniPath.get(); 15 | + 16 | if ((!appDataFile || !*appDataFile) && 17 | (argc > 1 && IsArg(argv[1], "app"))) { 18 | if (argc == 2) { 19 | diff --git a/xpcom/build/BinaryPath.h b/xpcom/build/BinaryPath.h 20 | --- a/xpcom/build/BinaryPath.h 21 | +++ b/xpcom/build/BinaryPath.h 22 | @@ -90,6 +90,46 @@ private: 23 | return rv; 24 | } 25 | 26 | + static nsresult GetApplicationIni(char aResult[MAXPATHLEN]) 27 | + { 28 | + // Works even if we're not bundled. 29 | + CFBundleRef appBundle = CFBundleGetMainBundle(); 30 | + if (!appBundle) { 31 | + return NS_ERROR_FAILURE; 32 | + } 33 | + 34 | + CFStringRef iniFilename = CFSTR("application.ini"); 35 | + CFURLRef iniURL = CFBundleCopyResourceURL(appBundle, iniFilename, NULL, NULL); 36 | + if (!iniURL) { 37 | + return NS_ERROR_FAILURE; 38 | + } 39 | + 40 | + nsresult rv; 41 | + if (CFURLGetFileSystemRepresentation(iniURL, false, (UInt8*)aResult, 42 | + MAXPATHLEN)) { 43 | + // Sanitize path in case the app was launched from Terminal via 44 | + // './firefox' for example. 45 | + size_t readPos = 0; 46 | + size_t writePos = 0; 47 | + while (aResult[readPos] != '\0') { 48 | + if (aResult[readPos] == '.' && aResult[readPos + 1] == '/') { 49 | + readPos += 2; 50 | + } else { 51 | + aResult[writePos] = aResult[readPos]; 52 | + readPos++; 53 | + writePos++; 54 | + } 55 | + } 56 | + aResult[writePos] = '\0'; 57 | + rv = NS_OK; 58 | + } else { 59 | + rv = NS_ERROR_FAILURE; 60 | + } 61 | + 62 | + CFRelease(iniURL); 63 | + return rv; 64 | + } 65 | + 66 | #elif defined(ANDROID) 67 | static nsresult Get(const char* argv0, char aResult[MAXPATHLEN]) 68 | { 69 | @@ -172,6 +212,19 @@ public: 70 | return result; 71 | } 72 | 73 | +#if defined(XP_MACOSX) 74 | + static UniqueFreePtr GetApplicationIni() 75 | + { 76 | + char path[MAXPATHLEN]; 77 | + if (NS_FAILED(GetApplicationIni(path))) { 78 | + return nullptr; 79 | + } 80 | + UniqueFreePtr result; 81 | + result.reset(strdup(path)); 82 | + return result; 83 | + } 84 | +#endif 85 | + 86 | #ifdef MOZILLA_INTERNAL_API 87 | static nsresult GetFile(const char* aArgv0, nsIFile** aResult) 88 | { 89 | -------------------------------------------------------------------------------- /mac/updater.tar.bz2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/mac/updater.tar.bz2 -------------------------------------------------------------------------------- /mac/zotero: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/mac/zotero -------------------------------------------------------------------------------- /scripts/4.0_beta_build_and_deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | PLATFORMS="ml" 9 | CHANNEL="beta" 10 | 11 | "$SCRIPT_DIR/check_requirements" 12 | "$ZOTERO_BUILD_DIR/xpi/build_xpi_4.0" 4.0 $CHANNEL 13 | "$SCRIPT_DIR/build_and_deploy" -x "$ZOTERO_BUILD_DIR/xpi/build/zotero-build.xpi" -p $PLATFORMS -c $CHANNEL 14 | -------------------------------------------------------------------------------- /scripts/4.0_release_build_and_deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | PLATFORMS="ml" 9 | CHANNEL="release" 10 | 11 | "$ZOTERO_BUILD_DIR/xpi/build_xpi_4.0" 4.0 $CHANNEL 12 | "$SCRIPT_DIR/build_and_deploy" -x "$ZOTERO_BUILD_DIR/xpi/build/zotero-build.xpi" -p $PLATFORMS -c $CHANNEL 13 | -------------------------------------------------------------------------------- /scripts/5.0_beta_build_and_deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | CHANNEL="beta" 9 | export SAFARI_APPEX="$ROOT_DIR/../safari-app-extension-builds/beta/ZoteroSafariExtension.appex" 10 | 11 | cd "$SCRIPT_DIR" 12 | ./check_requirements 13 | 14 | hash=`./get_repo_branch_hash master` 15 | source_dir=`./get_commit_files $hash` 16 | 17 | function cleanup { 18 | rm -rf $source_dir 19 | } 20 | trap cleanup EXIT 21 | 22 | "$ZOTERO_BUILD_DIR/xpi/build_xpi" -s "$source_dir" -c $CHANNEL -m $hash 23 | ./build_and_deploy -d "$ZOTERO_BUILD_DIR/xpi/build/staging" -p $BUILD_PLATFORMS -c $CHANNEL 24 | -------------------------------------------------------------------------------- /scripts/5.0_dev_build_and_deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | CHANNEL="dev" 9 | BRANCH="master" 10 | export SAFARI_APPEX="$ROOT_DIR/../safari-app-extension-builds/dev/ZoteroSafariExtension.appex" 11 | 12 | cd "$SCRIPT_DIR" 13 | ./check_requirements 14 | 15 | hash=`./get_repo_branch_hash $BRANCH` 16 | source_dir=`./get_commit_files $hash` 17 | 18 | function cleanup { 19 | rm -rf $source_dir 20 | } 21 | trap cleanup EXIT 22 | 23 | "$ZOTERO_BUILD_DIR/xpi/build_xpi" -s "$source_dir" -c $CHANNEL -m $hash 24 | ./build_and_deploy -d "$ZOTERO_BUILD_DIR/xpi/build/staging" -p $BUILD_PLATFORMS -c $CHANNEL -i 1 25 | -------------------------------------------------------------------------------- /scripts/5.0_release_build_and_deploy: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | CHANNEL="release" 9 | BRANCH="6.0" 10 | if [ "`uname`" = "Darwin" ]; then 11 | export SAFARI_APPEX="$ROOT_DIR/../safari-app-extension-builds/release/ZoteroSafariExtension.appex" 12 | fi 13 | 14 | cd "$SCRIPT_DIR" 15 | ./check_requirements 16 | 17 | hash=`./get_repo_branch_hash $BRANCH` 18 | source_dir=`./get_commit_files $hash` 19 | 20 | function cleanup { 21 | rm -rf $source_dir 22 | } 23 | trap cleanup EXIT 24 | 25 | "$ZOTERO_BUILD_DIR/xpi/build_xpi" -s "$source_dir" -c $CHANNEL -m $hash 26 | ./build_and_deploy -d "$ZOTERO_BUILD_DIR/xpi/build/staging" -p $BUILD_PLATFORMS -c $CHANNEL 27 | -------------------------------------------------------------------------------- /scripts/build_and_run: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | # Set ZOTERO_REPOS_DIR to use directory other than $HOME for zotero-client and zotero-standalone-build 4 | if [ -n "${ZOTERO_REPOS_DIR:-}" ]; then 5 | repos_dir=$ZOTERO_REPOS_DIR 6 | else 7 | repos_dir=$HOME 8 | fi 9 | 10 | for dir in zotero-client zotero-standalone-build; do 11 | if [ ! -d "$repos_dir/$dir" ]; then 12 | echo "$repos_dir/$dir not found" >&2 13 | exit 1 14 | fi 15 | done 16 | 17 | # Set ZOTERO_PROFILE environment variable to choose profile 18 | if [ -n "${ZOTERO_PROFILE:-}" ]; then 19 | profile="-p $ZOTERO_PROFILE" 20 | fi 21 | 22 | REBUILD=0 23 | SKIP_BUNDLED_FILES=0 24 | DEBUGGER=0 25 | while getopts "rbd" opt; do 26 | case $opt in 27 | r) 28 | REBUILD=1 29 | ;; 30 | 31 | b) 32 | SKIP_BUNDLED_FILES=1 33 | ;; 34 | 35 | d) 36 | DEBUGGER=1 37 | ;; 38 | 39 | \?) 40 | echo "Invalid option: -$OPTARG" >&2 41 | exit 1 42 | ;; 43 | esac 44 | done 45 | 46 | if [ $REBUILD -eq 1 ]; then 47 | PARAMS="" 48 | if [ $DEBUGGER -eq 1 ]; then 49 | PARAMS="-t" 50 | fi 51 | 52 | # Check if build watch is running 53 | # If not, run now 54 | if ! ps u | grep scripts/build.js | grep -v grep > /dev/null; then 55 | echo "Running JS build process" 56 | echo 57 | cd $repos_dir/zotero-client 58 | npm run build 59 | echo 60 | fi 61 | 62 | $repos_dir/zotero-standalone-build/scripts/dir_build $PARAMS 63 | fi 64 | 65 | PARAMS="" 66 | if [ $SKIP_BUNDLED_FILES -eq 1 ]; then 67 | PARAMS="$PARAMS -ZoteroSkipBundledFiles" 68 | fi 69 | if [ $DEBUGGER -eq 1 ]; then 70 | PARAMS="$PARAMS -debugger" 71 | fi 72 | 73 | if [ "`uname`" = "Darwin" ]; then 74 | command="Zotero.app/Contents/MacOS/zotero" 75 | # TODO: 32-bit 76 | elif [ "`uname`" = "Linux" ]; then 77 | command="Zotero_linux-x86_64/zotero" 78 | elif [ "`uname -o 2> /dev/null`" = "Cygwin" ]; then 79 | command="Zotero_win32/zotero.exe" 80 | else 81 | echo "Unknown platform" >&2 82 | exit 1 83 | fi 84 | 85 | $repos_dir/zotero-standalone-build/staging/$command $profile -ZoteroDebugText -jsconsole $PARAMS "$@" 86 | -------------------------------------------------------------------------------- /scripts/dir_build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | function usage { 9 | cat >&2 <&2 41 | exit 1 42 | ;; 43 | esac 44 | done 45 | 46 | if [[ -z $PLATFORM ]]; then 47 | if [ "`uname`" = "Darwin" ]; then 48 | PLATFORM="m" 49 | elif [ "`uname`" = "Linux" ]; then 50 | PLATFORM="l" 51 | elif [ "`uname -o 2> /dev/null`" = "Cygwin" ]; then 52 | PLATFORM="w" 53 | fi 54 | fi 55 | 56 | CHANNEL="source" 57 | 58 | VERSION=`perl -ne 'print and last if s/.*(.{3}).+/\1/;' "$ZOTERO_SOURCE_DIR/install.rdf"` 59 | if [ $VERSION = "4.0" ]; then 60 | "$ZOTERO_BUILD_DIR/xpi/build_xpi_4.0" "$ZOTERO_SOURCE_DIR" $CHANNEL 61 | "$ROOT_DIR/build.sh" -f "$ZOTERO_BUILD_DIR/xpi/build/zotero-build.xpi" -p $PLATFORM -c $CHANNEL -s 62 | else 63 | PARAMS="" 64 | if [ $DEVTOOLS -eq 1 ]; then 65 | PARAMS="-t" 66 | fi 67 | 68 | hash=`git -C "$ZOTERO_SOURCE_DIR" rev-parse --short HEAD` 69 | 70 | "$ZOTERO_BUILD_DIR/xpi/build_xpi" -s "$ZOTERO_SOURCE_DIR/build" -c $CHANNEL -m $hash 71 | "$ROOT_DIR/build.sh" -d "$ZOTERO_BUILD_DIR/xpi/build/staging" -p $PLATFORM -c $CHANNEL -s $PARAMS 72 | fi 73 | -------------------------------------------------------------------------------- /scripts/fetch_rcedit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | 7 | cd "$ROOT_DIR" 8 | 9 | if [ "`uname -o 2> /dev/null`" = "Cygwin" ]; then 10 | mkdir -p "xulrunner/bin" 11 | curl -L -o "xulrunner/bin/rcedit.exe" https://github.com/electron/rcedit/releases/download/v1.1.1/rcedit-x86.exe 12 | chmod 755 xulrunner/bin/rcedit 13 | fi 14 | -------------------------------------------------------------------------------- /scripts/get_commit_files: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | if [ -z "${1:-}" ]; then 9 | echo "Commit hash not provided" 10 | exit 1 11 | fi 12 | hash="$1" 13 | 14 | tmpdir=`mktemp -d` 15 | 16 | cd $tmpdir 17 | wget -O build.zip "https://$S3_BUCKET.s3.amazonaws.com/$S3_CI_ZIP_PATH/$hash.zip" >&2 \ 18 | || (echo "ZIP file not found for commit '$hash'" && exit 1) 19 | unzip build.zip >&2 20 | rm build.zip 21 | echo $tmpdir -------------------------------------------------------------------------------- /scripts/get_repo_branch_hash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | if [ -z "${1:-}" ]; then 9 | echo "Usage: $0 branch" 10 | exit 1 11 | fi 12 | branch=$1 13 | 14 | git ls-remote --exit-code $SOURCE_REPO_URL $branch | cut -f 1 15 | -------------------------------------------------------------------------------- /scripts/manage_incrementals: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Manage list of deployed version numbers for a channel in order to generate incremental builds 4 | # 5 | set -euo pipefail 6 | 7 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 9 | . "$ROOT_DIR/config.sh" 10 | 11 | function usage { 12 | cat >&2 <&2 73 | 74 | # Add version to file and reupload 75 | if [ "$VERSION" ]; then 76 | echo "Adding $VERSION to incrementals-$PLATFORM" 77 | echo $VERSION >> $INCR_PATH 78 | aws s3 cp $INCR_PATH $S3_URL 79 | # Show last n versions 80 | elif [ "$NUM_VERSIONS" ]; then 81 | tail -n $NUM_VERSIONS $INCR_PATH 82 | fi 83 | rm $INCR_PATH 84 | -------------------------------------------------------------------------------- /scripts/notarization_info: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | function usage { 9 | echo "Usage: $0 id" 10 | exit 1 11 | } 12 | 13 | id=${1:-} 14 | if [[ -z "$id" ]]; then 15 | usage 16 | fi 17 | 18 | xcrun notarytool log "$id" --apple-id "$NOTARIZATION_USER" --team-id "$NOTARIZATION_TEAM_ID" --password "$NOTARIZATION_PASSWORD" notary_log.json 19 | cat notary_log.json 20 | -------------------------------------------------------------------------------- /scripts/notarization_stapler: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | function usage { 9 | echo "Usage: $0 file" 10 | exit 1 11 | } 12 | 13 | file=${1:-} 14 | if [[ -z "$file" ]]; then 15 | usage 16 | fi 17 | 18 | echo "Stapling $file" 19 | xcrun stapler staple $file 20 | -------------------------------------------------------------------------------- /scripts/notarize_mac_app: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | function usage { 9 | echo "Usage: $0 file" 10 | exit 1 11 | } 12 | 13 | file=${1:-} 14 | if [[ -z "$file" ]]; then 15 | usage 16 | fi 17 | 18 | echo "Uploading ${file##*/} to Apple for notarization" >&2 19 | xcrun notarytool submit $file --apple-id "$NOTARIZATION_USER" --team-id "$NOTARIZATION_TEAM_ID" --password="$NOTARIZATION_PASSWORD" --wait 20 | -------------------------------------------------------------------------------- /scripts/upload_builds: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Upload build archives from 'dist' to S3 with the specified channel and version 4 | # 5 | set -euo pipefail 6 | 7 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 8 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 9 | . "$ROOT_DIR/config.sh" 10 | 11 | function usage { 12 | echo Usage: $0 CHANNEL VERSION >&2 13 | exit 1 14 | } 15 | 16 | CHANNEL="${1:-}" 17 | VERSION="${2:-}" 18 | 19 | if [[ -z "$CHANNEL" ]] || [[ -z "$VERSION" ]]; then 20 | usage 21 | fi 22 | 23 | url="s3://$S3_BUCKET/$S3_DIST_PATH/$CHANNEL/$VERSION/" 24 | aws s3 sync --exclude "files-*" --exclude build_id "$DIST_DIR" $url 25 | -------------------------------------------------------------------------------- /update-packaging/add_version_info: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | """ 3 | Update a builds manifest with info on a given build 4 | """ 5 | import argparse 6 | import os 7 | import sys 8 | import shutil 9 | import json 10 | import traceback 11 | 12 | DETAILS_URLS = { 13 | '4.0': 'https://www.zotero.org/support/4.0_changelog', 14 | '5.0': 'https://www.zotero.org/support/5.0_changelog', 15 | '6.0': 'https://www.zotero.org/support/6.0_changelog', 16 | } 17 | MAJOR = None 18 | 19 | parser = argparse.ArgumentParser( 20 | description='Update a builds manifest with info on a given build', 21 | formatter_class=argparse.ArgumentDefaultsHelpFormatter) 22 | 23 | parser.add_argument('-f', '--file', required=True, help="path to updates.json") 24 | parser.add_argument('-v', '--version', required=True, help='version number of build') 25 | parser.add_argument('-b', '--build_id', required=True, help="build ID ('20160801142343')") 26 | 27 | args = parser.parse_args() 28 | 29 | def main(): 30 | try: 31 | file = args.file 32 | version = args.version 33 | 34 | # Back up JSON file 35 | shutil.copy2(file, file + '.bak') 36 | 37 | # Read in existing file 38 | with open(file) as f: 39 | updates = json.loads(f.read()) 40 | 41 | updates.append({ 42 | 'version': version, 43 | 'buildID': args.build_id, 44 | 'detailsURL': DETAILS_URLS[version[0:3]], 45 | 'major': MAJOR 46 | }) 47 | 48 | # Keep last 5 entries 49 | updates = updates[-5:] 50 | 51 | # Write new file 52 | updates = json.dumps(updates, indent=2) 53 | with open(file, 'w') as f: 54 | f.write(updates + "\n") 55 | 56 | print(updates) 57 | 58 | return 0 59 | 60 | except Exception as err: 61 | sys.stderr.write("\n" + traceback.format_exc()) 62 | return 1 63 | 64 | if __name__ == '__main__': 65 | sys.exit(main()) 66 | -------------------------------------------------------------------------------- /update-packaging/removed-files_linux-i686: -------------------------------------------------------------------------------- 1 | xulrunner/* 2 | pingsender 3 | translators.zip 4 | translators.index 5 | styles.zip 6 | resource/schema/userdata.sql 7 | resource/schema/triggers.sql 8 | resource/schema/system.sql 9 | resource/schema/repotime.txt 10 | resource/schema/renamed-styles.json 11 | resource/schema/engines.json 12 | resource/schema/abbreviations.json 13 | resource/q.js 14 | resource/csl-validator.js 15 | resource/concurrent-caller.js 16 | install.rdf 17 | deleted.txt 18 | test/* 19 | run-zotero.sh 20 | -------------------------------------------------------------------------------- /update-packaging/removed-files_linux-x86_64: -------------------------------------------------------------------------------- 1 | xulrunner/* 2 | pingsender 3 | translators.zip 4 | translators.index 5 | styles.zip 6 | resource/schema/userdata.sql 7 | resource/schema/triggers.sql 8 | resource/schema/system.sql 9 | resource/schema/repotime.txt 10 | resource/schema/renamed-styles.json 11 | resource/schema/engines.json 12 | resource/schema/abbreviations.json 13 | resource/q.js 14 | resource/csl-validator.js 15 | resource/concurrent-caller.js 16 | install.rdf 17 | deleted.txt 18 | test/* 19 | run-zotero.sh 20 | -------------------------------------------------------------------------------- /update-packaging/removed-files_mac: -------------------------------------------------------------------------------- 1 | Contents/Frameworks/* 2 | Contents/MacOS/active-update.xml 3 | Contents/MacOS/components/ 4 | Contents/MacOS/chrome.manifest 5 | Contents/MacOS/crashreporter.app/* 6 | Contents/MacOS/defaults/* 7 | Contents/MacOS/dependentlibs.list 8 | Contents/MacOS/dictionaries/ 9 | Contents/MacOS/gmp-fake/* 10 | Contents/MacOS/Info.plist 11 | Contents/MacOS/js-gdb.py 12 | Contents/MacOS/libfreebl.chk 13 | Contents/MacOS/libnssdbm3.chk 14 | Contents/MacOS/libsoftokn3.chk 15 | Contents/MacOS/libmozsqlite3.dylib 16 | Contents/MacOS/libnspr4.dylib 17 | Contents/MacOS/libnssutil3.dylib 18 | Contents/MacOS/libplc4.dylib 19 | Contents/MacOS/libplds4.dylib 20 | Contents/MacOS/libsmime3.dylib 21 | Contents/MacOS/libssl3.dylib 22 | Contents/MacOS/libxpcom.dylib 23 | Contents/MacOS/LICENSE 24 | Contents/MacOS/omni.ja 25 | Contents/MacOS/pingsender 26 | Contents/MacOS/platform.ini 27 | Contents/MacOS/precomplete 28 | Contents/MacOS/README.xulrunner 29 | Contents/MacOS/res/* 30 | Contents/MacOS/Resources/* 31 | Contents/MacOS/update-settings.ini 32 | Contents/MacOS/updater.app/Contents/MacOS/updater-bin 33 | Contents/MacOS/updates.xml 34 | Contents/MacOS/updates/* 35 | Contents/MacOS/zotero-bin 36 | Contents/Resources/translators.zip 37 | Contents/Resources/translators.index 38 | Contents/Resources/styles.zip 39 | Contents/Resources/install.rdf 40 | Contents/Resources/deleted.txt 41 | Contents/Resources/extensions/pythonext@mozdev.org/* 42 | Contents/Resources/extensions/zoteroMacWordIntegration@zotero.org/components/install.py 43 | Contents/Resources/extensions/zoteroMacWordIntegration@zotero.org/components/install.pyo 44 | Contents/Resources/extensions/zoteroMacWordIntegration@zotero.org/components/zoteroIntegrationApplication.py 45 | Contents/Resources/extensions/zoteroMacWordIntegration@zotero.org/components/zoteroIntegrationApplication.pyo 46 | Contents/Resources/extensions/zoteroMacWordIntegration@zotero.org/pylib/* 47 | Contents/Resources/resource/* 48 | Contents/Resources/chrome/zotero.jar 49 | Contents/Resources/test/* 50 | -------------------------------------------------------------------------------- /update-packaging/removed-files_win32: -------------------------------------------------------------------------------- 1 | deleted.txt 2 | gkmedias.dll 3 | install.rdf 4 | mozcrt19.dll 5 | mozutils.dll 6 | msvcp80.dll 7 | msvcr80.dll 8 | translators.zip 9 | translators.index 10 | styles.zip 11 | Microsoft.VC80.CRT.manifest 12 | resource/schema/userdata.sql 13 | resource/schema/triggers.sql 14 | resource/schema/system.sql 15 | resource/schema/repotime.txt 16 | resource/schema/renamed-styles.json 17 | resource/schema/engines.json 18 | resource/schema/abbreviations.json 19 | resource/q.js 20 | resource/csl-validator.js 21 | resource/concurrent-caller.js 22 | resource/ 23 | xulrunner/* 24 | extensions/zoteroWinWordIntegration@zotero.org/components/zoteroWinWordIntegration.dll 25 | extensions/zoteroWinWordIntegration@zotero.org/components-5.0/* 26 | extensions/zoteroWinWordIntegration@zotero.org/components-6.0/* 27 | extensions/zoteroWinWordIntegration@zotero.org/components-7.0/* 28 | extensions/zoteroWinWordIntegration@zotero.org/components-8.0/* 29 | extensions/zoteroWinWordIntegration@zotero.org/components-9.0/* 30 | extensions/zoteroWinWordIntegration@zotero.org/components-10.0/* 31 | extensions/zoteroWinWordIntegration@zotero.org/components-12.0/* 32 | extensions/zoteroWinWordIntegration@zotero.org/components-13.0/* 33 | extensions/zoteroWinWordIntegration@zotero.org/components-14.0/* 34 | extensions/zoteroWinWordIntegration@zotero.org/components-17.0/* 35 | extensions/zoteroWinWordIntegration@zotero.org/components-18.0/* 36 | extensions/zoteroWinWordIntegration@zotero.org/components-20.0/* 37 | extensions/zoteroWinWordIntegration@zotero.org/components-22.0/* 38 | extensions/zoteroWinWordIntegration@zotero.org/components-23.0/* 39 | extensions/zoteroWinWordIntegration@zotero.org/components-25.0/* 40 | extensions/zoteroWinWordIntegration@zotero.org/components-26.0/* 41 | extensions/zoteroWinWordIntegration@zotero.org/components-28.0/* 42 | extensions/zoteroWinWordIntegration@zotero.org/components-30.0/* 43 | extensions/zoteroWinWordIntegration@zotero.org/components-32.0/* 44 | extensions/zoteroWinWordIntegration@zotero.org/components-33.0/* 45 | extensions/zoteroWinWordIntegration@zotero.org/components-35.0/* 46 | test/* 47 | -------------------------------------------------------------------------------- /win/download-nsis-plugins: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -euo pipefail 3 | 4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 5 | ROOT_DIR="$(dirname "$SCRIPT_DIR")" 6 | . "$ROOT_DIR/config.sh" 7 | 8 | # 9 | # Turns out we need older versions from Mozilla, not the official ZIPs 10 | # 11 | #plugins=$(cat < $plugin.dll 47 | done 48 | 49 | echo 50 | echo 51 | echo "Files downloaded to ./Plugins -- move to ${NSIS_DIR}Plugins" 52 | echo 53 | ls -la 54 | -------------------------------------------------------------------------------- /win/installer/7zstub/firefox/7zSD.sfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/installer/7zstub/firefox/7zSD.sfx -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zCompressionMode.cpp: -------------------------------------------------------------------------------- 1 | // CompressionMethod.cpp 2 | 3 | #include "StdAfx.h" 4 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zCompressionMode.h: -------------------------------------------------------------------------------- 1 | // 7zCompressionMode.h 2 | 3 | #ifndef __7Z_COMPRESSION_MODE_H 4 | #define __7Z_COMPRESSION_MODE_H 5 | 6 | #include "../../../Windows/PropVariant.h" 7 | 8 | #include "7zMethodID.h" 9 | 10 | namespace NArchive { 11 | namespace N7z { 12 | 13 | struct CProperty 14 | { 15 | PROPID PropID; 16 | NWindows::NCOM::CPropVariant Value; 17 | }; 18 | 19 | struct CMethodFull 20 | { 21 | CMethodID MethodID; 22 | UInt32 NumInStreams; 23 | UInt32 NumOutStreams; 24 | bool IsSimpleCoder() const 25 | { return (NumInStreams == 1) && (NumOutStreams == 1); } 26 | 27 | #ifdef EXCLUDE_COM 28 | #else 29 | CLSID EncoderClassID; 30 | CSysString FilePath; 31 | #endif 32 | 33 | CObjectVector CoderProperties; 34 | }; 35 | 36 | struct CBind 37 | { 38 | UInt32 InCoder; 39 | UInt32 InStream; 40 | UInt32 OutCoder; 41 | UInt32 OutStream; 42 | }; 43 | 44 | struct CCompressionMethodMode 45 | { 46 | CObjectVector Methods; 47 | CRecordVector Binds; 48 | #ifdef COMPRESS_MT 49 | UInt32 NumThreads; 50 | #endif 51 | bool PasswordIsDefined; 52 | UString Password; 53 | 54 | bool IsEmpty() const { return (Methods.IsEmpty() && !PasswordIsDefined); } 55 | CCompressionMethodMode(): PasswordIsDefined(false) 56 | #ifdef COMPRESS_MT 57 | , NumThreads(1) 58 | #endif 59 | {} 60 | }; 61 | 62 | }} 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zDecode.h: -------------------------------------------------------------------------------- 1 | // 7zDecode.h 2 | 3 | #ifndef __7Z_DECODE_H 4 | #define __7Z_DECODE_H 5 | 6 | #include "../../IStream.h" 7 | #include "../../IPassword.h" 8 | 9 | #include "../Common/CoderMixer2.h" 10 | #include "../Common/CoderMixer2MT.h" 11 | #ifdef _ST_MODE 12 | #include "../Common/CoderMixer2ST.h" 13 | #endif 14 | #ifndef EXCLUDE_COM 15 | #include "../Common/CoderLoader.h" 16 | #endif 17 | 18 | #include "7zItem.h" 19 | 20 | namespace NArchive { 21 | namespace N7z { 22 | 23 | struct CBindInfoEx: public NCoderMixer2::CBindInfo 24 | { 25 | CRecordVector CoderMethodIDs; 26 | void Clear() 27 | { 28 | CBindInfo::Clear(); 29 | CoderMethodIDs.Clear(); 30 | } 31 | }; 32 | 33 | class CDecoder 34 | { 35 | #ifndef EXCLUDE_COM 36 | CCoderLibraries _libraries; 37 | #endif 38 | 39 | bool _bindInfoExPrevIsDefinded; 40 | CBindInfoEx _bindInfoExPrev; 41 | 42 | bool _multiThread; 43 | #ifdef _ST_MODE 44 | NCoderMixer2::CCoderMixer2ST *_mixerCoderSTSpec; 45 | #endif 46 | NCoderMixer2::CCoderMixer2MT *_mixerCoderMTSpec; 47 | NCoderMixer2::CCoderMixer2 *_mixerCoderCommon; 48 | 49 | CMyComPtr _mixerCoder; 50 | CObjectVector > _decoders; 51 | // CObjectVector > _decoders2; 52 | public: 53 | CDecoder(bool multiThread); 54 | HRESULT Decode(IInStream *inStream, 55 | UInt64 startPos, 56 | const UInt64 *packSizes, 57 | const CFolder &folder, 58 | ISequentialOutStream *outStream, 59 | ICompressProgressInfo *compressProgress 60 | #ifndef _NO_CRYPTO 61 | , ICryptoGetTextPassword *getTextPasswordSpec 62 | #endif 63 | #ifdef COMPRESS_MT 64 | , bool mtMode, UInt32 numThreads 65 | #endif 66 | ); 67 | }; 68 | 69 | }} 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zFolderOutStream.h: -------------------------------------------------------------------------------- 1 | // 7zFolderOutStream.h 2 | 3 | #ifndef __7Z_FOLDEROUTSTREAM_H 4 | #define __7Z_FOLDEROUTSTREAM_H 5 | 6 | #include "7zIn.h" 7 | 8 | #include "../../IStream.h" 9 | #include "../IArchive.h" 10 | #include "../Common/OutStreamWithCRC.h" 11 | 12 | namespace NArchive { 13 | namespace N7z { 14 | 15 | class CFolderOutStream: 16 | public ISequentialOutStream, 17 | public CMyUnknownImp 18 | { 19 | public: 20 | MY_UNKNOWN_IMP 21 | 22 | CFolderOutStream(); 23 | 24 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 25 | private: 26 | 27 | COutStreamWithCRC *_outStreamWithHashSpec; 28 | CMyComPtr _outStreamWithHash; 29 | const CArchiveDatabaseEx *_archiveDatabase; 30 | const CBoolVector *_extractStatuses; 31 | UInt32 _startIndex; 32 | UInt32 _ref2Offset; 33 | int _currentIndex; 34 | // UInt64 _currentDataPos; 35 | CMyComPtr _extractCallback; 36 | bool _testMode; 37 | 38 | bool _fileIsOpen; 39 | UInt64 _filePos; 40 | 41 | HRESULT OpenFile(); 42 | HRESULT WriteEmptyFiles(); 43 | public: 44 | HRESULT Init( 45 | const CArchiveDatabaseEx *archiveDatabase, 46 | UInt32 ref2Offset, 47 | UInt32 startIndex, 48 | const CBoolVector *extractStatuses, 49 | IArchiveExtractCallback *extractCallback, 50 | bool testMode); 51 | HRESULT FlushCorrupted(Int32 resultEOperationResult); 52 | HRESULT WasWritingFinished(); 53 | }; 54 | 55 | }} 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zHeader.cpp: -------------------------------------------------------------------------------- 1 | // 7z/Header.cpp 2 | 3 | #include "StdAfx.h" 4 | #include "7zHeader.h" 5 | 6 | namespace NArchive { 7 | namespace N7z { 8 | 9 | Byte kSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C}; 10 | Byte kFinishSignature[kSignatureSize] = {'7' + 1, 'z', 0xBC, 0xAF, 0x27, 0x1C + 1}; 11 | 12 | class SignatureInitializer 13 | { 14 | public: 15 | SignatureInitializer() { kSignature[0]--; kFinishSignature[0]--;}; 16 | } g_SignatureInitializer; 17 | 18 | }} 19 | 20 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zHeader.h: -------------------------------------------------------------------------------- 1 | // 7z/7zHeader.h 2 | 3 | #ifndef __7Z_HEADER_H 4 | #define __7Z_HEADER_H 5 | 6 | #include "7zMethodID.h" 7 | 8 | namespace NArchive { 9 | namespace N7z { 10 | 11 | const int kSignatureSize = 6; 12 | extern Byte kSignature[kSignatureSize]; 13 | 14 | // #define _7Z_VOL 15 | // 7z-MultiVolume is not finished yet. 16 | // It can work already, but I still do not like some 17 | // things of that new multivolume format. 18 | // So please keep it commented. 19 | 20 | #ifdef _7Z_VOL 21 | extern Byte kFinishSignature[kSignatureSize]; 22 | #endif 23 | 24 | struct CArchiveVersion 25 | { 26 | Byte Major; 27 | Byte Minor; 28 | }; 29 | 30 | const Byte kMajorVersion = 0; 31 | 32 | struct CStartHeader 33 | { 34 | UInt64 NextHeaderOffset; 35 | UInt64 NextHeaderSize; 36 | UInt32 NextHeaderCRC; 37 | }; 38 | 39 | const UInt32 kStartHeaderSize = 20; 40 | 41 | #ifdef _7Z_VOL 42 | struct CFinishHeader: public CStartHeader 43 | { 44 | UInt64 ArchiveStartOffset; // data offset from end if that struct 45 | UInt64 AdditionalStartBlockSize; // start signature & start header size 46 | }; 47 | 48 | const UInt32 kFinishHeaderSize = kStartHeaderSize + 16; 49 | #endif 50 | 51 | namespace NID 52 | { 53 | enum EEnum 54 | { 55 | kEnd, 56 | 57 | kHeader, 58 | 59 | kArchiveProperties, 60 | 61 | kAdditionalStreamsInfo, 62 | kMainStreamsInfo, 63 | kFilesInfo, 64 | 65 | kPackInfo, 66 | kUnPackInfo, 67 | kSubStreamsInfo, 68 | 69 | kSize, 70 | kCRC, 71 | 72 | kFolder, 73 | 74 | kCodersUnPackSize, 75 | kNumUnPackStream, 76 | 77 | kEmptyStream, 78 | kEmptyFile, 79 | kAnti, 80 | 81 | kName, 82 | kCreationTime, 83 | kLastAccessTime, 84 | kLastWriteTime, 85 | kWinAttributes, 86 | kComment, 87 | 88 | kEncodedHeader, 89 | 90 | kStartPos 91 | }; 92 | } 93 | 94 | }} 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zMethodID.cpp: -------------------------------------------------------------------------------- 1 | // 7zMethodID.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "7zMethodID.h" 6 | 7 | namespace NArchive { 8 | namespace N7z { 9 | 10 | static wchar_t GetHex(Byte value) 11 | { 12 | return (value < 10) ? ('0' + value) : ('A' + (value - 10)); 13 | } 14 | 15 | static bool HexCharToInt(wchar_t value, Byte &result) 16 | { 17 | if (value >= '0' && value <= '9') 18 | result = value - '0'; 19 | else if (value >= 'a' && value <= 'f') 20 | result = 10 + value - 'a'; 21 | else if (value >= 'A' && value <= 'F') 22 | result = 10 + value - 'A'; 23 | else 24 | return false; 25 | return true; 26 | } 27 | 28 | static bool TwoHexCharsToInt(wchar_t valueHigh, wchar_t valueLow, Byte &result) 29 | { 30 | Byte resultHigh, resultLow; 31 | if (!HexCharToInt(valueHigh, resultHigh)) 32 | return false; 33 | if (!HexCharToInt(valueLow, resultLow)) 34 | return false; 35 | result = (resultHigh << 4) + resultLow; 36 | return true; 37 | } 38 | 39 | UString CMethodID::ConvertToString() const 40 | { 41 | UString result; 42 | for (int i = 0; i < IDSize; i++) 43 | { 44 | Byte b = ID[i]; 45 | result += GetHex(b >> 4); 46 | result += GetHex(b & 0xF); 47 | } 48 | return result; 49 | } 50 | 51 | bool CMethodID::ConvertFromString(const UString &srcString) 52 | { 53 | int length = srcString.Length(); 54 | if ((length & 1) != 0 || (length >> 1) > kMethodIDSize) 55 | return false; 56 | IDSize = length / 2; 57 | UInt32 i; 58 | for(i = 0; i < IDSize; i++) 59 | if (!TwoHexCharsToInt(srcString[i * 2], srcString[i * 2 + 1], ID[i])) 60 | return false; 61 | for(; i < kMethodIDSize; i++) 62 | ID[i] = 0; 63 | return true; 64 | } 65 | 66 | bool operator==(const CMethodID &a1, const CMethodID &a2) 67 | { 68 | if (a1.IDSize != a2.IDSize) 69 | return false; 70 | for (UInt32 i = 0; i < a1.IDSize; i++) 71 | if (a1.ID[i] != a2.ID[i]) 72 | return false; 73 | return true; 74 | } 75 | 76 | }} 77 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zMethodID.h: -------------------------------------------------------------------------------- 1 | // 7zMethodID.h 2 | 3 | #ifndef __7Z_METHOD_ID_H 4 | #define __7Z_METHOD_ID_H 5 | 6 | #include "../../../Common/String.h" 7 | #include "../../../Common/Types.h" 8 | 9 | namespace NArchive { 10 | namespace N7z { 11 | 12 | const int kMethodIDSize = 15; 13 | 14 | struct CMethodID 15 | { 16 | Byte ID[kMethodIDSize]; 17 | Byte IDSize; 18 | UString ConvertToString() const; 19 | bool ConvertFromString(const UString &srcString); 20 | }; 21 | 22 | bool operator==(const CMethodID &a1, const CMethodID &a2); 23 | 24 | inline bool operator!=(const CMethodID &a1, const CMethodID &a2) 25 | { return !(a1 == a2); } 26 | 27 | }} 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zMethods.h: -------------------------------------------------------------------------------- 1 | // 7zMethods.h 2 | 3 | #ifndef __7Z_METHODS_H 4 | #define __7Z_METHODS_H 5 | 6 | #include "7zMethodID.h" 7 | 8 | namespace NArchive { 9 | namespace N7z { 10 | 11 | struct CMethodInfo 12 | { 13 | UString Name; 14 | bool EncoderIsAssigned; 15 | bool DecoderIsAssigned; 16 | UInt32 NumInStreams; 17 | UInt32 NumOutStreams; 18 | CLSID Encoder; 19 | CLSID Decoder; 20 | // UString Description; 21 | CSysString FilePath; 22 | }; 23 | 24 | struct CMethodInfo2: public CMethodInfo 25 | { 26 | CMethodID MethodID; 27 | }; 28 | 29 | void LoadMethodMap(); 30 | bool GetMethodInfo(const CMethodID &methodID, CMethodInfo &methodInfo); 31 | bool GetMethodInfo(const UString &name, CMethodInfo2 &methodInfo); 32 | 33 | }} 34 | 35 | #endif 36 | 37 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/7z/7zProperties.h: -------------------------------------------------------------------------------- 1 | // 7zProperties.h 2 | 3 | #ifndef __7Z_PROPERTIES_H 4 | #define __7Z_PROPERTIES_H 5 | 6 | #include "../../PropID.h" 7 | 8 | namespace NArchive { 9 | namespace N7z { 10 | 11 | enum // PropID 12 | { 13 | kpidPackedSize0 = kpidUserDefined, 14 | kpidPackedSize1, 15 | kpidPackedSize2, 16 | kpidPackedSize3, 17 | kpidPackedSize4, 18 | }; 19 | 20 | }} 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/Archive.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | CreateObject PRIVATE 3 | GetHandlerProperty PRIVATE 4 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/Common/CrossThreadProgress.cpp: -------------------------------------------------------------------------------- 1 | // CrossThreadProgress.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "CrossThreadProgress.h" 6 | 7 | STDMETHODIMP CCrossThreadProgress::SetRatioInfo(const UInt64 *inSize, const UInt64 *outSize) 8 | { 9 | InSize = inSize; 10 | OutSize = outSize; 11 | ProgressEvent.Set(); 12 | WaitEvent.Lock(); 13 | return Result; 14 | } 15 | 16 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/Common/CrossThreadProgress.h: -------------------------------------------------------------------------------- 1 | // CrossThreadProgress.h 2 | 3 | #ifndef __CROSSTHREADPROGRESS_H 4 | #define __CROSSTHREADPROGRESS_H 5 | 6 | #include "../../ICoder.h" 7 | #include "../../../Windows/Synchronization.h" 8 | #include "../../../Common/MyCom.h" 9 | 10 | class CCrossThreadProgress: 11 | public ICompressProgressInfo, 12 | public CMyUnknownImp 13 | { 14 | public: 15 | const UInt64 *InSize; 16 | const UInt64 *OutSize; 17 | HRESULT Result; 18 | NWindows::NSynchronization::CAutoResetEvent ProgressEvent; 19 | NWindows::NSynchronization::CAutoResetEvent WaitEvent; 20 | void Init() 21 | { 22 | ProgressEvent.Reset(); 23 | WaitEvent.Reset(); 24 | } 25 | 26 | MY_UNKNOWN_IMP 27 | 28 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); 29 | }; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/Common/ItemNameUtils.cpp: -------------------------------------------------------------------------------- 1 | // Archive/Common/ItemNameUtils.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "ItemNameUtils.h" 6 | 7 | namespace NArchive { 8 | namespace NItemName { 9 | 10 | static const wchar_t kOSDirDelimiter = WCHAR_PATH_SEPARATOR; 11 | static const wchar_t kDirDelimiter = L'/'; 12 | 13 | UString MakeLegalName(const UString &name) 14 | { 15 | UString zipName = name; 16 | zipName.Replace(kOSDirDelimiter, kDirDelimiter); 17 | return zipName; 18 | } 19 | 20 | UString GetOSName(const UString &name) 21 | { 22 | UString newName = name; 23 | newName.Replace(kDirDelimiter, kOSDirDelimiter); 24 | return newName; 25 | } 26 | 27 | UString GetOSName2(const UString &name) 28 | { 29 | if (name.IsEmpty()) 30 | return UString(); 31 | UString newName = GetOSName(name); 32 | if (newName[newName.Length() - 1] == kOSDirDelimiter) 33 | newName.Delete(newName.Length() - 1); 34 | return newName; 35 | } 36 | 37 | bool HasTailSlash(const AString &name, UINT codePage) 38 | { 39 | if (name.IsEmpty()) 40 | return false; 41 | LPCSTR prev = 42 | #ifdef _WIN32 43 | CharPrevExA(codePage, name, &name[name.Length()], 0); 44 | #else 45 | (LPCSTR)(name) + (name.Length() - 1); 46 | #endif 47 | return (*prev == '/'); 48 | } 49 | 50 | #ifndef _WIN32 51 | UString WinNameToOSName(const UString &name) 52 | { 53 | UString newName = name; 54 | newName.Replace(L'\\', kOSDirDelimiter); 55 | return newName; 56 | } 57 | #endif 58 | 59 | }} 60 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/Common/ItemNameUtils.h: -------------------------------------------------------------------------------- 1 | // Archive/Common/ItemNameUtils.h 2 | 3 | #ifndef __ARCHIVE_ITEMNAMEUTILS_H 4 | #define __ARCHIVE_ITEMNAMEUTILS_H 5 | 6 | #include "../../../Common/String.h" 7 | 8 | namespace NArchive { 9 | namespace NItemName { 10 | 11 | UString MakeLegalName(const UString &name); 12 | UString GetOSName(const UString &name); 13 | UString GetOSName2(const UString &name); 14 | bool HasTailSlash(const AString &name, UINT codePage); 15 | 16 | #ifdef _WIN32 17 | inline UString WinNameToOSName(const UString &name) { return name; } 18 | #else 19 | UString WinNameToOSName(const UString &name); 20 | #endif 21 | 22 | }} 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.cpp: -------------------------------------------------------------------------------- 1 | // OutStreamWithCRC.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "OutStreamWithCRC.h" 6 | 7 | STDMETHODIMP COutStreamWithCRC::Write(const void *data, 8 | UInt32 size, UInt32 *processedSize) 9 | { 10 | UInt32 realProcessedSize; 11 | HRESULT result; 12 | if(!_stream) 13 | { 14 | realProcessedSize = size; 15 | result = S_OK; 16 | } 17 | else 18 | result = _stream->Write(data, size, &realProcessedSize); 19 | _crc.Update(data, realProcessedSize); 20 | if(processedSize != NULL) 21 | *processedSize = realProcessedSize; 22 | return result; 23 | } 24 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Archive/Common/OutStreamWithCRC.h: -------------------------------------------------------------------------------- 1 | // OutStreamWithCRC.h 2 | 3 | #ifndef __OUTSTREAMWITHCRC_H 4 | #define __OUTSTREAMWITHCRC_H 5 | 6 | #include "../../../Common/CRC.h" 7 | #include "../../../Common/MyCom.h" 8 | #include "../../IStream.h" 9 | 10 | class COutStreamWithCRC: 11 | public ISequentialOutStream, 12 | public CMyUnknownImp 13 | { 14 | public: 15 | MY_UNKNOWN_IMP 16 | 17 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 18 | private: 19 | CCRC _crc; 20 | CMyComPtr _stream; 21 | public: 22 | void Init(ISequentialOutStream *stream) 23 | { 24 | _stream = stream; 25 | _crc.Init(); 26 | } 27 | void ReleaseStream() { _stream.Release(); } 28 | UInt32 GetCRC() const { return _crc.GetDigest(); } 29 | void InitCRC() { _crc.Init(); } 30 | 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/ExtractCallback.h: -------------------------------------------------------------------------------- 1 | // ExtractCallback.h 2 | 3 | #ifndef __EXTRACTCALLBACK_H 4 | #define __EXTRACTCALLBACK_H 5 | 6 | #include "resource.h" 7 | 8 | #include "Common/String.h" 9 | #include "Windows/ResourceString.h" 10 | 11 | #include "../../Archive/IArchive.h" 12 | 13 | #include "../../Common/FileStreams.h" 14 | #include "../../ICoder.h" 15 | 16 | #ifndef _NO_PROGRESS 17 | #include "../../FileManager/Resource/ProgressDialog/ProgressDialog.h" 18 | #endif 19 | 20 | class CExtractCallbackImp: 21 | public IArchiveExtractCallback, 22 | public CMyUnknownImp 23 | { 24 | public: 25 | 26 | MY_UNKNOWN_IMP 27 | 28 | // IProgress 29 | STDMETHOD(SetTotal)(UInt64 size); 30 | STDMETHOD(SetCompleted)(const UInt64 *completeValue); 31 | 32 | // IExtractCallback 33 | STDMETHOD(GetStream)(UInt32 index, ISequentialOutStream **outStream, 34 | Int32 askExtractMode); 35 | STDMETHOD(PrepareOperation)(Int32 askExtractMode); 36 | STDMETHOD(SetOperationResult)(Int32 resultEOperationResult); 37 | 38 | private: 39 | CMyComPtr _archiveHandler; 40 | UString _directoryPath; 41 | 42 | UString _filePath; 43 | 44 | UString _diskFilePath; 45 | 46 | bool _extractMode; 47 | struct CProcessedFileInfo 48 | { 49 | FILETIME UTCLastWriteTime; 50 | bool IsDirectory; 51 | UInt32 Attributes; 52 | } _processedFileInfo; 53 | 54 | COutFileStream *_outFileStreamSpec; 55 | CMyComPtr _outFileStream; 56 | 57 | UString _itemDefaultName; 58 | FILETIME _utcLastWriteTimeDefault; 59 | UInt32 _attributesDefault; 60 | 61 | void CreateComplexDirectory(const UStringVector &dirPathParts); 62 | public: 63 | #ifndef _NO_PROGRESS 64 | CProgressDialog ProgressDialog; 65 | #endif 66 | 67 | bool _isCorrupt; 68 | UString _message; 69 | 70 | void Init(IInArchive *archiveHandler, 71 | const UString &directoryPath, 72 | const UString &itemDefaultName, 73 | const FILETIME &utcLastWriteTimeDefault, 74 | UInt32 attributesDefault); 75 | 76 | #ifndef _NO_PROGRESS 77 | HRESULT StartProgressDialog(const UString &title) 78 | { 79 | ProgressDialog.Create(title, 0); 80 | { 81 | #ifdef LANG 82 | ProgressDialog.SetText(LangLoadString(IDS_PROGRESS_EXTRACTING, 0x02000890)); 83 | #else 84 | ProgressDialog.SetText(NWindows::MyLoadStringW(IDS_PROGRESS_EXTRACTING)); 85 | #endif 86 | } 87 | 88 | ProgressDialog.Show(SW_SHOWNORMAL); 89 | return S_OK; 90 | } 91 | virtual ~CExtractCallbackImp() { ProgressDialog.Destroy(); } 92 | #endif 93 | 94 | }; 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/ExtractEngine.h: -------------------------------------------------------------------------------- 1 | // ExtractEngine.h 2 | 3 | #ifndef __EXTRACTENGINE_H 4 | #define __EXTRACTENGINE_H 5 | 6 | #include "Common/String.h" 7 | #include "../../UI/GUI/OpenCallbackGUI.h" 8 | 9 | HRESULT ExtractArchive( 10 | const UString &fileName, 11 | const UString &folderName, 12 | COpenCallbackGUI *openCallback, 13 | bool showProgress, 14 | bool &isCorrupt, 15 | UString &errorMessage); 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/SFXSetup-moz.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "SFXSetup-moz"=.\SFXSetup-moz.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // StdAfx.cpp 2 | 3 | #include "StdAfx.h" 4 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/StdAfx.h: -------------------------------------------------------------------------------- 1 | // StdAfx.h 2 | 3 | #ifndef __STDAFX_H 4 | #define __STDAFX_H 5 | 6 | #include "../../../Common/MyWindows.h" 7 | #include "../../../Common/NewHandler.h" 8 | #include 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/resource.h: -------------------------------------------------------------------------------- 1 | #define IDI_ICON3 159 2 | 3 | #define IDS_EXTRACTION_ERROR_TITLE 7 4 | #define IDS_EXTRACTION_ERROR_MESSAGE 8 5 | #define IDS_CANNOT_CREATE_FOLDER 9 6 | #define IDS_PROGRESS_EXTRACTING 69 7 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/resource.rc: -------------------------------------------------------------------------------- 1 | #include "../../MyVersionInfo.rc" 2 | #include "resource.h" 3 | 4 | MY_VERSION_INFO_APP("7z Setup SFX", "7zS.sfx") 5 | 6 | IDI_ICON3 ICON "setup.ico" 7 | 8 | STRINGTABLE 9 | BEGIN 10 | IDS_EXTRACTION_ERROR_TITLE "Extraction Failed" 11 | IDS_EXTRACTION_ERROR_MESSAGE "File is corrupt" 12 | IDS_CANNOT_CREATE_FOLDER "Cannot create folder '{0}'" 13 | IDS_PROGRESS_EXTRACTING "Extracting" 14 | END 15 | 16 | #include "../../FileManager/Resource/ProgressDialog/resource.rc" 17 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/installer/7zstub/src/7zip/Bundles/SFXSetup-moz/setup.ico -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/FilePathAutoRename.cpp: -------------------------------------------------------------------------------- 1 | // FilePathAutoRename.cpp 2 | 3 | #include "StdAfx.h" 4 | #include "FilePathAutoRename.h" 5 | 6 | #include "Common/Defs.h" 7 | #include "Common/IntToString.h" 8 | 9 | #include "Windows/FileName.h" 10 | #include "Windows/FileFind.h" 11 | 12 | using namespace NWindows; 13 | 14 | static bool MakeAutoName(const UString &name, 15 | const UString &extension, int value, UString &path) 16 | { 17 | wchar_t number[32]; 18 | ConvertUInt64ToString(value, number); 19 | path = name; 20 | path += number; 21 | path += extension; 22 | return NFile::NFind::DoesFileExist(path); 23 | } 24 | 25 | bool AutoRenamePath(UString &fullProcessedPath) 26 | { 27 | UString path; 28 | int dotPos = fullProcessedPath.ReverseFind(L'.'); 29 | 30 | int slashPos = fullProcessedPath.ReverseFind(L'/'); 31 | #ifdef _WIN32 32 | int slash1Pos = fullProcessedPath.ReverseFind(L'\\'); 33 | slashPos = MyMax(slashPos, slash1Pos); 34 | #endif 35 | 36 | UString name, extension; 37 | if (dotPos > slashPos && dotPos > 0) 38 | { 39 | name = fullProcessedPath.Left(dotPos); 40 | extension = fullProcessedPath.Mid(dotPos); 41 | } 42 | else 43 | name = fullProcessedPath; 44 | name += L'_'; 45 | int indexLeft = 1, indexRight = (1 << 30); 46 | while (indexLeft != indexRight) 47 | { 48 | int indexMid = (indexLeft + indexRight) / 2; 49 | if (MakeAutoName(name, extension, indexMid, path)) 50 | indexLeft = indexMid + 1; 51 | else 52 | indexRight = indexMid; 53 | } 54 | if (MakeAutoName(name, extension, indexRight, fullProcessedPath)) 55 | return false; 56 | return true; 57 | } 58 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/FilePathAutoRename.h: -------------------------------------------------------------------------------- 1 | // Util/FilePathAutoRename.h 2 | 3 | #ifndef __FILEPATHAUTORENAME_H 4 | #define __FILEPATHAUTORENAME_H 5 | 6 | #include "Common/String.h" 7 | 8 | bool AutoRenamePath(UString &fullProcessedPath); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/FileStreams.h: -------------------------------------------------------------------------------- 1 | // FileStreams.h 2 | 3 | #ifndef __FILESTREAMS_H 4 | #define __FILESTREAMS_H 5 | 6 | #ifdef _WIN32 7 | #include "../../Windows/FileIO.h" 8 | #else 9 | #include "../../Common/C_FileIO.h" 10 | #endif 11 | 12 | #include "../IStream.h" 13 | #include "../../Common/MyCom.h" 14 | 15 | class CInFileStream: 16 | public IInStream, 17 | public IStreamGetSize, 18 | public CMyUnknownImp 19 | { 20 | public: 21 | #ifdef _WIN32 22 | NWindows::NFile::NIO::CInFile File; 23 | #else 24 | NC::NFile::NIO::CInFile File; 25 | #endif 26 | CInFileStream() {} 27 | virtual ~CInFileStream() {} 28 | 29 | bool Open(LPCTSTR fileName); 30 | #ifdef _WIN32 31 | #ifndef _UNICODE 32 | bool Open(LPCWSTR fileName); 33 | #endif 34 | #endif 35 | 36 | MY_UNKNOWN_IMP2(IInStream, IStreamGetSize) 37 | 38 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 39 | STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); 40 | 41 | STDMETHOD(GetSize)(UInt64 *size); 42 | }; 43 | 44 | #ifndef _WIN32_WCE 45 | class CStdInFileStream: 46 | public ISequentialInStream, 47 | public CMyUnknownImp 48 | { 49 | public: 50 | // HANDLE File; 51 | // CStdInFileStream() File(INVALID_HANDLE_VALUE): {} 52 | // void Open() { File = GetStdHandle(STD_INPUT_HANDLE); }; 53 | MY_UNKNOWN_IMP 54 | 55 | virtual ~CStdInFileStream() {} 56 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 57 | }; 58 | #endif 59 | 60 | class COutFileStream: 61 | public IOutStream, 62 | public CMyUnknownImp 63 | { 64 | public: 65 | #ifdef _WIN32 66 | NWindows::NFile::NIO::COutFile File; 67 | #else 68 | NC::NFile::NIO::COutFile File; 69 | #endif 70 | virtual ~COutFileStream() {} 71 | bool Create(LPCTSTR fileName, bool createAlways); 72 | #ifdef _WIN32 73 | #ifndef _UNICODE 74 | bool Create(LPCWSTR fileName, bool createAlways); 75 | #endif 76 | #endif 77 | 78 | MY_UNKNOWN_IMP1(IOutStream) 79 | 80 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 81 | STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); 82 | STDMETHOD(SetSize)(Int64 newSize); 83 | }; 84 | 85 | #ifndef _WIN32_WCE 86 | class CStdOutFileStream: 87 | public ISequentialOutStream, 88 | public CMyUnknownImp 89 | { 90 | public: 91 | MY_UNKNOWN_IMP 92 | 93 | virtual ~CStdOutFileStream() {} 94 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 95 | }; 96 | #endif 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/InBuffer.cpp: -------------------------------------------------------------------------------- 1 | // InBuffer.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "InBuffer.h" 6 | 7 | #include "../../Common/Alloc.h" 8 | 9 | CInBuffer::CInBuffer(): 10 | _buffer(0), 11 | _bufferLimit(0), 12 | _bufferBase(0), 13 | _stream(0), 14 | _bufferSize(0) 15 | {} 16 | 17 | bool CInBuffer::Create(UInt32 bufferSize) 18 | { 19 | const UInt32 kMinBlockSize = 1; 20 | if (bufferSize < kMinBlockSize) 21 | bufferSize = kMinBlockSize; 22 | if (_bufferBase != 0 && _bufferSize == bufferSize) 23 | return true; 24 | Free(); 25 | _bufferSize = bufferSize; 26 | _bufferBase = (Byte *)::MidAlloc(bufferSize); 27 | return (_bufferBase != 0); 28 | } 29 | 30 | void CInBuffer::Free() 31 | { 32 | ::MidFree(_bufferBase); 33 | _bufferBase = 0; 34 | } 35 | 36 | void CInBuffer::SetStream(ISequentialInStream *stream) 37 | { 38 | _stream = stream; 39 | } 40 | 41 | void CInBuffer::Init() 42 | { 43 | _processedSize = 0; 44 | _buffer = _bufferBase; 45 | _bufferLimit = _buffer; 46 | _wasFinished = false; 47 | #ifdef _NO_EXCEPTIONS 48 | ErrorCode = S_OK; 49 | #endif 50 | } 51 | 52 | bool CInBuffer::ReadBlock() 53 | { 54 | #ifdef _NO_EXCEPTIONS 55 | if (ErrorCode != S_OK) 56 | return false; 57 | #endif 58 | if (_wasFinished) 59 | return false; 60 | _processedSize += (_buffer - _bufferBase); 61 | UInt32 numProcessedBytes; 62 | HRESULT result = _stream->Read(_bufferBase, _bufferSize, &numProcessedBytes); 63 | #ifdef _NO_EXCEPTIONS 64 | ErrorCode = result; 65 | #else 66 | if (result != S_OK) 67 | throw CInBufferException(result); 68 | #endif 69 | _buffer = _bufferBase; 70 | _bufferLimit = _buffer + numProcessedBytes; 71 | _wasFinished = (numProcessedBytes == 0); 72 | return (!_wasFinished); 73 | } 74 | 75 | Byte CInBuffer::ReadBlock2() 76 | { 77 | if(!ReadBlock()) 78 | return 0xFF; 79 | return *_buffer++; 80 | } 81 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/InBuffer.h: -------------------------------------------------------------------------------- 1 | // InBuffer.h 2 | 3 | #ifndef __INBUFFER_H 4 | #define __INBUFFER_H 5 | 6 | #include "../IStream.h" 7 | #include "../../Common/MyCom.h" 8 | 9 | #ifndef _NO_EXCEPTIONS 10 | class CInBufferException 11 | { 12 | public: 13 | HRESULT ErrorCode; 14 | CInBufferException(HRESULT errorCode): ErrorCode(errorCode) {} 15 | }; 16 | #endif 17 | 18 | class CInBuffer 19 | { 20 | Byte *_buffer; 21 | Byte *_bufferLimit; 22 | Byte *_bufferBase; 23 | CMyComPtr _stream; 24 | UInt64 _processedSize; 25 | UInt32 _bufferSize; 26 | bool _wasFinished; 27 | 28 | bool ReadBlock(); 29 | Byte ReadBlock2(); 30 | 31 | public: 32 | #ifdef _NO_EXCEPTIONS 33 | HRESULT ErrorCode; 34 | #endif 35 | 36 | CInBuffer(); 37 | ~CInBuffer() { Free(); } 38 | 39 | bool Create(UInt32 bufferSize); 40 | void Free(); 41 | 42 | void SetStream(ISequentialInStream *stream); 43 | void Init(); 44 | void ReleaseStream() { _stream.Release(); } 45 | 46 | bool ReadByte(Byte &b) 47 | { 48 | if(_buffer >= _bufferLimit) 49 | if(!ReadBlock()) 50 | return false; 51 | b = *_buffer++; 52 | return true; 53 | } 54 | Byte ReadByte() 55 | { 56 | if(_buffer >= _bufferLimit) 57 | return ReadBlock2(); 58 | return *_buffer++; 59 | } 60 | void ReadBytes(void *data, UInt32 size, UInt32 &processedSize) 61 | { 62 | for(processedSize = 0; processedSize < size; processedSize++) 63 | if (!ReadByte(((Byte *)data)[processedSize])) 64 | return; 65 | } 66 | bool ReadBytes(void *data, UInt32 size) 67 | { 68 | UInt32 processedSize; 69 | ReadBytes(data, size, processedSize); 70 | return (processedSize == size); 71 | } 72 | UInt64 GetProcessedSize() const { return _processedSize + (_buffer - _bufferBase); } 73 | bool WasFinished() const { return _wasFinished; } 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/InOutTempBuffer.h: -------------------------------------------------------------------------------- 1 | // Util/InOutTempBuffer.h 2 | 3 | #ifndef __IN_OUT_TEMP_BUFFER_H 4 | #define __IN_OUT_TEMP_BUFFER_H 5 | 6 | #include "../../Windows/FileIO.h" 7 | #include "../../Windows/FileDir.h" 8 | #include "../../Common/MyCom.h" 9 | 10 | #include "../IStream.h" 11 | 12 | class CInOutTempBuffer 13 | { 14 | NWindows::NFile::NDirectory::CTempFile _tempFile; 15 | NWindows::NFile::NIO::COutFile _outFile; 16 | NWindows::NFile::NIO::CInFile _inFile; 17 | Byte *_buffer; 18 | UInt32 _bufferPosition; 19 | UInt32 _currentPositionInBuffer; 20 | CSysString _tmpFileName; 21 | bool _tmpFileCreated; 22 | 23 | UInt64 _fileSize; 24 | 25 | bool WriteToFile(const void *data, UInt32 size); 26 | public: 27 | CInOutTempBuffer(); 28 | ~CInOutTempBuffer(); 29 | void Create(); 30 | 31 | void InitWriting(); 32 | bool Write(const void *data, UInt32 size); 33 | UInt64 GetDataSize() const { return _fileSize; } 34 | bool FlushWrite(); 35 | bool InitReading(); 36 | HRESULT WriteToStream(ISequentialOutStream *stream); 37 | }; 38 | 39 | class CSequentialOutTempBufferImp: 40 | public ISequentialOutStream, 41 | public CMyUnknownImp 42 | { 43 | CInOutTempBuffer *_buffer; 44 | public: 45 | // CSequentialOutStreamImp(): _size(0) {} 46 | // UInt32 _size; 47 | void Init(CInOutTempBuffer *buffer) { _buffer = buffer; } 48 | // UInt32 GetSize() const { return _size; } 49 | 50 | MY_UNKNOWN_IMP 51 | 52 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/LSBFDecoder.cpp: -------------------------------------------------------------------------------- 1 | // Stream/LSBFDecoder.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "LSBFDecoder.h" 6 | 7 | namespace NStream { 8 | namespace NLSBF { 9 | 10 | Byte kInvertTable[256]; 11 | 12 | class CInverterTableInitializer 13 | { 14 | public: 15 | CInverterTableInitializer() 16 | { 17 | for(int i = 0; i < 256; i++) 18 | { 19 | Byte b = Byte(i); 20 | Byte bInvert = 0; 21 | for(int j = 0; j < 8; j++) 22 | { 23 | bInvert <<= 1; 24 | if (b & 1) 25 | bInvert |= 1; 26 | b >>= 1; 27 | } 28 | kInvertTable[i] = bInvert; 29 | } 30 | } 31 | } g_InverterTableInitializer; 32 | 33 | 34 | }} 35 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/LSBFEncoder.cpp: -------------------------------------------------------------------------------- 1 | // LSBFEncoder.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "LSBFEncoder.h" 6 | #include "Common/Defs.h" 7 | 8 | namespace NStream { 9 | namespace NLSBF { 10 | 11 | void CEncoder::WriteBits(UInt32 value, int numBits) 12 | { 13 | while(numBits > 0) 14 | { 15 | if (numBits < m_BitPos) 16 | { 17 | m_CurByte |= (value & ((1 << numBits) - 1)) << (8 - m_BitPos); 18 | m_BitPos -= numBits; 19 | return; 20 | } 21 | numBits -= m_BitPos; 22 | m_Stream.WriteByte((Byte)(m_CurByte | (value << (8 - m_BitPos)))); 23 | value >>= m_BitPos; 24 | m_BitPos = 8; 25 | m_CurByte = 0; 26 | } 27 | } 28 | 29 | }} 30 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/LSBFEncoder.h: -------------------------------------------------------------------------------- 1 | // Stream/LSBFEncoder.h 2 | 3 | #ifndef __STREAM_LSBFENCODER_H 4 | #define __STREAM_LSBFENCODER_H 5 | 6 | #include "../IStream.h" 7 | #include "OutBuffer.h" 8 | 9 | namespace NStream { 10 | namespace NLSBF { 11 | 12 | class CEncoder 13 | { 14 | COutBuffer m_Stream; 15 | int m_BitPos; 16 | Byte m_CurByte; 17 | public: 18 | bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); } 19 | void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream); } 20 | void ReleaseStream() { m_Stream.ReleaseStream(); } 21 | void Init() 22 | { 23 | m_Stream.Init(); 24 | m_BitPos = 8; 25 | m_CurByte = 0; 26 | } 27 | HRESULT Flush() 28 | { 29 | FlushByte(); 30 | return m_Stream.Flush(); 31 | } 32 | 33 | void FlushByte() 34 | { 35 | if(m_BitPos < 8) 36 | m_Stream.WriteByte(m_CurByte); 37 | m_BitPos = 8; 38 | m_CurByte = 0; 39 | } 40 | 41 | void WriteBits(UInt32 value, int numBits); 42 | UInt32 GetBitPosition() const { return (8 - m_BitPos); } 43 | UInt64 GetProcessedSize() const { 44 | return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) /8; } 45 | void WriteByte(Byte b) { m_Stream.WriteByte(b);} 46 | }; 47 | 48 | 49 | }} 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/LimitedStreams.cpp: -------------------------------------------------------------------------------- 1 | // LimitedStreams.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "LimitedStreams.h" 6 | #include "../../Common/Defs.h" 7 | 8 | void CLimitedSequentialInStream::Init(ISequentialInStream *stream, UInt64 streamSize) 9 | { 10 | _stream = stream; 11 | _size = streamSize; 12 | } 13 | 14 | STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize) 15 | { 16 | UInt32 processedSizeReal; 17 | UInt32 sizeToRead = UInt32(MyMin(_size, UInt64(size))); 18 | HRESULT result = _stream->Read(data, sizeToRead, &processedSizeReal); 19 | _size -= processedSizeReal; 20 | if(processedSize != NULL) 21 | *processedSize = processedSizeReal; 22 | return result; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/LimitedStreams.h: -------------------------------------------------------------------------------- 1 | // LimitedStreams.h 2 | 3 | #ifndef __LIMITEDSTREAMS_H 4 | #define __LIMITEDSTREAMS_H 5 | 6 | #include "../../Common/MyCom.h" 7 | #include "../IStream.h" 8 | 9 | class CLimitedSequentialInStream: 10 | public ISequentialInStream, 11 | public CMyUnknownImp 12 | { 13 | UInt64 _size; 14 | CMyComPtr _stream; 15 | public: 16 | void Init(ISequentialInStream *stream, UInt64 streamSize); 17 | 18 | MY_UNKNOWN_IMP 19 | 20 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 21 | }; 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/LockedStream.cpp: -------------------------------------------------------------------------------- 1 | // LockedStream.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "LockedStream.h" 6 | 7 | HRESULT CLockedInStream::Read(UInt64 startPos, void *data, UInt32 size, 8 | UInt32 *processedSize) 9 | { 10 | NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection); 11 | RINOK(_stream->Seek(startPos, STREAM_SEEK_SET, NULL)); 12 | return _stream->Read(data, size, processedSize); 13 | } 14 | 15 | STDMETHODIMP CLockedSequentialInStreamImp::Read(void *data, UInt32 size, UInt32 *processedSize) 16 | { 17 | UInt32 realProcessedSize = 0; 18 | HRESULT result = _lockedInStream->Read(_pos, data, size, &realProcessedSize); 19 | _pos += realProcessedSize; 20 | if (processedSize != NULL) 21 | *processedSize = realProcessedSize; 22 | return result; 23 | } 24 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/LockedStream.h: -------------------------------------------------------------------------------- 1 | // LockedStream.h 2 | 3 | #ifndef __LOCKEDSTREAM_H 4 | #define __LOCKEDSTREAM_H 5 | 6 | #include "../../Windows/Synchronization.h" 7 | #include "../../Common/MyCom.h" 8 | #include "../IStream.h" 9 | 10 | class CLockedInStream 11 | { 12 | CMyComPtr _stream; 13 | NWindows::NSynchronization::CCriticalSection _criticalSection; 14 | public: 15 | void Init(IInStream *stream) 16 | { _stream = stream; } 17 | HRESULT Read(UInt64 startPos, void *data, UInt32 size, UInt32 *processedSize); 18 | }; 19 | 20 | class CLockedSequentialInStreamImp: 21 | public ISequentialInStream, 22 | public CMyUnknownImp 23 | { 24 | CLockedInStream *_lockedInStream; 25 | UInt64 _pos; 26 | public: 27 | void Init(CLockedInStream *lockedInStream, UInt64 startPos) 28 | { 29 | _lockedInStream = lockedInStream; 30 | _pos = startPos; 31 | } 32 | 33 | MY_UNKNOWN_IMP 34 | 35 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize); 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/MSBFDecoder.h: -------------------------------------------------------------------------------- 1 | // MSBFDecoder.h 2 | // the Most Significant Bit of byte is First 3 | 4 | #ifndef __STREAM_MSBFDECODER_H 5 | #define __STREAM_MSBFDECODER_H 6 | 7 | #include "../../Common/Types.h" 8 | #include "../IStream.h" 9 | 10 | namespace NStream { 11 | namespace NMSBF { 12 | 13 | const int kNumBigValueBits = 8 * 4; 14 | const int kNumValueBytes = 3; 15 | const int kNumValueBits = 8 * kNumValueBytes; 16 | 17 | const UInt32 kMask = (1 << kNumValueBits) - 1; 18 | 19 | template 20 | class CDecoder 21 | { 22 | UInt32 m_BitPos; 23 | UInt32 m_Value; 24 | public: 25 | TInByte m_Stream; 26 | bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); } 27 | void SetStream(ISequentialInStream *inStream) { m_Stream.SetStream(inStream);} 28 | void ReleaseStream() { m_Stream.ReleaseStream();} 29 | 30 | void Init() 31 | { 32 | m_Stream.Init(); 33 | m_BitPos = kNumBigValueBits; 34 | Normalize(); 35 | } 36 | 37 | UInt64 GetProcessedSize() const 38 | { return m_Stream.GetProcessedSize() - (kNumBigValueBits - m_BitPos) / 8; } 39 | UInt32 GetBitPosition() const { return (m_BitPos & 7); } 40 | 41 | void Normalize() 42 | { 43 | for (;m_BitPos >= 8; m_BitPos -= 8) 44 | m_Value = (m_Value << 8) | m_Stream.ReadByte(); 45 | } 46 | 47 | UInt32 GetValue(UInt32 numBits) const 48 | { 49 | // return (m_Value << m_BitPos) >> (kNumBigValueBits - numBits); 50 | return ((m_Value >> (8 - m_BitPos)) & kMask) >> (kNumValueBits - numBits); 51 | } 52 | 53 | void MovePos(UInt32 numBits) 54 | { 55 | m_BitPos += numBits; 56 | Normalize(); 57 | } 58 | 59 | UInt32 ReadBits(UInt32 numBits) 60 | { 61 | UInt32 res = GetValue(numBits); 62 | MovePos(numBits); 63 | return res; 64 | } 65 | }; 66 | 67 | }} 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/MSBFEncoder.h: -------------------------------------------------------------------------------- 1 | // Stream/MSBFEncoder.h 2 | 3 | #ifndef __STREAM_MSBFENCODER_H 4 | #define __STREAM_MSBFENCODER_H 5 | 6 | #include "Common/Defs.h" 7 | #include "../IStream.h" 8 | #include "OutBuffer.h" 9 | 10 | namespace NStream { 11 | namespace NMSBF { 12 | 13 | template 14 | class CEncoder 15 | { 16 | TOutByte m_Stream; 17 | int m_BitPos; 18 | Byte m_CurByte; 19 | public: 20 | bool Create(UInt32 bufferSize) { return m_Stream.Create(bufferSize); } 21 | void SetStream(ISequentialOutStream *outStream) { m_Stream.SetStream(outStream);} 22 | void ReleaseStream() { m_Stream.ReleaseStream(); } 23 | void Init() 24 | { 25 | m_Stream.Init(); 26 | m_BitPos = 8; 27 | m_CurByte = 0; 28 | } 29 | HRESULT Flush() 30 | { 31 | if(m_BitPos < 8) 32 | WriteBits(0, m_BitPos); 33 | return m_Stream.Flush(); 34 | } 35 | 36 | void WriteBits(UInt32 value, int numBits) 37 | { 38 | while(numBits > 0) 39 | { 40 | if (numBits < m_BitPos) 41 | { 42 | m_CurByte |= ((Byte)value << (m_BitPos -= numBits)); 43 | return; 44 | } 45 | numBits -= m_BitPos; 46 | UInt32 newBits = (value >> numBits); 47 | value -= (newBits << numBits); 48 | m_Stream.WriteByte(m_CurByte | (Byte)newBits); 49 | m_BitPos = 8; 50 | m_CurByte = 0; 51 | } 52 | } 53 | UInt64 GetProcessedSize() const { 54 | return m_Stream.GetProcessedSize() + (8 - m_BitPos + 7) / 8; } 55 | }; 56 | 57 | }} 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/OffsetStream.cpp: -------------------------------------------------------------------------------- 1 | // OffsetStream.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "Common/Defs.h" 6 | #include "OffsetStream.h" 7 | 8 | HRESULT COffsetOutStream::Init(IOutStream *stream, UInt64 offset) 9 | { 10 | _offset = offset; 11 | _stream = stream; 12 | return _stream->Seek(offset, STREAM_SEEK_SET, NULL); 13 | } 14 | 15 | STDMETHODIMP COffsetOutStream::Write(const void *data, UInt32 size, UInt32 *processedSize) 16 | { 17 | return _stream->Write(data, size, processedSize); 18 | } 19 | 20 | STDMETHODIMP COffsetOutStream::Seek(Int64 offset, UInt32 seekOrigin, 21 | UInt64 *newPosition) 22 | { 23 | UInt64 absoluteNewPosition; 24 | if (seekOrigin == STREAM_SEEK_SET) 25 | offset += _offset; 26 | HRESULT result = _stream->Seek(offset, seekOrigin, &absoluteNewPosition); 27 | if (newPosition != NULL) 28 | *newPosition = absoluteNewPosition - _offset; 29 | return result; 30 | } 31 | 32 | STDMETHODIMP COffsetOutStream::SetSize(Int64 newSize) 33 | { 34 | return _stream->SetSize(_offset + newSize); 35 | } 36 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/OffsetStream.h: -------------------------------------------------------------------------------- 1 | // OffsetStream.h 2 | 3 | #ifndef __OFFSETSTREAM_H 4 | #define __OFFSETSTREAM_H 5 | 6 | #include "Common/MyCom.h" 7 | #include "../IStream.h" 8 | 9 | class COffsetOutStream: 10 | public IOutStream, 11 | public CMyUnknownImp 12 | { 13 | UInt64 _offset; 14 | CMyComPtr _stream; 15 | public: 16 | HRESULT Init(IOutStream *stream, UInt64 offset); 17 | 18 | MY_UNKNOWN_IMP 19 | 20 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize); 21 | STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition); 22 | STDMETHOD(SetSize)(Int64 newSize); 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/OutBuffer.cpp: -------------------------------------------------------------------------------- 1 | // OutByte.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "OutBuffer.h" 6 | 7 | #include "../../Common/Alloc.h" 8 | 9 | bool COutBuffer::Create(UInt32 bufferSize) 10 | { 11 | const UInt32 kMinBlockSize = 1; 12 | if (bufferSize < kMinBlockSize) 13 | bufferSize = kMinBlockSize; 14 | if (_buffer != 0 && _bufferSize == bufferSize) 15 | return true; 16 | Free(); 17 | _bufferSize = bufferSize; 18 | _buffer = (Byte *)::MidAlloc(bufferSize); 19 | return (_buffer != 0); 20 | } 21 | 22 | void COutBuffer::Free() 23 | { 24 | ::MidFree(_buffer); 25 | _buffer = 0; 26 | } 27 | 28 | void COutBuffer::SetStream(ISequentialOutStream *stream) 29 | { 30 | _stream = stream; 31 | } 32 | 33 | void COutBuffer::Init() 34 | { 35 | _streamPos = 0; 36 | _limitPos = _bufferSize; 37 | _pos = 0; 38 | _processedSize = 0; 39 | _overDict = false; 40 | #ifdef _NO_EXCEPTIONS 41 | ErrorCode = S_OK; 42 | #endif 43 | } 44 | 45 | UInt64 COutBuffer::GetProcessedSize() const 46 | { 47 | UInt64 res = _processedSize + _pos - _streamPos; 48 | if (_streamPos > _pos) 49 | res += _bufferSize; 50 | return res; 51 | } 52 | 53 | 54 | HRESULT COutBuffer::FlushPart() 55 | { 56 | // _streamPos < _bufferSize 57 | UInt32 size = (_streamPos >= _pos) ? (_bufferSize - _streamPos) : (_pos - _streamPos); 58 | HRESULT result = S_OK; 59 | #ifdef _NO_EXCEPTIONS 60 | result = ErrorCode; 61 | #endif 62 | if (_buffer2 != 0) 63 | { 64 | memmove(_buffer2, _buffer + _streamPos, size); 65 | _buffer2 += size; 66 | } 67 | 68 | if (_stream != 0 69 | #ifdef _NO_EXCEPTIONS 70 | && (ErrorCode == S_OK) 71 | #endif 72 | ) 73 | { 74 | UInt32 processedSize = 0; 75 | result = _stream->Write(_buffer + _streamPos, size, &processedSize); 76 | size = processedSize; 77 | } 78 | _streamPos += size; 79 | if (_streamPos == _bufferSize) 80 | _streamPos = 0; 81 | if (_pos == _bufferSize) 82 | { 83 | _overDict = true; 84 | _pos = 0; 85 | } 86 | _limitPos = (_streamPos > _pos) ? _streamPos : _bufferSize; 87 | _processedSize += size; 88 | return result; 89 | } 90 | 91 | HRESULT COutBuffer::Flush() 92 | { 93 | #ifdef _NO_EXCEPTIONS 94 | if (ErrorCode != S_OK) 95 | return ErrorCode; 96 | #endif 97 | 98 | while(_streamPos != _pos) 99 | { 100 | HRESULT result = FlushPart(); 101 | if (result != S_OK) 102 | return result; 103 | } 104 | return S_OK; 105 | } 106 | 107 | void COutBuffer::FlushWithCheck() 108 | { 109 | HRESULT result = FlushPart(); 110 | #ifdef _NO_EXCEPTIONS 111 | ErrorCode = result; 112 | #else 113 | if (result != S_OK) 114 | throw COutBufferException(result); 115 | #endif 116 | } 117 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/OutBuffer.h: -------------------------------------------------------------------------------- 1 | // OutBuffer.h 2 | 3 | #ifndef __OUTBUFFER_H 4 | #define __OUTBUFFER_H 5 | 6 | #include "../IStream.h" 7 | #include "../../Common/MyCom.h" 8 | 9 | #ifndef _NO_EXCEPTIONS 10 | struct COutBufferException 11 | { 12 | HRESULT ErrorCode; 13 | COutBufferException(HRESULT errorCode): ErrorCode(errorCode) {} 14 | }; 15 | #endif 16 | 17 | class COutBuffer 18 | { 19 | protected: 20 | Byte *_buffer; 21 | UInt32 _pos; 22 | UInt32 _limitPos; 23 | UInt32 _streamPos; 24 | UInt32 _bufferSize; 25 | CMyComPtr _stream; 26 | UInt64 _processedSize; 27 | Byte *_buffer2; 28 | bool _overDict; 29 | 30 | HRESULT FlushPart(); 31 | void FlushWithCheck(); 32 | public: 33 | #ifdef _NO_EXCEPTIONS 34 | HRESULT ErrorCode; 35 | #endif 36 | 37 | COutBuffer(): _buffer(0), _pos(0), _stream(0), _buffer2(0) {} 38 | ~COutBuffer() { Free(); } 39 | 40 | bool Create(UInt32 bufferSize); 41 | void Free(); 42 | 43 | void SetMemStream(Byte *buffer) { _buffer2 = buffer; } 44 | void SetStream(ISequentialOutStream *stream); 45 | void Init(); 46 | HRESULT Flush(); 47 | void ReleaseStream() { _stream.Release(); } 48 | 49 | void WriteByte(Byte b) 50 | { 51 | _buffer[_pos++] = b; 52 | if(_pos == _limitPos) 53 | FlushWithCheck(); 54 | } 55 | void WriteBytes(const void *data, size_t size) 56 | { 57 | for (size_t i = 0; i < size; i++) 58 | WriteByte(((const Byte *)data)[i]); 59 | } 60 | 61 | UInt64 GetProcessedSize() const; 62 | }; 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/ProgressUtils.cpp: -------------------------------------------------------------------------------- 1 | // ProgressUtils.h 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "ProgressUtils.h" 6 | 7 | void CLocalCompressProgressInfo::Init(ICompressProgressInfo *progress, 8 | const UInt64 *inStartValue, const UInt64 *outStartValue) 9 | { 10 | _progress = progress; 11 | _inStartValueIsAssigned = (inStartValue != NULL); 12 | if (_inStartValueIsAssigned) 13 | _inStartValue = *inStartValue; 14 | _outStartValueIsAssigned = (outStartValue != NULL); 15 | if (_outStartValueIsAssigned) 16 | _outStartValue = *outStartValue; 17 | } 18 | 19 | STDMETHODIMP CLocalCompressProgressInfo::SetRatioInfo( 20 | const UInt64 *inSize, const UInt64 *outSize) 21 | { 22 | UInt64 inSizeNew, outSizeNew; 23 | const UInt64 *inSizeNewPointer; 24 | const UInt64 *outSizeNewPointer; 25 | if (_inStartValueIsAssigned && inSize != NULL) 26 | { 27 | inSizeNew = _inStartValue + (*inSize); 28 | inSizeNewPointer = &inSizeNew; 29 | } 30 | else 31 | inSizeNewPointer = NULL; 32 | 33 | if (_outStartValueIsAssigned && outSize != NULL) 34 | { 35 | outSizeNew = _outStartValue + (*outSize); 36 | outSizeNewPointer = &outSizeNew; 37 | } 38 | else 39 | outSizeNewPointer = NULL; 40 | return _progress->SetRatioInfo(inSizeNewPointer, outSizeNewPointer); 41 | } 42 | 43 | 44 | /////////////////////////////////// 45 | // 46 | 47 | void CLocalProgress::Init(IProgress *progress, bool inSizeIsMain) 48 | { 49 | _progress = progress; 50 | _inSizeIsMain = inSizeIsMain; 51 | } 52 | 53 | STDMETHODIMP CLocalProgress::SetRatioInfo( 54 | const UInt64 *inSize, const UInt64 *outSize) 55 | { 56 | return _progress->SetCompleted(_inSizeIsMain ? inSize : outSize); 57 | } 58 | 59 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/ProgressUtils.h: -------------------------------------------------------------------------------- 1 | // ProgressUtils.h 2 | 3 | #ifndef __PROGRESSUTILS_H 4 | #define __PROGRESSUTILS_H 5 | 6 | #include "../../Common/MyCom.h" 7 | 8 | #include "../ICoder.h" 9 | #include "../IProgress.h" 10 | 11 | class CLocalCompressProgressInfo: 12 | public ICompressProgressInfo, 13 | public CMyUnknownImp 14 | { 15 | CMyComPtr _progress; 16 | bool _inStartValueIsAssigned; 17 | bool _outStartValueIsAssigned; 18 | UInt64 _inStartValue; 19 | UInt64 _outStartValue; 20 | public: 21 | void Init(ICompressProgressInfo *progress, 22 | const UInt64 *inStartValue, const UInt64 *outStartValue); 23 | 24 | MY_UNKNOWN_IMP 25 | 26 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); 27 | }; 28 | 29 | class CLocalProgress: 30 | public ICompressProgressInfo, 31 | public CMyUnknownImp 32 | { 33 | CMyComPtr _progress; 34 | bool _inSizeIsMain; 35 | public: 36 | void Init(IProgress *progress, bool inSizeIsMain); 37 | 38 | MY_UNKNOWN_IMP 39 | 40 | STDMETHOD(SetRatioInfo)(const UInt64 *inSize, const UInt64 *outSize); 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/StdAfx.h: -------------------------------------------------------------------------------- 1 | // StdAfx.h 2 | 3 | #ifndef __STDAFX_H 4 | #define __STDAFX_H 5 | 6 | #include "../../Common/MyWindows.h" 7 | #include "../../Common/NewHandler.h" 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/StreamBinder.h: -------------------------------------------------------------------------------- 1 | // StreamBinder.h 2 | 3 | #ifndef __STREAMBINDER_H 4 | #define __STREAMBINDER_H 5 | 6 | #include "../IStream.h" 7 | #include "../../Windows/Synchronization.h" 8 | 9 | class CStreamBinder 10 | { 11 | NWindows::NSynchronization::CManualResetEvent *_allBytesAreWritenEvent; 12 | NWindows::NSynchronization::CManualResetEvent *_thereAreBytesToReadEvent; 13 | NWindows::NSynchronization::CManualResetEvent *_readStreamIsClosedEvent; 14 | UInt32 _bufferSize; 15 | const void *_buffer; 16 | public: 17 | // bool ReadingWasClosed; 18 | UInt64 ProcessedSize; 19 | CStreamBinder(): 20 | _allBytesAreWritenEvent(NULL), 21 | _thereAreBytesToReadEvent(NULL), 22 | _readStreamIsClosedEvent(NULL) 23 | {} 24 | ~CStreamBinder(); 25 | void CreateEvents(); 26 | 27 | void CreateStreams(ISequentialInStream **inStream, 28 | ISequentialOutStream **outStream); 29 | HRESULT Read(void *data, UInt32 size, UInt32 *processedSize); 30 | void CloseRead(); 31 | 32 | HRESULT Write(const void *data, UInt32 size, UInt32 *processedSize); 33 | void CloseWrite(); 34 | void ReInit(); 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/StreamUtils.cpp: -------------------------------------------------------------------------------- 1 | // StreamUtils.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../Common/MyCom.h" 6 | #include "StreamUtils.h" 7 | 8 | HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize) 9 | { 10 | if (processedSize != 0) 11 | *processedSize = 0; 12 | while(size != 0) 13 | { 14 | UInt32 processedSizeLoc; 15 | HRESULT res = stream->Read(data, size, &processedSizeLoc); 16 | if (processedSize != 0) 17 | *processedSize += processedSizeLoc; 18 | data = (Byte *)((Byte *)data + processedSizeLoc); 19 | size -= processedSizeLoc; 20 | RINOK(res); 21 | if (processedSizeLoc == 0) 22 | return S_OK; 23 | } 24 | return S_OK; 25 | } 26 | 27 | HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize) 28 | { 29 | if (processedSize != 0) 30 | *processedSize = 0; 31 | while(size != 0) 32 | { 33 | UInt32 processedSizeLoc; 34 | HRESULT res = stream->Write(data, size, &processedSizeLoc); 35 | if (processedSize != 0) 36 | *processedSize += processedSizeLoc; 37 | data = (const void *)((const Byte *)data + processedSizeLoc); 38 | size -= processedSizeLoc; 39 | RINOK(res); 40 | if (processedSizeLoc == 0) 41 | break; 42 | } 43 | return S_OK; 44 | } 45 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Common/StreamUtils.h: -------------------------------------------------------------------------------- 1 | // StreamUtils.h 2 | 3 | #ifndef __STREAMUTILS_H 4 | #define __STREAMUTILS_H 5 | 6 | #include "../IStream.h" 7 | 8 | HRESULT ReadStream(ISequentialInStream *stream, void *data, UInt32 size, UInt32 *processedSize); 9 | HRESULT WriteStream(ISequentialOutStream *stream, const void *data, UInt32 size, UInt32 *processedSize); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Branch/BranchCoder.cpp: -------------------------------------------------------------------------------- 1 | // BranchCoder.cpp 2 | 3 | #include "StdAfx.h" 4 | #include "BranchCoder.h" 5 | 6 | STDMETHODIMP CBranchConverter::Init() 7 | { 8 | _bufferPos = 0; 9 | SubInit(); 10 | return S_OK; 11 | } 12 | 13 | STDMETHODIMP_(UInt32) CBranchConverter::Filter(Byte *data, UInt32 size) 14 | { 15 | UInt32 processedSize = SubFilter(data, size); 16 | _bufferPos += processedSize; 17 | return processedSize; 18 | } 19 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Branch/BranchCoder.h: -------------------------------------------------------------------------------- 1 | // BranchCoder.h 2 | 3 | #ifndef __BRANCH_CODER_H 4 | #define __BRANCH_CODER_H 5 | 6 | #include "Common/MyCom.h" 7 | #include "Common/Types.h" 8 | #include "Common/Alloc.h" 9 | 10 | #include "../../ICoder.h" 11 | 12 | class CBranchConverter: 13 | public ICompressFilter, 14 | public CMyUnknownImp 15 | { 16 | protected: 17 | UInt32 _bufferPos; 18 | virtual void SubInit() {} 19 | virtual UInt32 SubFilter(Byte *data, UInt32 size) = 0; 20 | public: 21 | MY_UNKNOWN_IMP; 22 | STDMETHOD(Init)(); 23 | STDMETHOD_(UInt32, Filter)(Byte *data, UInt32 size); 24 | }; 25 | 26 | #define MyClassEncoderA(Name) class C ## Name: public CBranchConverter \ 27 | { public: UInt32 SubFilter(Byte *data, UInt32 size); }; 28 | 29 | #define MyClassDecoderA(Name) class C ## Name: public CBranchConverter \ 30 | { public: UInt32 SubFilter(Byte *data, UInt32 size); }; 31 | 32 | #define MyClassEncoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \ 33 | { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT}; 34 | 35 | #define MyClassDecoderB(Name, ADD_ITEMS, ADD_INIT) class C ## Name: public CBranchConverter, public ADD_ITEMS \ 36 | { public: UInt32 SubFilter(Byte *data, UInt32 size); ADD_INIT}; 37 | 38 | #define MyClass2b(Name, id, subId, encodingId) \ 39 | DEFINE_GUID(CLSID_CCompressConvert ## Name, \ 40 | 0x23170F69, 0x40C1, 0x278B, 0x03, 0x03, id, subId, 0x00, 0x00, encodingId, 0x00); 41 | 42 | #define MyClassA(Name, id, subId) \ 43 | MyClass2b(Name ## _Encoder, id, subId, 0x01) \ 44 | MyClassEncoderA(Name ## _Encoder) \ 45 | MyClass2b(Name ## _Decoder, id, subId, 0x00) \ 46 | MyClassDecoderA(Name ## _Decoder) 47 | 48 | #define MyClassB(Name, id, subId, ADD_ITEMS, ADD_INIT) \ 49 | MyClass2b(Name ## _Encoder, id, subId, 0x01) \ 50 | MyClassEncoderB(Name ## _Encoder, ADD_ITEMS, ADD_INIT) \ 51 | MyClass2b(Name ## _Decoder, id, subId, 0x00) \ 52 | MyClassDecoderB(Name ## _Decoder, ADD_ITEMS, ADD_INIT) 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Branch/BranchTypes.h: -------------------------------------------------------------------------------- 1 | /* BranchTypes.h */ 2 | 3 | #ifndef __BRANCHTYPES_H 4 | #define __BRANCHTYPES_H 5 | 6 | typedef unsigned char Byte; 7 | typedef unsigned short UInt16; 8 | 9 | #ifdef _LZMA_UINT32_IS_ULONG 10 | typedef unsigned long UInt32; 11 | #else 12 | typedef unsigned int UInt32; 13 | #endif 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Branch/BranchX86.c: -------------------------------------------------------------------------------- 1 | /* BranchX86.c */ 2 | 3 | #include "BranchX86.h" 4 | 5 | /* 6 | static int inline Test86MSByte(Byte b) 7 | { 8 | return (b == 0 || b == 0xFF); 9 | } 10 | */ 11 | #define Test86MSByte(b) ((b) == 0 || (b) == 0xFF) 12 | 13 | const int kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0}; 14 | const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3}; 15 | 16 | /* 17 | void x86_Convert_Init(UInt32 *prevMask, UInt32 *prevPos) 18 | { 19 | *prevMask = 0; 20 | *prevPos = (UInt32)(-5); 21 | } 22 | */ 23 | 24 | UInt32 x86_Convert(Byte *buffer, UInt32 endPos, UInt32 nowPos, 25 | UInt32 *prevMask, UInt32 *prevPos, int encoding) 26 | { 27 | UInt32 bufferPos = 0; 28 | UInt32 limit; 29 | 30 | if (endPos < 5) 31 | return 0; 32 | 33 | if (nowPos - *prevPos > 5) 34 | *prevPos = nowPos - 5; 35 | 36 | limit = endPos - 5; 37 | while(bufferPos <= limit) 38 | { 39 | Byte b = buffer[bufferPos]; 40 | UInt32 offset; 41 | if (b != 0xE8 && b != 0xE9) 42 | { 43 | bufferPos++; 44 | continue; 45 | } 46 | offset = (nowPos + bufferPos - *prevPos); 47 | *prevPos = (nowPos + bufferPos); 48 | if (offset > 5) 49 | *prevMask = 0; 50 | else 51 | { 52 | UInt32 i; 53 | for (i = 0; i < offset; i++) 54 | { 55 | *prevMask &= 0x77; 56 | *prevMask <<= 1; 57 | } 58 | } 59 | b = buffer[bufferPos + 4]; 60 | if (Test86MSByte(b) && kMaskToAllowedStatus[(*prevMask >> 1) & 0x7] && 61 | (*prevMask >> 1) < 0x10) 62 | { 63 | UInt32 src = 64 | ((UInt32)(b) << 24) | 65 | ((UInt32)(buffer[bufferPos + 3]) << 16) | 66 | ((UInt32)(buffer[bufferPos + 2]) << 8) | 67 | (buffer[bufferPos + 1]); 68 | 69 | UInt32 dest; 70 | while(1) 71 | { 72 | UInt32 index; 73 | if (encoding) 74 | dest = (nowPos + bufferPos + 5) + src; 75 | else 76 | dest = src - (nowPos + bufferPos + 5); 77 | if (*prevMask == 0) 78 | break; 79 | index = kMaskToBitNumber[*prevMask >> 1]; 80 | b = (Byte)(dest >> (24 - index * 8)); 81 | if (!Test86MSByte(b)) 82 | break; 83 | src = dest ^ ((1 << (32 - index * 8)) - 1); 84 | } 85 | buffer[bufferPos + 4] = (Byte)(~(((dest >> 24) & 1) - 1)); 86 | buffer[bufferPos + 3] = (Byte)(dest >> 16); 87 | buffer[bufferPos + 2] = (Byte)(dest >> 8); 88 | buffer[bufferPos + 1] = (Byte)dest; 89 | bufferPos += 5; 90 | *prevMask = 0; 91 | } 92 | else 93 | { 94 | bufferPos++; 95 | *prevMask |= 1; 96 | if (Test86MSByte(b)) 97 | *prevMask |= 0x10; 98 | } 99 | } 100 | return bufferPos; 101 | } 102 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Branch/BranchX86.h: -------------------------------------------------------------------------------- 1 | /* BranchX86.h */ 2 | 3 | #ifndef __BRANCHX86_H 4 | #define __BRANCHX86_H 5 | 6 | #include "BranchTypes.h" 7 | 8 | #define x86_Convert_Init(prevMask, prevPos) { prevMask = 0; prevPos = (UInt32)(-5); } 9 | 10 | UInt32 x86_Convert(Byte *buffer, UInt32 endPos, UInt32 nowPos, 11 | UInt32 *prevMask, UInt32 *prevPos, int encoding); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Branch/x86.cpp: -------------------------------------------------------------------------------- 1 | // x86.cpp 2 | 3 | #include "StdAfx.h" 4 | #include "x86.h" 5 | 6 | #include "Windows/Defs.h" 7 | 8 | #include "BranchX86.c" 9 | 10 | UInt32 CBCJ_x86_Encoder::SubFilter(Byte *data, UInt32 size) 11 | { 12 | return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 1); 13 | } 14 | 15 | UInt32 CBCJ_x86_Decoder::SubFilter(Byte *data, UInt32 size) 16 | { 17 | return ::x86_Convert(data, size, _bufferPos, &_prevMask, &_prevPos, 0); 18 | } 19 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Branch/x86.h: -------------------------------------------------------------------------------- 1 | // x86.h 2 | 3 | #ifndef __X86_H 4 | #define __X86_H 5 | 6 | #include "BranchCoder.h" 7 | #include "BranchX86.h" 8 | 9 | struct CBranch86 10 | { 11 | UInt32 _prevMask; 12 | UInt32 _prevPos; 13 | void x86Init() { x86_Convert_Init(_prevMask, _prevPos); } 14 | }; 15 | 16 | MyClassB(BCJ_x86, 0x01, 3, CBranch86 , 17 | virtual void SubInit() { x86Init(); }) 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Copy/CopyCoder.cpp: -------------------------------------------------------------------------------- 1 | // Compress/CopyCoder.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "CopyCoder.h" 6 | #include "../../../Common/Alloc.h" 7 | #include "../../Common/StreamUtils.h" 8 | 9 | namespace NCompress { 10 | 11 | static const UInt32 kBufferSize = 1 << 17; 12 | 13 | CCopyCoder::~CCopyCoder() 14 | { 15 | ::MidFree(_buffer); 16 | } 17 | 18 | STDMETHODIMP CCopyCoder::Code(ISequentialInStream *inStream, 19 | ISequentialOutStream *outStream, 20 | const UInt64 *inSize, const UInt64 *outSize, 21 | ICompressProgressInfo *progress) 22 | { 23 | if (_buffer == 0) 24 | { 25 | _buffer = (Byte *)::MidAlloc(kBufferSize); 26 | if (_buffer == 0) 27 | return E_OUTOFMEMORY; 28 | } 29 | 30 | TotalSize = 0; 31 | while(true) 32 | { 33 | UInt32 realProcessedSize; 34 | UInt32 size = kBufferSize; 35 | if (outSize != 0) 36 | if (size > *outSize - TotalSize) 37 | size = (UInt32)(*outSize - TotalSize); 38 | RINOK(inStream->Read(_buffer, size, &realProcessedSize)); 39 | if(realProcessedSize == 0) 40 | break; 41 | RINOK(WriteStream(outStream, _buffer, realProcessedSize, NULL)); 42 | TotalSize += realProcessedSize; 43 | if (progress != NULL) 44 | { 45 | RINOK(progress->SetRatioInfo(&TotalSize, &TotalSize)); 46 | } 47 | } 48 | return S_OK; 49 | } 50 | 51 | } 52 | 53 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/Copy/CopyCoder.h: -------------------------------------------------------------------------------- 1 | // Compress/CopyCoder.h 2 | 3 | #ifndef __COMPRESS_COPYCODER_H 4 | #define __COMPRESS_COPYCODER_H 5 | 6 | #include "../../ICoder.h" 7 | #include "../../../Common/MyCom.h" 8 | 9 | namespace NCompress { 10 | 11 | class CCopyCoder: 12 | public ICompressCoder, 13 | public CMyUnknownImp 14 | { 15 | Byte *_buffer; 16 | public: 17 | UInt64 TotalSize; 18 | CCopyCoder(): TotalSize(0) , _buffer(0) {}; 19 | ~CCopyCoder(); 20 | 21 | MY_UNKNOWN_IMP 22 | 23 | STDMETHOD(Code)(ISequentialInStream *inStream, 24 | ISequentialOutStream *outStream, 25 | const UInt64 *inSize, const UInt64 *outSize, 26 | ICompressProgressInfo *progress); 27 | }; 28 | 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/LZ/LZOutWindow.cpp: -------------------------------------------------------------------------------- 1 | // LZOutWindow.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "../../../Common/Alloc.h" 6 | #include "LZOutWindow.h" 7 | 8 | void CLZOutWindow::Init(bool solid) 9 | { 10 | if(!solid) 11 | COutBuffer::Init(); 12 | #ifdef _NO_EXCEPTIONS 13 | ErrorCode = S_OK; 14 | #endif 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/LZ/LZOutWindow.h: -------------------------------------------------------------------------------- 1 | // LZOutWindow.h 2 | 3 | #ifndef __LZ_OUT_WINDOW_H 4 | #define __LZ_OUT_WINDOW_H 5 | 6 | #include "../../IStream.h" 7 | #include "../../Common/OutBuffer.h" 8 | 9 | #ifndef _NO_EXCEPTIONS 10 | typedef COutBufferException CLZOutWindowException; 11 | #endif 12 | 13 | class CLZOutWindow: public COutBuffer 14 | { 15 | public: 16 | void Init(bool solid = false); 17 | 18 | // distance >= 0, len > 0, 19 | bool CopyBlock(UInt32 distance, UInt32 len) 20 | { 21 | UInt32 pos = _pos - distance - 1; 22 | if (distance >= _pos) 23 | { 24 | if (!_overDict || distance >= _bufferSize) 25 | return false; 26 | pos += _bufferSize; 27 | } 28 | do 29 | { 30 | if (pos == _bufferSize) 31 | pos = 0; 32 | _buffer[_pos++] = _buffer[pos++]; 33 | if (_pos == _limitPos) 34 | FlushWithCheck(); 35 | } 36 | while(--len != 0); 37 | return true; 38 | } 39 | 40 | void PutByte(Byte b) 41 | { 42 | _buffer[_pos++] = b; 43 | if (_pos == _limitPos) 44 | FlushWithCheck(); 45 | } 46 | 47 | Byte GetByte(UInt32 distance) const 48 | { 49 | UInt32 pos = _pos - distance - 1; 50 | if (pos >= _bufferSize) 51 | pos += _bufferSize; 52 | return _buffer[pos]; 53 | } 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/LZMA/LZMA.h: -------------------------------------------------------------------------------- 1 | // LZMA.h 2 | 3 | #ifndef __LZMA_H 4 | #define __LZMA_H 5 | 6 | namespace NCompress { 7 | namespace NLZMA { 8 | 9 | const UInt32 kNumRepDistances = 4; 10 | 11 | const int kNumStates = 12; 12 | 13 | const Byte kLiteralNextStates[kNumStates] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5}; 14 | const Byte kMatchNextStates[kNumStates] = {7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10}; 15 | const Byte kRepNextStates[kNumStates] = {8, 8, 8, 8, 8, 8, 8, 11, 11, 11, 11, 11}; 16 | const Byte kShortRepNextStates[kNumStates]= {9, 9, 9, 9, 9, 9, 9, 11, 11, 11, 11, 11}; 17 | 18 | class CState 19 | { 20 | public: 21 | Byte Index; 22 | void Init() { Index = 0; } 23 | void UpdateChar() { Index = kLiteralNextStates[Index]; } 24 | void UpdateMatch() { Index = kMatchNextStates[Index]; } 25 | void UpdateRep() { Index = kRepNextStates[Index]; } 26 | void UpdateShortRep() { Index = kShortRepNextStates[Index]; } 27 | bool IsCharState() const { return Index < 7; } 28 | }; 29 | 30 | const int kNumPosSlotBits = 6; 31 | const int kDicLogSizeMin = 0; 32 | const int kDicLogSizeMax = 32; 33 | const int kDistTableSizeMax = kDicLogSizeMax * 2; 34 | 35 | const UInt32 kNumLenToPosStates = 4; 36 | 37 | inline UInt32 GetLenToPosState(UInt32 len) 38 | { 39 | len -= 2; 40 | if (len < kNumLenToPosStates) 41 | return len; 42 | return kNumLenToPosStates - 1; 43 | } 44 | 45 | namespace NLength { 46 | 47 | const int kNumPosStatesBitsMax = 4; 48 | const UInt32 kNumPosStatesMax = (1 << kNumPosStatesBitsMax); 49 | 50 | const int kNumPosStatesBitsEncodingMax = 4; 51 | const UInt32 kNumPosStatesEncodingMax = (1 << kNumPosStatesBitsEncodingMax); 52 | 53 | const int kNumLowBits = 3; 54 | const int kNumMidBits = 3; 55 | const int kNumHighBits = 8; 56 | const UInt32 kNumLowSymbols = 1 << kNumLowBits; 57 | const UInt32 kNumMidSymbols = 1 << kNumMidBits; 58 | const UInt32 kNumSymbolsTotal = kNumLowSymbols + kNumMidSymbols + (1 << kNumHighBits); 59 | 60 | } 61 | 62 | const UInt32 kMatchMinLen = 2; 63 | const UInt32 kMatchMaxLen = kMatchMinLen + NLength::kNumSymbolsTotal - 1; 64 | 65 | const int kNumAlignBits = 4; 66 | const UInt32 kAlignTableSize = 1 << kNumAlignBits; 67 | const UInt32 kAlignMask = (kAlignTableSize - 1); 68 | 69 | const UInt32 kStartPosModelIndex = 4; 70 | const UInt32 kEndPosModelIndex = 14; 71 | const UInt32 kNumPosModels = kEndPosModelIndex - kStartPosModelIndex; 72 | 73 | const UInt32 kNumFullDistances = 1 << (kEndPosModelIndex / 2); 74 | 75 | const int kNumLitPosStatesBitsEncodingMax = 4; 76 | const int kNumLitContextBitsMax = 8; 77 | 78 | const int kNumMoveBits = 5; 79 | 80 | }} 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/RangeCoder/RangeCoderBit.cpp: -------------------------------------------------------------------------------- 1 | // Compress/RangeCoder/RangeCoderBit.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "RangeCoderBit.h" 6 | 7 | namespace NCompress { 8 | namespace NRangeCoder { 9 | 10 | UInt32 CPriceTables::ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; 11 | static CPriceTables g_PriceTables; 12 | 13 | CPriceTables::CPriceTables() { Init(); } 14 | 15 | void CPriceTables::Init() 16 | { 17 | const int kNumBits = (kNumBitModelTotalBits - kNumMoveReducingBits); 18 | for(int i = kNumBits - 1; i >= 0; i--) 19 | { 20 | UInt32 start = 1 << (kNumBits - i - 1); 21 | UInt32 end = 1 << (kNumBits - i); 22 | for (UInt32 j = start; j < end; j++) 23 | ProbPrices[j] = (i << kNumBitPriceShiftBits) + 24 | (((end - j) << kNumBitPriceShiftBits) >> (kNumBits - i - 1)); 25 | } 26 | 27 | /* 28 | // simplest: bad solution 29 | for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) 30 | ProbPrices[i] = kBitPrice; 31 | */ 32 | 33 | /* 34 | const double kDummyMultMid = (1.0 / kBitPrice) / 2; 35 | const double kDummyMultMid = 0; 36 | // float solution 37 | double ln2 = log(double(2)); 38 | double lnAll = log(double(kBitModelTotal >> kNumMoveReducingBits)); 39 | for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) 40 | ProbPrices[i] = UInt32((fabs(lnAll - log(double(i))) / ln2 + kDummyMultMid) * kBitPrice); 41 | */ 42 | 43 | /* 44 | // experimental, slow, solution: 45 | for(UInt32 i = 1; i < (kBitModelTotal >> kNumMoveReducingBits) - 1; i++) 46 | { 47 | const int kCyclesBits = 5; 48 | const UInt32 kCycles = (1 << kCyclesBits); 49 | 50 | UInt32 range = UInt32(-1); 51 | UInt32 bitCount = 0; 52 | for (UInt32 j = 0; j < kCycles; j++) 53 | { 54 | range >>= (kNumBitModelTotalBits - kNumMoveReducingBits); 55 | range *= i; 56 | while(range < (1 << 31)) 57 | { 58 | range <<= 1; 59 | bitCount++; 60 | } 61 | } 62 | bitCount <<= kNumBitPriceShiftBits; 63 | range -= (1 << 31); 64 | for (int k = kNumBitPriceShiftBits - 1; k >= 0; k--) 65 | { 66 | range <<= 1; 67 | if (range > (1 << 31)) 68 | { 69 | bitCount += (1 << k); 70 | range -= (1 << 31); 71 | } 72 | } 73 | ProbPrices[i] = (bitCount 74 | // + (1 << (kCyclesBits - 1)) 75 | ) >> kCyclesBits; 76 | } 77 | */ 78 | } 79 | 80 | }} 81 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/Compress/RangeCoder/RangeCoderOpt.h: -------------------------------------------------------------------------------- 1 | // Compress/RangeCoder/RangeCoderOpt.h 2 | 3 | #ifndef __COMPRESS_RANGECODER_OPT_H 4 | #define __COMPRESS_RANGECODER_OPT_H 5 | 6 | #define RC_INIT_VAR \ 7 | UInt32 range = rangeDecoder->Range; \ 8 | UInt32 code = rangeDecoder->Code; 9 | 10 | #define RC_FLUSH_VAR \ 11 | rangeDecoder->Range = range; \ 12 | rangeDecoder->Code = code; 13 | 14 | #define RC_NORMALIZE \ 15 | if (range < NCompress::NRangeCoder::kTopValue) \ 16 | { code = (code << 8) | rangeDecoder->Stream.ReadByte(); range <<= 8; } 17 | 18 | #define RC_GETBIT2(numMoveBits, prob, mi, A0, A1) \ 19 | { UInt32 bound = (range >> NCompress::NRangeCoder::kNumBitModelTotalBits) * prob; \ 20 | if (code < bound) \ 21 | { A0; range = bound; \ 22 | prob += (NCompress::NRangeCoder::kBitModelTotal - prob) >> numMoveBits; \ 23 | mi <<= 1; } \ 24 | else \ 25 | { A1; range -= bound; code -= bound; prob -= (prob) >> numMoveBits; \ 26 | mi = (mi + mi) + 1; }} \ 27 | RC_NORMALIZE 28 | 29 | #define RC_GETBIT(numMoveBits, prob, mi) RC_GETBIT2(numMoveBits, prob, mi, ; , ;) 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/FileManager/FormatUtils.cpp: -------------------------------------------------------------------------------- 1 | // FormatUtils.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "FormatUtils.h" 6 | #include "Common/IntToString.h" 7 | #include "Windows/ResourceString.h" 8 | 9 | #ifdef LANG 10 | #include "LangUtils.h" 11 | #endif 12 | 13 | UString NumberToString(UInt64 number) 14 | { 15 | wchar_t numberString[32]; 16 | ConvertUInt64ToString(number, numberString); 17 | return numberString; 18 | } 19 | 20 | UString MyFormatNew(const UString &format, const UString &argument) 21 | { 22 | UString result = format; 23 | result.Replace(L"{0}", argument); 24 | return result; 25 | } 26 | 27 | UString MyFormatNew(UINT resourceID, 28 | #ifdef LANG 29 | UInt32 langID, 30 | #endif 31 | const UString &argument) 32 | { 33 | return MyFormatNew( 34 | #ifdef LANG 35 | LangString(resourceID, langID), 36 | #else 37 | NWindows::MyLoadStringW(resourceID), 38 | #endif 39 | argument); 40 | } 41 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/FileManager/FormatUtils.h: -------------------------------------------------------------------------------- 1 | // FormatUtils.h 2 | 3 | #ifndef __FORMATUTILS_H 4 | #define __FORMATUTILS_H 5 | 6 | #include "Common/Types.h" 7 | #include "Common/String.h" 8 | 9 | UString NumberToString(UInt64 number); 10 | 11 | UString MyFormatNew(const UString &format, const UString &argument); 12 | UString MyFormatNew(UINT resourceID, 13 | #ifdef LANG 14 | UInt32 langID, 15 | #endif 16 | const UString &argument); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/FileManager/Resource/ProgressDialog/StdAfx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h 2 | 3 | #ifndef __STDAFX_H 4 | #define __STDAFX_H 5 | 6 | #define _WIN32_WINNT 0x0400 7 | 8 | // it's for Windows NT supporting (MENUITEMINFOW) 9 | #define WINVER 0x0400 10 | 11 | #include 12 | #include 13 | 14 | #include "Common/NewHandler.h" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/FileManager/Resource/ProgressDialog/resource.h: -------------------------------------------------------------------------------- 1 | #define IDD_DIALOG_PROGRESS 500 2 | 3 | #define IDC_PROGRESS1 1000 4 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/FileManager/Resource/ProgressDialog/resource.rc: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "../../../GuiCommon.rc" 3 | 4 | #define xSize2 172 5 | #define ySize2 42 6 | #define xSize (xSize2 + marg + marg) 7 | #define ySize (ySize2 + marg + marg) 8 | 9 | #define bYPos (ySize - marg - bYSize) 10 | #define bXPos (xSize - marg - bXSize) 11 | 12 | 13 | IDD_DIALOG_PROGRESS DIALOG 0, 0, xSize, ySize MY_MODAL_DIALOG_STYLE 14 | CAPTION "Progress" 15 | MY_FONT 16 | BEGIN 17 | PUSHBUTTON "Cancel", IDCANCEL, bXPos, bYPos , bXSize, bYSize 18 | CONTROL "Progress1", IDC_PROGRESS1,"msctls_progress32",PBS_SMOOTH | WS_BORDER, 19 | marg,marg, xSize2, 14 20 | END 21 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/GuiCommon.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #define marg 7 6 | #undef bXSize 7 | #undef bYSize 8 | #define bXSize 64 9 | #define bYSize 14 10 | #define bDotsSize 20 11 | 12 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 13 | 14 | #undef xSize2 15 | #undef ySize2 16 | #undef xSize 17 | #undef ySize 18 | #undef bXPos 19 | #undef bYPos 20 | #undef b1XPos 21 | #undef b1YPos 22 | #undef b2XPos 23 | #undef b2YPos 24 | #undef b3XPos 25 | #undef b3YPos 26 | #undef gPos 27 | #undef gPos2 28 | #undef gSpace 29 | #undef gSize 30 | #undef marg2 31 | #undef marg3 32 | 33 | 34 | #define MY_MODAL_DIALOG_STYLE STYLE DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU 35 | #define MY_PAGE_STYLE STYLE DS_FIXEDSYS | WS_CHILD | WS_DISABLED | WS_CAPTION 36 | 37 | #define MY_FONT FONT 8, "MS Shell Dlg" 38 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/IPassword.h: -------------------------------------------------------------------------------- 1 | // IPassword.h 2 | 3 | #ifndef __IPASSWORD_H 4 | #define __IPASSWORD_H 5 | 6 | #include "../Common/MyUnknown.h" 7 | #include "../Common/Types.h" 8 | 9 | // MIDL_INTERFACE("23170F69-40C1-278A-0000-000500xx0000") 10 | #define PASSWORD_INTERFACE(i, x) \ 11 | DEFINE_GUID(IID_ ## i, \ 12 | 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x05, 0x00, x, 0x00, 0x00); \ 13 | struct i: public IUnknown 14 | 15 | PASSWORD_INTERFACE(ICryptoGetTextPassword, 0x10) 16 | { 17 | STDMETHOD(CryptoGetTextPassword)(BSTR *password) PURE; 18 | }; 19 | 20 | PASSWORD_INTERFACE(ICryptoGetTextPassword2, 0x11) 21 | { 22 | STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password) PURE; 23 | }; 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/IProgress.h: -------------------------------------------------------------------------------- 1 | // Interface/IProgress.h 2 | 3 | #ifndef __IPROGRESS_H 4 | #define __IPROGRESS_H 5 | 6 | #include "../Common/MyUnknown.h" 7 | #include "../Common/Types.h" 8 | 9 | // {23170F69-40C1-278A-0000-000000050000} 10 | DEFINE_GUID(IID_IProgress, 11 | 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00); 12 | MIDL_INTERFACE("23170F69-40C1-278A-0000-000000050000") 13 | IProgress: public IUnknown 14 | { 15 | STDMETHOD(SetTotal)(UInt64 total) PURE; 16 | STDMETHOD(SetCompleted)(const UInt64 *completeValue) PURE; 17 | }; 18 | 19 | /* 20 | // {23170F69-40C1-278A-0000-000000050002} 21 | DEFINE_GUID(IID_IProgress2, 22 | 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x02); 23 | MIDL_INTERFACE("23170F69-40C1-278A-0000-000000050002") 24 | IProgress2: public IUnknown 25 | { 26 | public: 27 | STDMETHOD(SetTotal)(const UInt64 *total) PURE; 28 | STDMETHOD(SetCompleted)(const UInt64 *completeValue) PURE; 29 | }; 30 | */ 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/IStream.h: -------------------------------------------------------------------------------- 1 | // IStream.h 2 | 3 | #ifndef __ISTREAM_H 4 | #define __ISTREAM_H 5 | 6 | #include "../Common/MyUnknown.h" 7 | #include "../Common/Types.h" 8 | 9 | // "23170F69-40C1-278A-0000-000300xx0000" 10 | 11 | #define STREAM_INTERFACE_SUB(i, b, x) \ 12 | DEFINE_GUID(IID_ ## i, \ 13 | 0x23170F69, 0x40C1, 0x278A, 0x00, 0x00, 0x00, 0x03, 0x00, x, 0x00, 0x00); \ 14 | struct i: public b 15 | 16 | #define STREAM_INTERFACE(i, x) STREAM_INTERFACE_SUB(i, IUnknown, x) 17 | 18 | STREAM_INTERFACE(ISequentialInStream, 0x01) 19 | { 20 | STDMETHOD(Read)(void *data, UInt32 size, UInt32 *processedSize) PURE; 21 | /* 22 | Out: if size != 0, return_value = S_OK and (*processedSize == 0), 23 | then there are no more bytes in stream. 24 | if (size > 0) && there are bytes in stream, 25 | this function must read at least 1 byte. 26 | This function is allowed to read less than number of remaining bytes in stream. 27 | You must call Read function in loop, if you need exact amount of data 28 | */ 29 | }; 30 | 31 | STREAM_INTERFACE(ISequentialOutStream, 0x02) 32 | { 33 | STDMETHOD(Write)(const void *data, UInt32 size, UInt32 *processedSize) PURE; 34 | /* 35 | if (size > 0) this function must write at least 1 byte. 36 | This function is allowed to write less than "size". 37 | You must call Write function in loop, if you need to write exact amount of data 38 | */ 39 | }; 40 | 41 | STREAM_INTERFACE_SUB(IInStream, ISequentialInStream, 0x03) 42 | { 43 | STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE; 44 | }; 45 | 46 | STREAM_INTERFACE_SUB(IOutStream, ISequentialOutStream, 0x04) 47 | { 48 | STDMETHOD(Seek)(Int64 offset, UInt32 seekOrigin, UInt64 *newPosition) PURE; 49 | STDMETHOD(SetSize)(Int64 newSize) PURE; 50 | }; 51 | 52 | STREAM_INTERFACE(IStreamGetSize, 0x06) 53 | { 54 | STDMETHOD(GetSize)(UInt64 *size) PURE; 55 | }; 56 | 57 | STREAM_INTERFACE(IOutStreamFlush, 0x07) 58 | { 59 | STDMETHOD(Flush)() PURE; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/MyVersion.h: -------------------------------------------------------------------------------- 1 | #define MY_VER_MAJOR 4 2 | #define MY_VER_MINOR 42 3 | #define MY_VER_BUILD 0 4 | #define MY_VERSION "4.42" 5 | #define MY_7ZIP_VERSION "7-Zip 4.42" 6 | #define MY_DATE "2006-05-14" 7 | #define MY_COPYRIGHT "Copyright (c) 1999-2006 Igor Pavlov" 8 | #define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " " MY_DATE 9 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/MyVersionInfo.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MyVersion.h" 3 | 4 | #define MY_VER MY_VER_MAJOR,MY_VER_MINOR,MY_VER_BUILD,0 5 | 6 | #ifdef DEBUG 7 | #define DBG_FL VS_FF_DEBUG 8 | #else 9 | #define DBG_FL 0 10 | #endif 11 | 12 | #define MY_VERSION_INFO(fileType, descr, intName, origName) \ 13 | LANGUAGE 9, 1 \ 14 | 1 VERSIONINFO \ 15 | FILEVERSION MY_VER \ 16 | PRODUCTVERSION MY_VER \ 17 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK \ 18 | FILEFLAGS DBG_FL \ 19 | FILEOS VOS_NT_WINDOWS32 \ 20 | FILETYPE fileType \ 21 | FILESUBTYPE 0x0L \ 22 | BEGIN \ 23 | BLOCK "StringFileInfo" \ 24 | BEGIN \ 25 | BLOCK "040904b0" \ 26 | BEGIN \ 27 | VALUE "CompanyName", "Igor Pavlov" \ 28 | VALUE "FileDescription", descr \ 29 | VALUE "FileVersion", MY_VERSION \ 30 | VALUE "InternalName", intName \ 31 | VALUE "LegalCopyright", MY_COPYRIGHT \ 32 | VALUE "OriginalFilename", origName \ 33 | VALUE "ProductName", "7-Zip" \ 34 | VALUE "ProductVersion", MY_VERSION \ 35 | END \ 36 | END \ 37 | END 38 | 39 | #define MY_VERSION_INFO_APP(descr, intName) MY_VERSION_INFO(VFT_APP, descr, intName, intName ".exe") 40 | 41 | #define MY_VERSION_INFO_DLL(descr, intName) MY_VERSION_INFO(VFT_DLL, descr, intName, intName ".dll") 42 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/PropID.h: -------------------------------------------------------------------------------- 1 | // Interface/PropID.h 2 | 3 | #ifndef __INTERFACE_PROPID_H 4 | #define __INTERFACE_PROPID_H 5 | 6 | enum 7 | { 8 | kpidNoProperty = 0, 9 | 10 | kpidHandlerItemIndex = 2, 11 | kpidPath, 12 | kpidName, 13 | kpidExtension, 14 | kpidIsFolder, 15 | kpidSize, 16 | kpidPackedSize, 17 | kpidAttributes, 18 | kpidCreationTime, 19 | kpidLastAccessTime, 20 | kpidLastWriteTime, 21 | kpidSolid, 22 | kpidCommented, 23 | kpidEncrypted, 24 | kpidSplitBefore, 25 | kpidSplitAfter, 26 | kpidDictionarySize, 27 | kpidCRC, 28 | kpidType, 29 | kpidIsAnti, 30 | kpidMethod, 31 | kpidHostOS, 32 | kpidFileSystem, 33 | kpidUser, 34 | kpidGroup, 35 | kpidBlock, 36 | kpidComment, 37 | kpidPosition, 38 | kpidPrefix, 39 | 40 | kpidTotalSize = 0x1100, 41 | kpidFreeSpace, 42 | kpidClusterSize, 43 | kpidVolumeName, 44 | 45 | kpidLocalName = 0x1200, 46 | kpidProvider, 47 | 48 | kpidUserDefined = 0x10000 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/UI/Common/ArchiveOpenCallback.h: -------------------------------------------------------------------------------- 1 | // ArchiveOpenCallback.h 2 | 3 | #ifndef __ARCHIVE_OPEN_CALLBACK_H 4 | #define __ARCHIVE_OPEN_CALLBACK_H 5 | 6 | #include "Common/String.h" 7 | #include "Common/MyCom.h" 8 | #include "Windows/FileFind.h" 9 | 10 | #ifndef _NO_CRYPTO 11 | #include "../../IPassword.h" 12 | #endif 13 | #include "../../Archive/IArchive.h" 14 | 15 | struct IOpenCallbackUI 16 | { 17 | virtual HRESULT CheckBreak() = 0; 18 | virtual HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes) = 0; 19 | virtual HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes) = 0; 20 | #ifndef _NO_CRYPTO 21 | virtual HRESULT CryptoGetTextPassword(BSTR *password) = 0; 22 | virtual HRESULT GetPasswordIfAny(UString &password) = 0; 23 | #endif 24 | }; 25 | 26 | class COpenCallbackImp: 27 | public IArchiveOpenCallback, 28 | public IArchiveOpenVolumeCallback, 29 | public IArchiveOpenSetSubArchiveName, 30 | #ifndef _NO_CRYPTO 31 | public ICryptoGetTextPassword, 32 | #endif 33 | public CMyUnknownImp 34 | { 35 | public: 36 | #ifndef _NO_CRYPTO 37 | MY_UNKNOWN_IMP3( 38 | IArchiveOpenVolumeCallback, 39 | ICryptoGetTextPassword, 40 | IArchiveOpenSetSubArchiveName 41 | ) 42 | #else 43 | MY_UNKNOWN_IMP2( 44 | IArchiveOpenVolumeCallback, 45 | IArchiveOpenSetSubArchiveName 46 | ) 47 | #endif 48 | 49 | STDMETHOD(SetTotal)(const UInt64 *files, const UInt64 *bytes); 50 | STDMETHOD(SetCompleted)(const UInt64 *files, const UInt64 *bytes); 51 | 52 | // IArchiveOpenVolumeCallback 53 | STDMETHOD(GetProperty)(PROPID propID, PROPVARIANT *value); 54 | STDMETHOD(GetStream)(const wchar_t *name, IInStream **inStream); 55 | 56 | #ifndef _NO_CRYPTO 57 | // ICryptoGetTextPassword 58 | STDMETHOD(CryptoGetTextPassword)(BSTR *password); 59 | #endif 60 | 61 | STDMETHOD(SetSubArchiveName(const wchar_t *name)) 62 | { 63 | _subArchiveMode = true; 64 | _subArchiveName = name; 65 | return S_OK; 66 | } 67 | 68 | private: 69 | UString _folderPrefix; 70 | NWindows::NFile::NFind::CFileInfoW _fileInfo; 71 | bool _subArchiveMode; 72 | UString _subArchiveName; 73 | public: 74 | UStringVector FileNames; 75 | IOpenCallbackUI *Callback; 76 | void Init(const UString &folderPrefix, const UString &fileName) 77 | { 78 | _folderPrefix = folderPrefix; 79 | if (!NWindows::NFile::NFind::FindFile(_folderPrefix + fileName, _fileInfo)) 80 | throw 1; 81 | FileNames.Clear(); 82 | _subArchiveMode = false; 83 | } 84 | int FindName(const UString &name); 85 | }; 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/UI/Common/ArchiverInfo.h: -------------------------------------------------------------------------------- 1 | // ArchiverInfo.h 2 | 3 | #ifndef __ARCHIVERINFO_H 4 | #define __ARCHIVERINFO_H 5 | 6 | #include "Common/String.h" 7 | #include "Common/Types.h" 8 | #include "Common/Buffer.h" 9 | 10 | struct CArchiverExtInfo 11 | { 12 | UString Ext; 13 | UString AddExt; 14 | CArchiverExtInfo() {} 15 | CArchiverExtInfo(const UString &ext): Ext(ext) {} 16 | CArchiverExtInfo(const UString &ext, const UString &addExt): Ext(ext), AddExt(addExt) {} 17 | }; 18 | 19 | struct CArchiverInfo 20 | { 21 | #ifndef EXCLUDE_COM 22 | UString FilePath; 23 | CLSID ClassID; 24 | #endif 25 | UString Name; 26 | CObjectVector Extensions; 27 | #ifndef _SFX 28 | CByteBuffer StartSignature; 29 | CByteBuffer FinishSignature; 30 | bool Associate; 31 | #endif 32 | int FindExtension(const UString &ext) const 33 | { 34 | for (int i = 0; i < Extensions.Size(); i++) 35 | if (ext.CompareNoCase(Extensions[i].Ext) == 0) 36 | return i; 37 | return -1; 38 | } 39 | UString GetAllExtensions() const 40 | { 41 | UString s; 42 | for (int i = 0; i < Extensions.Size(); i++) 43 | { 44 | if (i > 0) 45 | s += ' '; 46 | s += Extensions[i].Ext; 47 | } 48 | return s; 49 | } 50 | const UString &GetMainExtension() const 51 | { 52 | return Extensions[0].Ext; 53 | } 54 | bool UpdateEnabled; 55 | bool KeepName; 56 | 57 | CArchiverInfo(): UpdateEnabled(false), KeepName(false) 58 | #ifndef _SFX 59 | ,Associate(true) 60 | #endif 61 | {} 62 | }; 63 | 64 | void ReadArchiverInfoList(CObjectVector &archivers); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/UI/Common/DefaultName.cpp: -------------------------------------------------------------------------------- 1 | // DefaultName.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "DefaultName.h" 6 | 7 | static const wchar_t *kEmptyFileAlias = L"[Content]"; 8 | 9 | UString GetDefaultName2(const UString &fileName, 10 | const UString &extension, const UString &addSubExtension) 11 | { 12 | int extLength = extension.Length(); 13 | int fileNameLength = fileName.Length(); 14 | if (fileNameLength > extLength + 1) 15 | { 16 | int dotPos = fileNameLength - (extLength + 1); 17 | if (fileName[dotPos] == '.') 18 | if (extension.CompareNoCase(fileName.Mid(dotPos + 1)) == 0) 19 | return fileName.Left(dotPos) + addSubExtension; 20 | } 21 | return kEmptyFileAlias; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/UI/Common/DefaultName.h: -------------------------------------------------------------------------------- 1 | // DefaultName.h 2 | 3 | #ifndef __DEFAULTNAME_H 4 | #define __DEFAULTNAME_H 5 | 6 | #include "Common/String.h" 7 | 8 | UString GetDefaultName2(const UString &fileName, 9 | const UString &extension, const UString &addSubExtension); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/UI/Explorer/MyMessages.cpp: -------------------------------------------------------------------------------- 1 | // MyMessages.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "MyMessages.h" 6 | #include "Common/String.h" 7 | #include "Common/StringConvert.h" 8 | 9 | #include "Windows/Error.h" 10 | #include "Windows/ResourceString.h" 11 | 12 | #ifdef LANG 13 | #include "../../FileManager/LangUtils.h" 14 | #endif 15 | 16 | using namespace NWindows; 17 | 18 | void MyMessageBox(HWND window, LPCWSTR message) 19 | { 20 | ::MessageBoxW(window, message, L"7-Zip", 0); 21 | } 22 | 23 | void MyMessageBox(UINT32 id 24 | #ifdef LANG 25 | ,UINT32 langID 26 | #endif 27 | ) 28 | { 29 | #ifdef LANG 30 | MyMessageBox(LangString(id, langID)); 31 | #else 32 | MyMessageBox(MyLoadStringW(id)); 33 | #endif 34 | } 35 | 36 | void ShowErrorMessage(HWND window, DWORD message) 37 | { 38 | MyMessageBox(window, NError::MyFormatMessageW(message)); 39 | } 40 | 41 | void ShowLastErrorMessage(HWND window) 42 | { 43 | ShowErrorMessage(window, ::GetLastError()); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/UI/Explorer/MyMessages.h: -------------------------------------------------------------------------------- 1 | // MyMessages.h 2 | 3 | #ifndef __MYMESSAGES_H 4 | #define __MYMESSAGES_H 5 | 6 | #include "Common/String.h" 7 | 8 | void MyMessageBox(HWND window, LPCWSTR message); 9 | 10 | inline void MyMessageBox(LPCWSTR message) 11 | { MyMessageBox(0, message); } 12 | 13 | void MyMessageBox(UINT32 id 14 | #ifdef LANG 15 | ,UINT32 langID 16 | #endif 17 | ); 18 | 19 | void ShowErrorMessage(HWND window, DWORD errorMessage); 20 | inline void ShowErrorMessage(DWORD errorMessage) 21 | { ShowErrorMessage(0, errorMessage); } 22 | void ShowLastErrorMessage(HWND window = 0); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/UI/GUI/OpenCallbackGUI.cpp: -------------------------------------------------------------------------------- 1 | // OpenCallbackGUI.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "OpenCallbackGUI.h" 6 | 7 | #include "Common/StdOutStream.h" 8 | #include "Common/StdInStream.h" 9 | #include "Common/StringConvert.h" 10 | 11 | #ifndef _NO_CRYPTO 12 | #include "../../FileManager/Resource/PasswordDialog/PasswordDialog.h" 13 | #endif 14 | 15 | HRESULT COpenCallbackGUI::CheckBreak() 16 | { 17 | return S_OK; 18 | } 19 | 20 | HRESULT COpenCallbackGUI::SetTotal(const UInt64 *files, const UInt64 *bytes) 21 | { 22 | return S_OK; 23 | } 24 | 25 | HRESULT COpenCallbackGUI::SetCompleted(const UInt64 *files, const UInt64 *bytes) 26 | { 27 | return S_OK; 28 | } 29 | 30 | #ifndef _NO_CRYPTO 31 | HRESULT COpenCallbackGUI::CryptoGetTextPassword(BSTR *password) 32 | { 33 | if (!PasswordIsDefined) 34 | { 35 | CPasswordDialog dialog; 36 | if (dialog.Create(ParentWindow) == IDCANCEL) 37 | return E_ABORT; 38 | Password = dialog.Password; 39 | PasswordIsDefined = true; 40 | } 41 | CMyComBSTR tempName(Password); 42 | *password = tempName.Detach(); 43 | return S_OK; 44 | } 45 | 46 | HRESULT COpenCallbackGUI::GetPasswordIfAny(UString &password) 47 | { 48 | if (PasswordIsDefined) 49 | password = Password; 50 | return S_OK; 51 | } 52 | #endif 53 | 54 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/7zip/UI/GUI/OpenCallbackGUI.h: -------------------------------------------------------------------------------- 1 | // OpenCallbackGUI.h 2 | 3 | #ifndef __OPEN_CALLBACK_GUI_H 4 | #define __OPEN_CALLBACK_GUI_H 5 | 6 | #include "../Common/ArchiveOpenCallback.h" 7 | 8 | class COpenCallbackGUI: public IOpenCallbackUI 9 | { 10 | public: 11 | HRESULT CheckBreak(); 12 | HRESULT SetTotal(const UInt64 *files, const UInt64 *bytes); 13 | HRESULT SetCompleted(const UInt64 *files, const UInt64 *bytes); 14 | #ifndef _NO_CRYPTO 15 | HRESULT CryptoGetTextPassword(BSTR *password); 16 | HRESULT GetPasswordIfAny(UString &password); 17 | bool PasswordIsDefined; 18 | UString Password; 19 | #endif 20 | 21 | HWND ParentWindow; 22 | 23 | COpenCallbackGUI(): 24 | #ifndef _NO_CRYPTO 25 | PasswordIsDefined(false), 26 | #endif 27 | ParentWindow(0) {} 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/Alloc.h: -------------------------------------------------------------------------------- 1 | // Common/Alloc.h 2 | 3 | #ifndef __COMMON_ALLOC_H 4 | #define __COMMON_ALLOC_H 5 | 6 | #include 7 | 8 | void *MyAlloc(size_t size) throw(); 9 | void MyFree(void *address) throw(); 10 | 11 | #ifdef _WIN32 12 | 13 | bool SetLargePageSize(); 14 | 15 | void *MidAlloc(size_t size) throw(); 16 | void MidFree(void *address) throw(); 17 | void *BigAlloc(size_t size) throw(); 18 | void BigFree(void *address) throw(); 19 | 20 | #else 21 | 22 | #define MidAlloc(size) MyAlloc(size) 23 | #define MidFree(address) MyFree(address) 24 | #define BigAlloc(size) MyAlloc(size) 25 | #define BigFree(address) MyFree(address) 26 | 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/Buffer.h: -------------------------------------------------------------------------------- 1 | // Common/Buffer.h 2 | 3 | #ifndef __COMMON_BUFFER_H 4 | #define __COMMON_BUFFER_H 5 | 6 | #include "Defs.h" 7 | 8 | template class CBuffer 9 | { 10 | protected: 11 | size_t _capacity; 12 | T *_items; 13 | void Free() 14 | { 15 | delete []_items; 16 | _items = 0; 17 | _capacity = 0; 18 | } 19 | public: 20 | CBuffer(): _capacity(0), _items(0) {}; 21 | CBuffer(const CBuffer &buffer): _capacity(0), _items(0) { *this = buffer; } 22 | CBuffer(size_t size): _items(0), _capacity(0) { SetCapacity(size); } 23 | virtual ~CBuffer() { delete []_items; } 24 | operator T *() { return _items; }; 25 | operator const T *() const { return _items; }; 26 | size_t GetCapacity() const { return _capacity; } 27 | void SetCapacity(size_t newCapacity) 28 | { 29 | if (newCapacity == _capacity) 30 | return; 31 | T *newBuffer; 32 | if (newCapacity > 0) 33 | { 34 | newBuffer = new T[newCapacity]; 35 | if(_capacity > 0) 36 | memmove(newBuffer, _items, MyMin(_capacity, newCapacity) * sizeof(T)); 37 | } 38 | else 39 | newBuffer = 0; 40 | delete []_items; 41 | _items = newBuffer; 42 | _capacity = newCapacity; 43 | } 44 | CBuffer& operator=(const CBuffer &buffer) 45 | { 46 | Free(); 47 | if(buffer._capacity > 0) 48 | { 49 | SetCapacity(buffer._capacity); 50 | memmove(_items, buffer._items, buffer._capacity * sizeof(T)); 51 | } 52 | return *this; 53 | } 54 | }; 55 | 56 | template 57 | bool operator==(const CBuffer& b1, const CBuffer& b2) 58 | { 59 | if (b1.GetCapacity() != b2.GetCapacity()) 60 | return false; 61 | for (size_t i = 0; i < b1.GetCapacity(); i++) 62 | if (b1[i] != b2[i]) 63 | return false; 64 | return true; 65 | } 66 | 67 | template 68 | bool operator!=(const CBuffer& b1, const CBuffer& b2) 69 | { 70 | return !(b1 == b2); 71 | } 72 | 73 | typedef CBuffer CCharBuffer; 74 | typedef CBuffer CWCharBuffer; 75 | typedef CBuffer CByteBuffer; 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/CRC.cpp: -------------------------------------------------------------------------------- 1 | // Common/CRC.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "CRC.h" 6 | 7 | static const UInt32 kCRCPoly = 0xEDB88320; 8 | 9 | UInt32 CCRC::Table[256]; 10 | 11 | void CCRC::InitTable() 12 | { 13 | for (UInt32 i = 0; i < 256; i++) 14 | { 15 | UInt32 r = i; 16 | for (int j = 0; j < 8; j++) 17 | if (r & 1) 18 | r = (r >> 1) ^ kCRCPoly; 19 | else 20 | r >>= 1; 21 | CCRC::Table[i] = r; 22 | } 23 | } 24 | 25 | class CCRCTableInit 26 | { 27 | public: 28 | CCRCTableInit() { CCRC::InitTable(); } 29 | } g_CRCTableInit; 30 | 31 | void CCRC::UpdateByte(Byte b) 32 | { 33 | _value = Table[((Byte)(_value)) ^ b] ^ (_value >> 8); 34 | } 35 | 36 | void CCRC::UpdateUInt16(UInt16 v) 37 | { 38 | UpdateByte(Byte(v)); 39 | UpdateByte(Byte(v >> 8)); 40 | } 41 | 42 | void CCRC::UpdateUInt32(UInt32 v) 43 | { 44 | for (int i = 0; i < 4; i++) 45 | UpdateByte((Byte)(v >> (8 * i))); 46 | } 47 | 48 | void CCRC::UpdateUInt64(UInt64 v) 49 | { 50 | for (int i = 0; i < 8; i++) 51 | UpdateByte((Byte)(v >> (8 * i))); 52 | } 53 | 54 | void CCRC::Update(const void *data, size_t size) 55 | { 56 | UInt32 v = _value; 57 | const Byte *p = (const Byte *)data; 58 | for (; size > 0 ; size--, p++) 59 | v = Table[((Byte)(v)) ^ *p] ^ (v >> 8); 60 | _value = v; 61 | } 62 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/CRC.h: -------------------------------------------------------------------------------- 1 | // Common/CRC.h 2 | 3 | #ifndef __COMMON_CRC_H 4 | #define __COMMON_CRC_H 5 | 6 | #include 7 | #include "Types.h" 8 | 9 | class CCRC 10 | { 11 | UInt32 _value; 12 | public: 13 | static UInt32 Table[256]; 14 | static void InitTable(); 15 | 16 | CCRC(): _value(0xFFFFFFFF){}; 17 | void Init() { _value = 0xFFFFFFFF; } 18 | void UpdateByte(Byte v); 19 | void UpdateUInt16(UInt16 v); 20 | void UpdateUInt32(UInt32 v); 21 | void UpdateUInt64(UInt64 v); 22 | void Update(const void *data, size_t size); 23 | UInt32 GetDigest() const { return _value ^ 0xFFFFFFFF; } 24 | static UInt32 CalculateDigest(const void *data, size_t size) 25 | { 26 | CCRC crc; 27 | crc.Update(data, size); 28 | return crc.GetDigest(); 29 | } 30 | static bool VerifyDigest(UInt32 digest, const void *data, size_t size) 31 | { 32 | return (CalculateDigest(data, size) == digest); 33 | } 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/ComTry.h: -------------------------------------------------------------------------------- 1 | // ComTry.h 2 | 3 | #ifndef __COM_TRY_H 4 | #define __COM_TRY_H 5 | 6 | #include "MyWindows.h" 7 | // #include "Exception.h" 8 | // #include "NewHandler.h" 9 | 10 | #define COM_TRY_BEGIN try { 11 | #define COM_TRY_END } catch(...) { return E_OUTOFMEMORY; } 12 | 13 | // catch(const CNewException &) { return E_OUTOFMEMORY; }\ 14 | // catch(const CSystemException &e) { return e.ErrorCode; }\ 15 | // catch(...) { return E_FAIL; } 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/CommandLineParser.h: -------------------------------------------------------------------------------- 1 | // Common/CommandLineParser.h 2 | 3 | #ifndef __COMMON_COMMANDLINEPARSER_H 4 | #define __COMMON_COMMANDLINEPARSER_H 5 | 6 | #include "Common/String.h" 7 | 8 | namespace NCommandLineParser { 9 | 10 | void SplitCommandLine(const UString &src, UString &dest1, UString &dest2); 11 | void SplitCommandLine(const UString &s, UStringVector &parts); 12 | 13 | namespace NSwitchType { 14 | enum EEnum 15 | { 16 | kSimple, 17 | kPostMinus, 18 | kLimitedPostString, 19 | kUnLimitedPostString, 20 | kPostChar 21 | }; 22 | } 23 | 24 | struct CSwitchForm 25 | { 26 | const wchar_t *IDString; 27 | NSwitchType::EEnum Type; 28 | bool Multi; 29 | int MinLen; 30 | int MaxLen; 31 | const wchar_t *PostCharSet; 32 | }; 33 | 34 | struct CSwitchResult 35 | { 36 | bool ThereIs; 37 | bool WithMinus; 38 | UStringVector PostStrings; 39 | int PostCharIndex; 40 | CSwitchResult(): ThereIs(false) {}; 41 | }; 42 | 43 | class CParser 44 | { 45 | int _numSwitches; 46 | CSwitchResult *_switches; 47 | bool ParseString(const UString &s, const CSwitchForm *switchForms); 48 | public: 49 | UStringVector NonSwitchStrings; 50 | CParser(int numSwitches); 51 | ~CParser(); 52 | void ParseStrings(const CSwitchForm *switchForms, 53 | const UStringVector &commandStrings); 54 | const CSwitchResult& operator[](size_t index) const; 55 | }; 56 | 57 | ///////////////////////////////// 58 | // Command parsing procedures 59 | 60 | struct CCommandForm 61 | { 62 | wchar_t *IDString; 63 | bool PostStringMode; 64 | }; 65 | 66 | // Returns: Index of form and postString; -1, if there is no match 67 | int ParseCommand(int numCommandForms, const CCommandForm *commandForms, 68 | const UString &commandString, UString &postString); 69 | 70 | } 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/Defs.h: -------------------------------------------------------------------------------- 1 | // Common/Defs.h 2 | 3 | #ifndef __COMMON_DEFS_H 4 | #define __COMMON_DEFS_H 5 | 6 | template inline T MyMin(T a, T b) 7 | { return a < b ? a : b; } 8 | template inline T MyMax(T a, T b) 9 | { return a > b ? a : b; } 10 | 11 | template inline int MyCompare(T a, T b) 12 | { return a < b ? -1 : (a == b ? 0 : 1); } 13 | 14 | inline int BoolToInt(bool value) 15 | { return (value ? 1: 0); } 16 | 17 | inline bool IntToBool(int value) 18 | { return (value != 0); } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/DynamicBuffer.h: -------------------------------------------------------------------------------- 1 | // Common/DynamicBuffer.h 2 | 3 | #ifndef __COMMON_DYNAMICBUFFER_H 4 | #define __COMMON_DYNAMICBUFFER_H 5 | 6 | #include "Buffer.h" 7 | 8 | template class CDynamicBuffer: public CBuffer 9 | { 10 | void GrowLength(size_t size) 11 | { 12 | size_t delta; 13 | if (this->_capacity > 64) 14 | delta = this->_capacity / 4; 15 | else if (this->_capacity > 8) 16 | delta = 16; 17 | else 18 | delta = 4; 19 | delta = MyMax(delta, size); 20 | SetCapacity(this->_capacity + delta); 21 | } 22 | public: 23 | CDynamicBuffer(): CBuffer() {}; 24 | CDynamicBuffer(const CDynamicBuffer &buffer): CBuffer(buffer) {}; 25 | CDynamicBuffer(size_t size): CBuffer(size) {}; 26 | CDynamicBuffer& operator=(const CDynamicBuffer &buffer) 27 | { 28 | this->Free(); 29 | if(buffer._capacity > 0) 30 | { 31 | SetCapacity(buffer._capacity); 32 | memmove(this->_items, buffer._items, buffer._capacity * sizeof(T)); 33 | } 34 | return *this; 35 | } 36 | void EnsureCapacity(size_t capacity) 37 | { 38 | if (this->_capacity < capacity) 39 | GrowLength(capacity - this->_capacity); 40 | } 41 | }; 42 | 43 | typedef CDynamicBuffer CCharDynamicBuffer; 44 | typedef CDynamicBuffer CWCharDynamicBuffer; 45 | typedef CDynamicBuffer CByteDynamicBuffer; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/IntToString.cpp: -------------------------------------------------------------------------------- 1 | // Common/IntToString.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "IntToString.h" 6 | 7 | void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base) 8 | { 9 | if (base < 2 || base > 36) 10 | { 11 | *s = L'\0'; 12 | return; 13 | } 14 | char temp[72]; 15 | int pos = 0; 16 | do 17 | { 18 | int delta = (int)(value % base); 19 | temp[pos++] = (delta < 10) ? ('0' + delta) : ('a' + (delta - 10)); 20 | value /= base; 21 | } 22 | while (value != 0); 23 | do 24 | *s++ = temp[--pos]; 25 | while(pos > 0); 26 | *s = '\0'; 27 | } 28 | 29 | void ConvertUInt64ToString(UInt64 value, wchar_t *s) 30 | { 31 | wchar_t temp[32]; 32 | int pos = 0; 33 | do 34 | { 35 | temp[pos++] = L'0' + (int)(value % 10); 36 | value /= 10; 37 | } 38 | while (value != 0); 39 | do 40 | *s++ = temp[--pos]; 41 | while(pos > 0); 42 | *s = L'\0'; 43 | } 44 | 45 | void ConvertInt64ToString(Int64 value, char *s) 46 | { 47 | if (value < 0) 48 | { 49 | *s++ = '-'; 50 | value = -value; 51 | } 52 | ConvertUInt64ToString(value, s); 53 | } 54 | 55 | void ConvertInt64ToString(Int64 value, wchar_t *s) 56 | { 57 | if (value < 0) 58 | { 59 | *s++ = L'-'; 60 | value = -value; 61 | } 62 | ConvertUInt64ToString(value, s); 63 | } 64 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/IntToString.h: -------------------------------------------------------------------------------- 1 | // Common/IntToString.h 2 | 3 | #ifndef __COMMON_INTTOSTRING_H 4 | #define __COMMON_INTTOSTRING_H 5 | 6 | #include 7 | #include "Types.h" 8 | 9 | void ConvertUInt64ToString(UInt64 value, char *s, UInt32 base = 10); 10 | void ConvertUInt64ToString(UInt64 value, wchar_t *s); 11 | 12 | void ConvertInt64ToString(Int64 value, char *s); 13 | void ConvertInt64ToString(Int64 value, wchar_t *s); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/MyUnknown.h: -------------------------------------------------------------------------------- 1 | // MyUnknown.h 2 | 3 | #ifndef __MYUNKNOWN_H 4 | #define __MYUNKNOWN_H 5 | 6 | #ifdef _WIN32 7 | 8 | #ifdef _WIN32_WCE 9 | #if (_WIN32_WCE > 300) 10 | #include 11 | #else 12 | #define MIDL_INTERFACE(x) struct 13 | #endif 14 | #else 15 | #include 16 | #endif 17 | 18 | #include 19 | 20 | #else 21 | #include "MyWindows.h" 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/MyWindows.cpp: -------------------------------------------------------------------------------- 1 | // MyWindows.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #ifndef _WIN32 6 | 7 | #include "MyWindows.h" 8 | #include "Types.h" 9 | #include 10 | 11 | static inline void *AllocateForBSTR(size_t cb) { return ::malloc(cb); } 12 | static inline void FreeForBSTR(void *pv) { ::free(pv);} 13 | 14 | static UINT MyStringLen(const wchar_t *s) 15 | { 16 | UINT i; 17 | for (i = 0; s[i] != '\0'; i++); 18 | return i; 19 | } 20 | 21 | BSTR SysAllocStringByteLen(LPCSTR psz, UINT len) 22 | { 23 | int realLen = len + sizeof(UINT) + sizeof(OLECHAR) + sizeof(OLECHAR); 24 | void *p = AllocateForBSTR(realLen); 25 | if (p == 0) 26 | return 0; 27 | *(UINT *)p = len; 28 | BSTR bstr = (BSTR)((UINT *)p + 1); 29 | memmove(bstr, psz, len); 30 | Byte *pb = ((Byte *)bstr) + len; 31 | for (int i = 0; i < sizeof(OLECHAR) * 2; i++) 32 | pb[i] = 0; 33 | return bstr; 34 | } 35 | 36 | BSTR SysAllocString(const OLECHAR *sz) 37 | { 38 | if (sz == 0) 39 | return 0; 40 | UINT strLen = MyStringLen(sz); 41 | UINT len = (strLen + 1) * sizeof(OLECHAR); 42 | void *p = AllocateForBSTR(len + sizeof(UINT)); 43 | if (p == 0) 44 | return 0; 45 | *(UINT *)p = strLen; 46 | BSTR bstr = (BSTR)((UINT *)p + 1); 47 | memmove(bstr, sz, len); 48 | return bstr; 49 | } 50 | 51 | void SysFreeString(BSTR bstr) 52 | { 53 | if (bstr != 0) 54 | FreeForBSTR((UINT *)bstr - 1); 55 | } 56 | 57 | UINT SysStringByteLen(BSTR bstr) 58 | { 59 | if (bstr == 0) 60 | return 0; 61 | return *((UINT *)bstr - 1); 62 | } 63 | 64 | UINT SysStringLen(BSTR bstr) 65 | { 66 | return SysStringByteLen(bstr) / sizeof(OLECHAR); 67 | } 68 | 69 | HRESULT VariantClear(VARIANTARG *prop) 70 | { 71 | if (prop->vt == VT_BSTR) 72 | SysFreeString(prop->bstrVal); 73 | prop->vt = VT_EMPTY; 74 | return S_OK; 75 | } 76 | 77 | HRESULT VariantCopy(VARIANTARG *dest, VARIANTARG *src) 78 | { 79 | HRESULT res = ::VariantClear(dest); 80 | if (res != S_OK) 81 | return res; 82 | if (src->vt == VT_BSTR) 83 | { 84 | dest->bstrVal = SysAllocStringByteLen((LPCSTR)src->bstrVal, 85 | SysStringByteLen(src->bstrVal)); 86 | if (dest->bstrVal == 0) 87 | return E_OUTOFMEMORY; 88 | dest->vt = VT_BSTR; 89 | } 90 | else 91 | *dest = *src; 92 | return S_OK; 93 | } 94 | 95 | LONG CompareFileTime(const FILETIME* ft1, const FILETIME* ft2) 96 | { 97 | if(ft1->dwHighDateTime < ft2->dwHighDateTime) 98 | return -1; 99 | if(ft1->dwHighDateTime > ft2->dwHighDateTime) 100 | return 1; 101 | if(ft1->dwLowDateTime < ft2->dwLowDateTime) 102 | return -1; 103 | if(ft1->dwLowDateTime > ft2->dwLowDateTime) 104 | return 1; 105 | return 0; 106 | } 107 | 108 | DWORD GetLastError() 109 | { 110 | return 0; 111 | } 112 | 113 | #endif 114 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/NewHandler.cpp: -------------------------------------------------------------------------------- 1 | // NewHandler.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include 6 | 7 | #include "NewHandler.h" 8 | 9 | // #define DEBUG_MEMORY_LEAK 10 | 11 | #ifndef DEBUG_MEMORY_LEAK 12 | 13 | #ifdef _WIN32 14 | void * 15 | #ifdef _MSC_VER 16 | __cdecl 17 | #endif 18 | operator new(size_t size) 19 | { 20 | // void *p = ::HeapAlloc(::GetProcessHeap(), 0, size); 21 | void *p = ::malloc(size); 22 | if (p == 0) 23 | throw CNewException(); 24 | return p; 25 | } 26 | 27 | void 28 | #ifdef _MSC_VER 29 | __cdecl 30 | #endif 31 | operator delete(void *p) throw() 32 | { 33 | /* 34 | if (p == 0) 35 | return; 36 | ::HeapFree(::GetProcessHeap(), 0, p); 37 | */ 38 | ::free(p); 39 | } 40 | #endif 41 | 42 | #else 43 | 44 | #pragma init_seg(lib) 45 | const int kDebugSize = 1000000; 46 | static void *a[kDebugSize]; 47 | static int index = 0; 48 | 49 | static int numAllocs = 0; 50 | void * __cdecl operator new(size_t size) 51 | { 52 | numAllocs++; 53 | void *p = HeapAlloc(GetProcessHeap(), 0, size); 54 | if (index == 40) 55 | { 56 | int t = 1; 57 | } 58 | if (index < kDebugSize) 59 | { 60 | a[index] = p; 61 | index++; 62 | } 63 | if (p == 0) 64 | throw CNewException(); 65 | printf("Alloc %6d, size = %8d\n", numAllocs, size); 66 | return p; 67 | } 68 | 69 | class CC 70 | { 71 | public: 72 | CC() 73 | { 74 | for (int i = 0; i < kDebugSize; i++) 75 | a[i] = 0; 76 | } 77 | ~CC() 78 | { 79 | for (int i = 0; i < kDebugSize; i++) 80 | if (a[i] != 0) 81 | return; 82 | } 83 | } g_CC; 84 | 85 | 86 | void __cdecl operator delete(void *p) 87 | { 88 | if (p == 0) 89 | return; 90 | /* 91 | for (int i = 0; i < index; i++) 92 | if (a[i] == p) 93 | a[i] = 0; 94 | */ 95 | HeapFree(GetProcessHeap(), 0, p); 96 | numAllocs--; 97 | printf("Free %d\n", numAllocs); 98 | } 99 | 100 | #endif 101 | 102 | /* 103 | int MemErrorVC(size_t) 104 | { 105 | throw CNewException(); 106 | // return 1; 107 | } 108 | CNewHandlerSetter::CNewHandlerSetter() 109 | { 110 | // MemErrorOldVCFunction = _set_new_handler(MemErrorVC); 111 | } 112 | CNewHandlerSetter::~CNewHandlerSetter() 113 | { 114 | // _set_new_handler(MemErrorOldVCFunction); 115 | } 116 | */ 117 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/NewHandler.h: -------------------------------------------------------------------------------- 1 | // Common/NewHandler.h 2 | 3 | #ifndef __COMMON_NEWHANDLER_H 4 | #define __COMMON_NEWHANDLER_H 5 | 6 | class CNewException {}; 7 | 8 | #ifdef _WIN32 9 | void 10 | #ifdef _MSC_VER 11 | __cdecl 12 | #endif 13 | operator delete(void *p) throw(); 14 | #endif 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/Random.cpp: -------------------------------------------------------------------------------- 1 | // Common/Random.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include 6 | #include 7 | 8 | #include "Common/Random.h" 9 | 10 | void CRandom::Init(unsigned int seed) 11 | { srand(seed); } 12 | 13 | void CRandom::Init() 14 | { Init((unsigned int)time(NULL)); } 15 | 16 | int CRandom::Generate() const 17 | { return rand(); } 18 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/Random.h: -------------------------------------------------------------------------------- 1 | // Common/Random.h 2 | 3 | #ifndef __COMMON_RANDOM_H 4 | #define __COMMON_RANDOM_H 5 | 6 | class CRandom 7 | { 8 | public: 9 | void Init(); 10 | void Init(unsigned int seed); 11 | int Generate() const; 12 | }; 13 | 14 | #endif 15 | 16 | 17 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/StdInStream.cpp: -------------------------------------------------------------------------------- 1 | // Common/StdInStream.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include 6 | #include "StdInStream.h" 7 | 8 | static const char kIllegalChar = '\0'; 9 | static const char kNewLineChar = '\n'; 10 | 11 | static const char *kEOFMessage = "Unexpected end of input stream"; 12 | static const char *kReadErrorMessage ="Error reading input stream"; 13 | static const char *kIllegalCharMessage = "Illegal character in input stream"; 14 | 15 | static LPCTSTR kFileOpenMode = TEXT("r"); 16 | 17 | CStdInStream g_StdIn(stdin); 18 | 19 | bool CStdInStream::Open(LPCTSTR fileName) 20 | { 21 | Close(); 22 | _stream = _tfopen(fileName, kFileOpenMode); 23 | _streamIsOpen = (_stream != 0); 24 | return _streamIsOpen; 25 | } 26 | 27 | bool CStdInStream::Close() 28 | { 29 | if(!_streamIsOpen) 30 | return true; 31 | _streamIsOpen = (fclose(_stream) != 0); 32 | return !_streamIsOpen; 33 | } 34 | 35 | CStdInStream::~CStdInStream() 36 | { 37 | Close(); 38 | } 39 | 40 | AString CStdInStream::ScanStringUntilNewLine() 41 | { 42 | AString s; 43 | while(true) 44 | { 45 | int intChar = GetChar(); 46 | if(intChar == EOF) 47 | throw kEOFMessage; 48 | char c = char(intChar); 49 | if (c == kIllegalChar) 50 | throw kIllegalCharMessage; 51 | if(c == kNewLineChar) 52 | return s; 53 | s += c; 54 | } 55 | } 56 | 57 | void CStdInStream::ReadToString(AString &resultString) 58 | { 59 | resultString.Empty(); 60 | int c; 61 | while((c = GetChar()) != EOF) 62 | resultString += char(c); 63 | } 64 | 65 | bool CStdInStream::Eof() 66 | { 67 | return (feof(_stream) != 0); 68 | } 69 | 70 | int CStdInStream::GetChar() 71 | { 72 | int c = getc(_stream); 73 | if(c == EOF && !Eof()) 74 | throw kReadErrorMessage; 75 | return c; 76 | } 77 | 78 | 79 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/StdInStream.h: -------------------------------------------------------------------------------- 1 | // Common/StdInStream.h 2 | 3 | #ifndef __COMMON_STDINSTREAM_H 4 | #define __COMMON_STDINSTREAM_H 5 | 6 | #include 7 | 8 | #include "Common/String.h" 9 | #include "Types.h" 10 | 11 | class CStdInStream 12 | { 13 | bool _streamIsOpen; 14 | FILE *_stream; 15 | public: 16 | CStdInStream(): _streamIsOpen(false) {}; 17 | CStdInStream(FILE *stream): _streamIsOpen(false), _stream(stream) {}; 18 | ~CStdInStream(); 19 | bool Open(LPCTSTR fileName); 20 | bool Close(); 21 | 22 | AString ScanStringUntilNewLine(); 23 | void ReadToString(AString &resultString); 24 | 25 | bool Eof(); 26 | int GetChar(); 27 | }; 28 | 29 | extern CStdInStream g_StdIn; 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/StdOutStream.cpp: -------------------------------------------------------------------------------- 1 | // Common/StdOutStream.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include 6 | 7 | #include "StdOutStream.h" 8 | #include "Common/IntToString.h" 9 | #include "Common/StringConvert.h" 10 | 11 | static const char kNewLineChar = '\n'; 12 | 13 | static const char *kFileOpenMode = "wt"; 14 | 15 | CStdOutStream g_StdOut(stdout); 16 | CStdOutStream g_StdErr(stderr); 17 | 18 | bool CStdOutStream::Open(const char *fileName) 19 | { 20 | Close(); 21 | _stream = fopen(fileName, kFileOpenMode); 22 | _streamIsOpen = (_stream != 0); 23 | return _streamIsOpen; 24 | } 25 | 26 | bool CStdOutStream::Close() 27 | { 28 | if(!_streamIsOpen) 29 | return true; 30 | _streamIsOpen = (fclose(_stream) != 0); 31 | return !_streamIsOpen; 32 | } 33 | 34 | bool CStdOutStream::Flush() 35 | { 36 | if(!_streamIsOpen) 37 | return false; 38 | return (fflush(_stream) == 0); 39 | } 40 | 41 | CStdOutStream::~CStdOutStream () 42 | { 43 | Close(); 44 | } 45 | 46 | CStdOutStream & CStdOutStream::operator<<(CStdOutStream & (*aFunction)(CStdOutStream &)) 47 | { 48 | (*aFunction)(*this); 49 | return *this; 50 | } 51 | 52 | CStdOutStream & endl(CStdOutStream & outStream) 53 | { 54 | return outStream << kNewLineChar; 55 | } 56 | 57 | CStdOutStream & CStdOutStream::operator<<(const char *string) 58 | { 59 | fputs(string, _stream); 60 | return *this; 61 | } 62 | 63 | CStdOutStream & CStdOutStream::operator<<(const wchar_t *string) 64 | { 65 | *this << (const char *)UnicodeStringToMultiByte(string, CP_OEMCP); 66 | return *this; 67 | } 68 | 69 | CStdOutStream & CStdOutStream::operator<<(char c) 70 | { 71 | fputc(c, _stream); 72 | return *this; 73 | } 74 | 75 | CStdOutStream & CStdOutStream::operator<<(int number) 76 | { 77 | char textString[32]; 78 | ConvertInt64ToString(number, textString); 79 | return operator<<(textString); 80 | } 81 | 82 | CStdOutStream & CStdOutStream::operator<<(UInt64 number) 83 | { 84 | char textString[32]; 85 | ConvertUInt64ToString(number, textString); 86 | return operator<<(textString); 87 | } 88 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/StdOutStream.h: -------------------------------------------------------------------------------- 1 | // Common/StdOutStream.h 2 | 3 | #ifndef __COMMON_STDOUTSTREAM_H 4 | #define __COMMON_STDOUTSTREAM_H 5 | 6 | #include 7 | 8 | #include "Types.h" 9 | 10 | class CStdOutStream 11 | { 12 | bool _streamIsOpen; 13 | FILE *_stream; 14 | public: 15 | CStdOutStream (): _streamIsOpen(false) {}; 16 | CStdOutStream (FILE *stream): _streamIsOpen(false), _stream(stream) {}; 17 | ~CStdOutStream (); 18 | bool Open(const char *fileName); 19 | bool Close(); 20 | bool Flush(); 21 | 22 | CStdOutStream & operator<<(CStdOutStream & (* aFunction)(CStdOutStream &)); 23 | CStdOutStream & operator<<(const char *string); 24 | CStdOutStream & operator<<(const wchar_t *string); 25 | CStdOutStream & operator<<(char c); 26 | CStdOutStream & operator<<(int number); 27 | CStdOutStream & operator<<(UInt64 number); 28 | }; 29 | 30 | CStdOutStream & endl(CStdOutStream & outStream); 31 | 32 | extern CStdOutStream g_StdOut; 33 | extern CStdOutStream g_StdErr; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/StringConvert.cpp: -------------------------------------------------------------------------------- 1 | // Common/StringConvert.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "StringConvert.h" 6 | 7 | #ifndef _WIN32 8 | #include 9 | #endif 10 | 11 | #ifdef _WIN32 12 | UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) 13 | { 14 | UString resultString; 15 | if(!srcString.IsEmpty()) 16 | { 17 | int numChars = MultiByteToWideChar(codePage, 0, srcString, 18 | srcString.Length(), resultString.GetBuffer(srcString.Length()), 19 | srcString.Length() + 1); 20 | #ifndef _WIN32_WCE 21 | if(numChars == 0) 22 | throw 282228; 23 | #endif 24 | resultString.ReleaseBuffer(numChars); 25 | } 26 | return resultString; 27 | } 28 | 29 | AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage) 30 | { 31 | AString resultString; 32 | if(!srcString.IsEmpty()) 33 | { 34 | int numRequiredBytes = srcString.Length() * 2; 35 | int numChars = WideCharToMultiByte(codePage, 0, srcString, 36 | srcString.Length(), resultString.GetBuffer(numRequiredBytes), 37 | numRequiredBytes + 1, NULL, NULL); 38 | #ifndef _WIN32_WCE 39 | if(numChars == 0) 40 | throw 282229; 41 | #endif 42 | resultString.ReleaseBuffer(numChars); 43 | } 44 | return resultString; 45 | } 46 | 47 | #ifndef _WIN32_WCE 48 | AString SystemStringToOemString(const CSysString &srcString) 49 | { 50 | AString result; 51 | CharToOem(srcString, result.GetBuffer(srcString.Length() * 2)); 52 | result.ReleaseBuffer(); 53 | return result; 54 | } 55 | #endif 56 | 57 | #else 58 | 59 | UString MultiByteToUnicodeString(const AString &srcString, UINT codePage) 60 | { 61 | UString resultString; 62 | for (int i = 0; i < srcString.Length(); i++) 63 | resultString += wchar_t(srcString[i]); 64 | /* 65 | if(!srcString.IsEmpty()) 66 | { 67 | int numChars = mbstowcs(resultString.GetBuffer(srcString.Length()), srcString, srcString.Length() + 1); 68 | if (numChars < 0) throw "Your environment does not support UNICODE"; 69 | resultString.ReleaseBuffer(numChars); 70 | } 71 | */ 72 | return resultString; 73 | } 74 | 75 | AString UnicodeStringToMultiByte(const UString &srcString, UINT codePage) 76 | { 77 | AString resultString; 78 | for (int i = 0; i < srcString.Length(); i++) 79 | resultString += char(srcString[i]); 80 | /* 81 | if(!srcString.IsEmpty()) 82 | { 83 | int numRequiredBytes = srcString.Length() * 6 + 1; 84 | int numChars = wcstombs(resultString.GetBuffer(numRequiredBytes), srcString, numRequiredBytes); 85 | if (numChars < 0) throw "Your environment does not support UNICODE"; 86 | resultString.ReleaseBuffer(numChars); 87 | } 88 | */ 89 | return resultString; 90 | } 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/TextConfig.h: -------------------------------------------------------------------------------- 1 | // Common/TextConfig.h 2 | 3 | #ifndef __COMMON_TEXTCONFIG_H 4 | #define __COMMON_TEXTCONFIG_H 5 | 6 | #include "Common/Vector.h" 7 | #include "Common/String.h" 8 | 9 | struct CTextConfigPair 10 | { 11 | UString ID; 12 | UString String; 13 | }; 14 | 15 | bool GetTextConfig(const AString &text, CObjectVector &pairs); 16 | 17 | int FindTextConfigItem(const CObjectVector &pairs, const UString &id); 18 | UString GetTextConfigValue(const CObjectVector &pairs, const UString &id); 19 | 20 | #endif 21 | 22 | 23 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/Types.h: -------------------------------------------------------------------------------- 1 | // Common/Types.h 2 | 3 | #ifndef __COMMON_TYPES_H 4 | #define __COMMON_TYPES_H 5 | 6 | typedef unsigned char Byte; 7 | typedef short Int16; 8 | typedef unsigned short UInt16; 9 | typedef int Int32; 10 | typedef unsigned int UInt32; 11 | #ifdef _MSC_VER 12 | typedef __int64 Int64; 13 | typedef unsigned __int64 UInt64; 14 | #else 15 | typedef long long int Int64; 16 | typedef unsigned long long int UInt64; 17 | #endif 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/UTFConvert.cpp: -------------------------------------------------------------------------------- 1 | // UTFConvert.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "UTFConvert.h" 6 | #include "Types.h" 7 | 8 | static Byte kUtf8Limits[5] = { 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; 9 | 10 | // These functions are for UTF8 <-> UTF16 conversion. 11 | 12 | bool ConvertUTF8ToUnicode(const AString &src, UString &dest) 13 | { 14 | dest.Empty(); 15 | for(int i = 0; i < src.Length();) 16 | { 17 | Byte c = (Byte)src[i++]; 18 | if (c < 0x80) 19 | { 20 | dest += (wchar_t)c; 21 | continue; 22 | } 23 | if(c < 0xC0) 24 | return false; 25 | int numAdds; 26 | for (numAdds = 1; numAdds < 5; numAdds++) 27 | if (c < kUtf8Limits[numAdds]) 28 | break; 29 | UInt32 value = (c - kUtf8Limits[numAdds - 1]); 30 | do 31 | { 32 | if (i >= src.Length()) 33 | return false; 34 | Byte c2 = (Byte)src[i++]; 35 | if (c2 < 0x80 || c2 >= 0xC0) 36 | return false; 37 | value <<= 6; 38 | value |= (c2 - 0x80); 39 | numAdds--; 40 | } 41 | while(numAdds > 0); 42 | if (value < 0x10000) 43 | dest += (wchar_t)(value); 44 | else 45 | { 46 | value -= 0x10000; 47 | if (value >= 0x100000) 48 | return false; 49 | dest += (wchar_t)(0xD800 + (value >> 10)); 50 | dest += (wchar_t)(0xDC00 + (value & 0x3FF)); 51 | } 52 | } 53 | return true; 54 | } 55 | 56 | bool ConvertUnicodeToUTF8(const UString &src, AString &dest) 57 | { 58 | dest.Empty(); 59 | for(int i = 0; i < src.Length();) 60 | { 61 | UInt32 value = (UInt32)src[i++]; 62 | if (value < 0x80) 63 | { 64 | dest += (char)value; 65 | continue; 66 | } 67 | if (value >= 0xD800 && value < 0xE000) 68 | { 69 | if (value >= 0xDC00) 70 | return false; 71 | if (i >= src.Length()) 72 | return false; 73 | UInt32 c2 = (UInt32)src[i++]; 74 | if (c2 < 0xDC00 || c2 >= 0xE000) 75 | return false; 76 | value = ((value - 0xD800) << 10) | (c2 - 0xDC00); 77 | } 78 | int numAdds; 79 | for (numAdds = 1; numAdds < 5; numAdds++) 80 | if (value < (((UInt32)1) << (numAdds * 5 + 6))) 81 | break; 82 | dest += (char)(kUtf8Limits[numAdds - 1] + (value >> (6 * numAdds))); 83 | do 84 | { 85 | numAdds--; 86 | dest += (char)(0x80 + ((value >> (6 * numAdds)) & 0x3F)); 87 | } 88 | while(numAdds > 0); 89 | } 90 | return true; 91 | } 92 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/UTFConvert.h: -------------------------------------------------------------------------------- 1 | // Common/UTFConvert.h 2 | 3 | #ifndef __COMMON_UTFCONVERT_H 4 | #define __COMMON_UTFCONVERT_H 5 | 6 | #include "Common/String.h" 7 | 8 | bool ConvertUTF8ToUnicode(const AString &utfString, UString &resultString); 9 | bool ConvertUnicodeToUTF8(const UString &unicodeString, AString &resultString); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/Vector.cpp: -------------------------------------------------------------------------------- 1 | // Common/Vector.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include 6 | 7 | #include "Vector.h" 8 | 9 | CBaseRecordVector::~CBaseRecordVector() 10 | { delete []((unsigned char *)_items); } 11 | void CBaseRecordVector::Clear() 12 | { DeleteFrom(0); } 13 | void CBaseRecordVector::DeleteBack() 14 | { Delete(_size - 1); } 15 | void CBaseRecordVector::DeleteFrom(int index) 16 | { Delete(index, _size - index); } 17 | 18 | void CBaseRecordVector::ReserveOnePosition() 19 | { 20 | if(_size != _capacity) 21 | return; 22 | int delta; 23 | if (_capacity > 64) 24 | delta = _capacity / 2; 25 | else if (_capacity > 8) 26 | delta = 8; 27 | else 28 | delta = 4; 29 | Reserve(_capacity + delta); 30 | } 31 | 32 | void CBaseRecordVector::Reserve(int newCapacity) 33 | { 34 | if(newCapacity <= _capacity) 35 | return; 36 | /* 37 | #ifndef _DEBUG 38 | static const unsigned int kMaxVectorSize = 0xF0000000; 39 | if(newCapacity < _size || 40 | ((unsigned int )newCapacity * (unsigned int )_itemSize) > kMaxVectorSize) 41 | throw 1052354; 42 | #endif 43 | */ 44 | unsigned char *p = new unsigned char[newCapacity * _itemSize]; 45 | int numRecordsToMove = _capacity; 46 | memmove(p, _items, _itemSize * numRecordsToMove); 47 | delete [](unsigned char *)_items; 48 | _items = p; 49 | _capacity = newCapacity; 50 | } 51 | 52 | void CBaseRecordVector::MoveItems(int destIndex, int srcIndex) 53 | { 54 | memmove(((unsigned char *)_items) + destIndex * _itemSize, 55 | ((unsigned char *)_items) + srcIndex * _itemSize, 56 | _itemSize * (_size - srcIndex)); 57 | } 58 | 59 | void CBaseRecordVector::InsertOneItem(int index) 60 | { 61 | ReserveOnePosition(); 62 | MoveItems(index + 1, index); 63 | _size++; 64 | } 65 | 66 | void CBaseRecordVector::Delete(int index, int num) 67 | { 68 | TestIndexAndCorrectNum(index, num); 69 | if (num > 0) 70 | { 71 | MoveItems(index, index + num); 72 | _size -= num; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Common/Wildcard.h: -------------------------------------------------------------------------------- 1 | // Common/Wildcard.h 2 | 3 | #ifndef __COMMON_WILDCARD_H 4 | #define __COMMON_WILDCARD_H 5 | 6 | #include "Common/String.h" 7 | 8 | void SplitPathToParts(const UString &path, UStringVector &pathParts); 9 | void SplitPathToParts(const UString &path, UString &dirPrefix, UString &name); 10 | UString ExtractDirPrefixFromPath(const UString &path); 11 | UString ExtractFileNameFromPath(const UString &path); 12 | bool DoesNameContainWildCard(const UString &path); 13 | bool CompareWildCardWithName(const UString &mask, const UString &name); 14 | 15 | namespace NWildcard { 16 | 17 | struct CItem 18 | { 19 | UStringVector PathParts; 20 | bool Recursive; 21 | bool ForFile; 22 | bool ForDir; 23 | bool CheckPath(const UStringVector &pathParts, bool isFile) const; 24 | }; 25 | 26 | class CCensorNode 27 | { 28 | CCensorNode *Parent; 29 | bool CheckPathCurrent(bool include, const UStringVector &pathParts, bool isFile) const; 30 | void AddItemSimple(bool include, CItem &item); 31 | bool CheckPath(UStringVector &pathParts, bool isFile, bool &include) const; 32 | public: 33 | CCensorNode(): Parent(0) { }; 34 | CCensorNode(const UString &name, CCensorNode *parent): Name(name), Parent(parent) { }; 35 | UString Name; 36 | CObjectVector SubNodes; 37 | CObjectVector IncludeItems; 38 | CObjectVector ExcludeItems; 39 | 40 | int FindSubNode(const UString &path) const; 41 | 42 | void AddItem(bool include, CItem &item); 43 | void AddItem(bool include, const UString &path, bool recursive, bool forFile, bool forDir); 44 | void AddItem2(bool include, const UString &path, bool recursive); 45 | 46 | bool NeedCheckSubDirs() const; 47 | bool AreThereIncludeItems() const; 48 | 49 | bool CheckPath(const UString &path, bool isFile, bool &include) const; 50 | bool CheckPath(const UString &path, bool isFile) const; 51 | 52 | bool CheckPathToRoot(bool include, UStringVector &pathParts, bool isFile) const; 53 | // bool CheckPathToRoot(const UString &path, bool isFile, bool include) const; 54 | void ExtendExclude(const CCensorNode &fromNodes); 55 | }; 56 | 57 | struct CPair 58 | { 59 | UString Prefix; 60 | CCensorNode Head; 61 | CPair(const UString &prefix): Prefix(prefix) { }; 62 | }; 63 | 64 | class CCensor 65 | { 66 | int FindPrefix(const UString &prefix) const; 67 | public: 68 | CObjectVector Pairs; 69 | bool AllAreRelative() const 70 | { return (Pairs.Size() == 1 && Pairs.Front().Prefix.IsEmpty()); } 71 | void AddItem(bool include, const UString &path, bool recursive); 72 | bool CheckPath(const UString &path, bool isFile) const; 73 | void ExtendExclude(); 74 | }; 75 | 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/COM.cpp: -------------------------------------------------------------------------------- 1 | // Windows/COM.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "Windows/COM.h" 6 | #include "Common/StringConvert.h" 7 | 8 | namespace NWindows { 9 | namespace NCOM { 10 | 11 | // CoInitialize (NULL); must be called! 12 | 13 | UString GUIDToStringW(REFGUID guid) 14 | { 15 | UString string; 16 | const int kStringSize = 48; 17 | StringFromGUID2(guid, string.GetBuffer(kStringSize), kStringSize); 18 | string.ReleaseBuffer(); 19 | return string; 20 | } 21 | 22 | AString GUIDToStringA(REFGUID guid) 23 | { 24 | return UnicodeStringToMultiByte(GUIDToStringW(guid)); 25 | } 26 | 27 | HRESULT StringToGUIDW(const wchar_t *string, GUID &classID) 28 | { 29 | return CLSIDFromString((wchar_t *)string, &classID); 30 | } 31 | 32 | HRESULT StringToGUIDA(const char *string, GUID &classID) 33 | { 34 | return StringToGUIDW(MultiByteToUnicodeString(string), classID); 35 | } 36 | 37 | }} -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/COM.h: -------------------------------------------------------------------------------- 1 | // Windows/COM.h 2 | 3 | #ifndef __WINDOWS_COM_H 4 | #define __WINDOWS_COM_H 5 | 6 | #include "Common/String.h" 7 | 8 | namespace NWindows { 9 | namespace NCOM { 10 | 11 | class CComInitializer 12 | { 13 | public: 14 | CComInitializer() { CoInitialize(NULL);}; 15 | ~CComInitializer() { CoUninitialize(); }; 16 | }; 17 | 18 | class CStgMedium 19 | { 20 | STGMEDIUM _object; 21 | public: 22 | bool _mustBeReleased; 23 | CStgMedium(): _mustBeReleased(false) {} 24 | ~CStgMedium() { Free(); } 25 | void Free() 26 | { 27 | if(_mustBeReleased) 28 | ReleaseStgMedium(&_object); 29 | _mustBeReleased = false; 30 | } 31 | const STGMEDIUM* operator->() const { return &_object;} 32 | STGMEDIUM* operator->() { return &_object;} 33 | STGMEDIUM* operator&() { return &_object; } 34 | }; 35 | 36 | ////////////////////////////////// 37 | // GUID <--> String Conversions 38 | UString GUIDToStringW(REFGUID guid); 39 | AString GUIDToStringA(REFGUID guid); 40 | #ifdef UNICODE 41 | #define GUIDToString GUIDToStringW 42 | #else 43 | #define GUIDToString GUIDToStringA 44 | #endif // !UNICODE 45 | 46 | HRESULT StringToGUIDW(const wchar_t *string, GUID &classID); 47 | HRESULT StringToGUIDA(const char *string, GUID &classID); 48 | #ifdef UNICODE 49 | #define StringToGUID StringToGUIDW 50 | #else 51 | #define StringToGUID StringToGUIDA 52 | #endif // !UNICODE 53 | 54 | 55 | }} 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/Control/ProgressBar.h: -------------------------------------------------------------------------------- 1 | // Windows/Control/ProgressBar.h 2 | 3 | #ifndef __WINDOWS_CONTROL_PROGRESSBAR_H 4 | #define __WINDOWS_CONTROL_PROGRESSBAR_H 5 | 6 | #include "Windows/Window.h" 7 | #include "Windows/Defs.h" 8 | 9 | namespace NWindows { 10 | namespace NControl { 11 | 12 | class CProgressBar: public CWindow 13 | { 14 | public: 15 | LRESULT SetPos(int pos) 16 | { return SendMessage(PBM_SETPOS, pos, 0); } 17 | LRESULT DeltaPos(int increment) 18 | { return SendMessage(PBM_DELTAPOS, increment, 0); } 19 | UINT GetPos() 20 | { return SendMessage(PBM_GETPOS, 0, 0); } 21 | LRESULT SetRange(unsigned short minValue, unsigned short maxValue) 22 | { return SendMessage(PBM_SETRANGE, 0, MAKELPARAM(minValue, maxValue)); } 23 | DWORD SetRange32(int minValue, int maxValue) 24 | { return SendMessage(PBM_SETRANGE32, minValue, maxValue); } 25 | int SetStep(int aStep) 26 | { return SendMessage(PBM_SETSTEP, aStep, 0); } 27 | int StepIt() 28 | { return SendMessage(PBM_STEPIT, 0, 0); } 29 | 30 | int GetRange(bool minValue, PPBRANGE range) 31 | { return SendMessage(PBM_GETRANGE, BoolToBOOL(minValue), (LPARAM)range); } 32 | 33 | COLORREF SetBarColor(COLORREF color) 34 | { return SendMessage(PBM_SETBARCOLOR, 0, color); } 35 | COLORREF SetBackgroundColor(COLORREF color) 36 | { return SendMessage(PBM_SETBKCOLOR, 0, color); } 37 | }; 38 | 39 | }} 40 | 41 | #endif -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/DLL.cpp: -------------------------------------------------------------------------------- 1 | // Windows/DLL.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "DLL.h" 6 | #include "Defs.h" 7 | #ifndef _UNICODE 8 | #include "../Common/StringConvert.h" 9 | #endif 10 | 11 | #ifndef _UNICODE 12 | extern bool g_IsNT; 13 | #endif 14 | 15 | namespace NWindows { 16 | namespace NDLL { 17 | 18 | CLibrary::~CLibrary() 19 | { 20 | Free(); 21 | } 22 | 23 | bool CLibrary::Free() 24 | { 25 | if (_module == 0) 26 | return true; 27 | // MessageBox(0, TEXT(""), TEXT("Free"), 0); 28 | // Sleep(5000); 29 | if (!::FreeLibrary(_module)) 30 | return false; 31 | _module = 0; 32 | return true; 33 | } 34 | 35 | bool CLibrary::LoadOperations(HMODULE newModule) 36 | { 37 | if (newModule == NULL) 38 | return false; 39 | if(!Free()) 40 | return false; 41 | _module = newModule; 42 | return true; 43 | } 44 | 45 | bool CLibrary::LoadEx(LPCTSTR fileName, DWORD flags) 46 | { 47 | // MessageBox(0, fileName, TEXT("LoadEx"), 0); 48 | return LoadOperations(::LoadLibraryEx(fileName, NULL, flags)); 49 | } 50 | 51 | bool CLibrary::Load(LPCTSTR fileName) 52 | { 53 | // MessageBox(0, fileName, TEXT("Load"), 0); 54 | // Sleep(5000); 55 | // OutputDebugString(fileName); 56 | // OutputDebugString(TEXT("\n")); 57 | return LoadOperations(::LoadLibrary(fileName)); 58 | } 59 | 60 | #ifndef _UNICODE 61 | static inline UINT GetCurrentCodePage() { return ::AreFileApisANSI() ? CP_ACP : CP_OEMCP; } 62 | CSysString GetSysPath(LPCWSTR sysPath) 63 | { return UnicodeStringToMultiByte(sysPath, GetCurrentCodePage()); } 64 | 65 | bool CLibrary::LoadEx(LPCWSTR fileName, DWORD flags) 66 | { 67 | if (g_IsNT) 68 | return LoadOperations(::LoadLibraryExW(fileName, NULL, flags)); 69 | return LoadEx(GetSysPath(fileName), flags); 70 | } 71 | bool CLibrary::Load(LPCWSTR fileName) 72 | { 73 | if (g_IsNT) 74 | return LoadOperations(::LoadLibraryW(fileName)); 75 | return Load(GetSysPath(fileName)); 76 | } 77 | #endif 78 | 79 | bool MyGetModuleFileName(HMODULE hModule, CSysString &result) 80 | { 81 | result.Empty(); 82 | TCHAR fullPath[MAX_PATH + 2]; 83 | DWORD size = ::GetModuleFileName(hModule, fullPath, MAX_PATH + 1); 84 | if (size <= MAX_PATH && size != 0) 85 | { 86 | result = fullPath; 87 | return true; 88 | } 89 | return false; 90 | } 91 | 92 | #ifndef _UNICODE 93 | bool MyGetModuleFileName(HMODULE hModule, UString &result) 94 | { 95 | result.Empty(); 96 | if (g_IsNT) 97 | { 98 | wchar_t fullPath[MAX_PATH + 2]; 99 | DWORD size = ::GetModuleFileNameW(hModule, fullPath, MAX_PATH + 1); 100 | if (size <= MAX_PATH && size != 0) 101 | { 102 | result = fullPath; 103 | return true; 104 | } 105 | return false; 106 | } 107 | CSysString resultSys; 108 | if (!MyGetModuleFileName(hModule, resultSys)) 109 | return false; 110 | result = MultiByteToUnicodeString(resultSys, GetCurrentCodePage()); 111 | return true; 112 | } 113 | #endif 114 | 115 | }} 116 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/DLL.h: -------------------------------------------------------------------------------- 1 | // Windows/DLL.h 2 | 3 | #ifndef __WINDOWS_DLL_H 4 | #define __WINDOWS_DLL_H 5 | 6 | #include "../Common/String.h" 7 | 8 | namespace NWindows { 9 | namespace NDLL { 10 | 11 | class CLibrary 12 | { 13 | bool LoadOperations(HMODULE newModule); 14 | protected: 15 | HMODULE _module; 16 | public: 17 | operator HMODULE() const { return _module; } 18 | HMODULE* operator&() { return &_module; } 19 | 20 | CLibrary():_module(NULL) {}; 21 | ~CLibrary(); 22 | void Attach(HMODULE m) 23 | { 24 | Free(); 25 | _module = m; 26 | } 27 | HMODULE Detach() 28 | { 29 | HMODULE m = _module; 30 | _module = NULL; 31 | return m; 32 | } 33 | 34 | // operator HMODULE() const { return _module; }; 35 | // bool IsLoaded() const { return (_module != NULL); }; 36 | bool Free(); 37 | bool LoadEx(LPCTSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE); 38 | bool Load(LPCTSTR fileName); 39 | #ifndef _UNICODE 40 | bool LoadEx(LPCWSTR fileName, DWORD flags = LOAD_LIBRARY_AS_DATAFILE); 41 | bool Load(LPCWSTR fileName); 42 | #endif 43 | FARPROC GetProcAddress(LPCSTR procName) const 44 | { return ::GetProcAddress(_module, procName); } 45 | }; 46 | 47 | bool MyGetModuleFileName(HMODULE hModule, CSysString &result); 48 | #ifndef _UNICODE 49 | bool MyGetModuleFileName(HMODULE hModule, UString &result); 50 | #endif 51 | 52 | }} 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/Defs.h: -------------------------------------------------------------------------------- 1 | // Windows/Defs.h 2 | 3 | #ifndef __WINDOWS_DEFS_H 4 | #define __WINDOWS_DEFS_H 5 | 6 | inline bool BOOLToBool(BOOL value) 7 | { return (value != FALSE); } 8 | 9 | inline BOOL BoolToBOOL(bool value) 10 | { return (value ? TRUE: FALSE); } 11 | 12 | inline VARIANT_BOOL BoolToVARIANT_BOOL(bool value) 13 | { return (value ? VARIANT_TRUE: VARIANT_FALSE); } 14 | 15 | inline bool VARIANT_BOOLToBool(VARIANT_BOOL value) 16 | { return (value != VARIANT_FALSE); } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/Error.cpp: -------------------------------------------------------------------------------- 1 | // Windows/Error.h 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "Windows/Error.h" 6 | #ifndef _UNICODE 7 | #include "Common/StringConvert.h" 8 | #endif 9 | 10 | #ifndef _UNICODE 11 | extern bool g_IsNT; 12 | #endif 13 | 14 | namespace NWindows { 15 | namespace NError { 16 | 17 | bool MyFormatMessage(DWORD messageID, CSysString &message) 18 | { 19 | LPVOID msgBuf; 20 | if(::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | 21 | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 22 | NULL,messageID, 0, (LPTSTR) &msgBuf,0, NULL) == 0) 23 | return false; 24 | message = (LPCTSTR)msgBuf; 25 | ::LocalFree(msgBuf); 26 | return true; 27 | } 28 | 29 | #ifndef _UNICODE 30 | bool MyFormatMessage(DWORD messageID, UString &message) 31 | { 32 | if (g_IsNT) 33 | { 34 | LPVOID msgBuf; 35 | if(::FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | 36 | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 37 | NULL, messageID, 0, (LPWSTR) &msgBuf, 0, NULL) == 0) 38 | return false; 39 | message = (LPCWSTR)msgBuf; 40 | ::LocalFree(msgBuf); 41 | return true; 42 | } 43 | CSysString messageSys; 44 | bool result = MyFormatMessage(messageID, messageSys); 45 | message = GetUnicodeString(messageSys); 46 | return result; 47 | } 48 | #endif 49 | 50 | }} 51 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/Error.h: -------------------------------------------------------------------------------- 1 | // Windows/Error.h 2 | 3 | #ifndef __WINDOWS_ERROR_H 4 | #define __WINDOWS_ERROR_H 5 | 6 | #include "Common/String.h" 7 | 8 | namespace NWindows { 9 | namespace NError { 10 | 11 | bool MyFormatMessage(DWORD messageID, CSysString &message); 12 | inline CSysString MyFormatMessage(DWORD messageID) 13 | { 14 | CSysString message; 15 | MyFormatMessage(messageID, message); 16 | return message; 17 | } 18 | #ifdef _UNICODE 19 | inline UString MyFormatMessageW(DWORD messageID) 20 | { return MyFormatMessage(messageID); } 21 | #else 22 | bool MyFormatMessage(DWORD messageID, UString &message); 23 | inline UString MyFormatMessageW(DWORD messageID) 24 | { 25 | UString message; 26 | MyFormatMessage(messageID, message); 27 | return message; 28 | } 29 | #endif 30 | 31 | }} 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/FileName.cpp: -------------------------------------------------------------------------------- 1 | // Windows/FileName.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "Windows/FileName.h" 6 | #include "Common/Wildcard.h" 7 | 8 | namespace NWindows { 9 | namespace NFile { 10 | namespace NName { 11 | 12 | static const wchar_t kDiskDelimiter = L':'; 13 | 14 | /* 15 | static bool IsCharAPrefixDelimiter(wchar_t c) 16 | { return (c == kDirDelimiter || c == kDiskDelimiter); } 17 | */ 18 | 19 | void NormalizeDirPathPrefix(CSysString &dirPath) 20 | { 21 | if (dirPath.IsEmpty()) 22 | return; 23 | if (dirPath.ReverseFind(kDirDelimiter) != dirPath.Length() - 1) 24 | dirPath += kDirDelimiter; 25 | } 26 | 27 | #ifndef _UNICODE 28 | void NormalizeDirPathPrefix(UString &dirPath) 29 | { 30 | if (dirPath.IsEmpty()) 31 | return; 32 | if (dirPath.ReverseFind(wchar_t(kDirDelimiter)) != dirPath.Length() - 1) 33 | dirPath += wchar_t(kDirDelimiter); 34 | } 35 | #endif 36 | 37 | namespace NPathType 38 | { 39 | EEnum GetPathType(const UString &path) 40 | { 41 | if (path.Length() <= 2) 42 | return kLocal; 43 | if (path[0] == kDirDelimiter && path[1] == kDirDelimiter) 44 | return kUNC; 45 | return kLocal; 46 | } 47 | } 48 | 49 | void CParsedPath::ParsePath(const UString &path) 50 | { 51 | int curPos = 0; 52 | switch (NPathType::GetPathType(path)) 53 | { 54 | case NPathType::kLocal: 55 | { 56 | int posDiskDelimiter = path.Find(kDiskDelimiter); 57 | if(posDiskDelimiter >= 0) 58 | { 59 | curPos = posDiskDelimiter + 1; 60 | if (path.Length() > curPos) 61 | if(path[curPos] == kDirDelimiter) 62 | curPos++; 63 | } 64 | break; 65 | } 66 | case NPathType::kUNC: 67 | { 68 | int curPos = path.Find(kDirDelimiter, 2); 69 | if(curPos < 0) 70 | curPos = path.Length(); 71 | else 72 | curPos++; 73 | } 74 | } 75 | Prefix = path.Left(curPos); 76 | SplitPathToParts(path.Mid(curPos), PathParts); 77 | } 78 | 79 | UString CParsedPath::MergePath() const 80 | { 81 | UString result = Prefix; 82 | for(int i = 0; i < PathParts.Size(); i++) 83 | { 84 | if (i != 0) 85 | result += kDirDelimiter; 86 | result += PathParts[i]; 87 | } 88 | return result; 89 | } 90 | 91 | const wchar_t kExtensionDelimiter = L'.'; 92 | 93 | void SplitNameToPureNameAndExtension(const UString &fullName, 94 | UString &pureName, UString &extensionDelimiter, UString &extension) 95 | { 96 | int index = fullName.ReverseFind(kExtensionDelimiter); 97 | if (index < 0) 98 | { 99 | pureName = fullName; 100 | extensionDelimiter.Empty(); 101 | extension.Empty(); 102 | } 103 | else 104 | { 105 | pureName = fullName.Left(index); 106 | extensionDelimiter = kExtensionDelimiter; 107 | extension = fullName.Mid(index + 1); 108 | } 109 | } 110 | 111 | }}} 112 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/FileName.h: -------------------------------------------------------------------------------- 1 | // Windows/FileName.h 2 | 3 | #ifndef __WINDOWS_FILENAME_H 4 | #define __WINDOWS_FILENAME_H 5 | 6 | #include "../Common/String.h" 7 | 8 | namespace NWindows { 9 | namespace NFile { 10 | namespace NName { 11 | 12 | const TCHAR kDirDelimiter = CHAR_PATH_SEPARATOR; 13 | const TCHAR kAnyStringWildcard = '*'; 14 | 15 | void NormalizeDirPathPrefix(CSysString &dirPath); // ensures that it ended with '\\' 16 | #ifndef _UNICODE 17 | void NormalizeDirPathPrefix(UString &dirPath); // ensures that it ended with '\\' 18 | #endif 19 | 20 | namespace NPathType 21 | { 22 | enum EEnum 23 | { 24 | kLocal, 25 | kUNC 26 | }; 27 | EEnum GetPathType(const UString &path); 28 | } 29 | 30 | struct CParsedPath 31 | { 32 | UString Prefix; // Disk or UNC with slash 33 | UStringVector PathParts; 34 | void ParsePath(const UString &path); 35 | UString MergePath() const; 36 | }; 37 | 38 | void SplitNameToPureNameAndExtension(const UString &fullName, 39 | UString &pureName, UString &extensionDelimiter, UString &extension); 40 | 41 | }}} 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/Handle.h: -------------------------------------------------------------------------------- 1 | // Windows/Handle.h 2 | 3 | #ifndef __WINDOWS_HANDLE_H 4 | #define __WINDOWS_HANDLE_H 5 | 6 | namespace NWindows { 7 | 8 | class CHandle 9 | { 10 | protected: 11 | HANDLE _handle; 12 | public: 13 | operator HANDLE() { return _handle; } 14 | CHandle(): _handle(NULL) {} 15 | ~CHandle() { Close(); } 16 | bool Close() 17 | { 18 | if (_handle == NULL) 19 | return true; 20 | if (!::CloseHandle(_handle)) 21 | return false; 22 | _handle = NULL; 23 | return true; 24 | } 25 | void Attach(HANDLE handle) 26 | { _handle = handle; } 27 | HANDLE Detach() 28 | { 29 | HANDLE handle = _handle; 30 | _handle = NULL; 31 | return handle; 32 | } 33 | }; 34 | 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/PropVariant.h: -------------------------------------------------------------------------------- 1 | // Windows/PropVariant.h 2 | 3 | #ifndef __WINDOWS_PROPVARIANT_H 4 | #define __WINDOWS_PROPVARIANT_H 5 | 6 | #include "../Common/MyWindows.h" 7 | #include "../Common/Types.h" 8 | 9 | namespace NWindows { 10 | namespace NCOM { 11 | 12 | class CPropVariant : public tagPROPVARIANT 13 | { 14 | public: 15 | CPropVariant() { vt = VT_EMPTY; } 16 | ~CPropVariant() { Clear(); } 17 | CPropVariant(const PROPVARIANT& varSrc); 18 | CPropVariant(const CPropVariant& varSrc); 19 | CPropVariant(BSTR bstrSrc); 20 | CPropVariant(LPCOLESTR lpszSrc); 21 | CPropVariant(bool bSrc) { vt = VT_BOOL; boolVal = (bSrc ? VARIANT_TRUE : VARIANT_FALSE); }; 22 | CPropVariant(UInt32 value) { vt = VT_UI4; ulVal = value; } 23 | CPropVariant(UInt64 value) { vt = VT_UI8; uhVal = *(ULARGE_INTEGER*)&value; } 24 | CPropVariant(const FILETIME &value) { vt = VT_FILETIME; filetime = value; } 25 | CPropVariant(Int32 value) { vt = VT_I4; lVal = value; } 26 | CPropVariant(Byte value) { vt = VT_UI1; bVal = value; } 27 | CPropVariant(Int16 value) { vt = VT_I2; iVal = value; } 28 | // CPropVariant(LONG value, VARTYPE vtSrc = VT_I4) { vt = vtSrc; lVal = value; } 29 | 30 | CPropVariant& operator=(const CPropVariant& varSrc); 31 | CPropVariant& operator=(const PROPVARIANT& varSrc); 32 | CPropVariant& operator=(BSTR bstrSrc); 33 | CPropVariant& operator=(LPCOLESTR lpszSrc); 34 | CPropVariant& operator=(bool bSrc); 35 | CPropVariant& operator=(UInt32 value); 36 | CPropVariant& operator=(UInt64 value); 37 | CPropVariant& operator=(const FILETIME &value); 38 | 39 | CPropVariant& operator=(Int32 value); 40 | CPropVariant& operator=(Byte value); 41 | CPropVariant& operator=(Int16 value); 42 | // CPropVariant& operator=(LONG value); 43 | 44 | HRESULT Clear(); 45 | HRESULT Copy(const PROPVARIANT* pSrc); 46 | HRESULT Attach(PROPVARIANT* pSrc); 47 | HRESULT Detach(PROPVARIANT* pDest); 48 | 49 | HRESULT InternalClear(); 50 | void InternalCopy(const PROPVARIANT* pSrc); 51 | 52 | int Compare(const CPropVariant &a1); 53 | }; 54 | 55 | }} 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/PropVariantConversions.h: -------------------------------------------------------------------------------- 1 | // Windows/PropVariantConversions.h 2 | 3 | #ifndef __PROPVARIANTCONVERSIONS_H 4 | #define __PROPVARIANTCONVERSIONS_H 5 | 6 | #include "Common/Types.h" 7 | #include "Common/String.h" 8 | 9 | bool ConvertFileTimeToString(const FILETIME &ft, char *s, bool includeTime = true, bool includeSeconds = true); 10 | UString ConvertFileTimeToString(const FILETIME &ft, bool includeTime = true, bool includeSeconds = true); 11 | UString ConvertPropVariantToString(const PROPVARIANT &propVariant); 12 | UInt64 ConvertPropVariantToUInt64(const PROPVARIANT &propVariant); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/ResourceString.cpp: -------------------------------------------------------------------------------- 1 | // Windows/ResourceString.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "Windows/ResourceString.h" 6 | #ifndef _UNICODE 7 | #include "Common/StringConvert.h" 8 | #endif 9 | 10 | extern HINSTANCE g_hInstance; 11 | #ifndef _UNICODE 12 | extern bool g_IsNT; 13 | #endif 14 | 15 | namespace NWindows { 16 | 17 | CSysString MyLoadString(UINT resourceID) 18 | { 19 | CSysString s; 20 | int size = 256; 21 | int len; 22 | do 23 | { 24 | size += 256; 25 | len = ::LoadString(g_hInstance, resourceID, s.GetBuffer(size - 1), size); 26 | } 27 | while (size - len <= 1); 28 | s.ReleaseBuffer(); 29 | return s; 30 | } 31 | 32 | #ifndef _UNICODE 33 | UString MyLoadStringW(UINT resourceID) 34 | { 35 | if (g_IsNT) 36 | { 37 | UString s; 38 | int size = 256; 39 | int len; 40 | do 41 | { 42 | size += 256; 43 | len = ::LoadStringW(g_hInstance, resourceID, s.GetBuffer(size - 1), size); 44 | } 45 | while (size - len <= 1); 46 | s.ReleaseBuffer(); 47 | return s; 48 | } 49 | return GetUnicodeString(MyLoadString(resourceID)); 50 | } 51 | #endif 52 | 53 | } 54 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/ResourceString.h: -------------------------------------------------------------------------------- 1 | // Windows/ResourceString.h 2 | 3 | #ifndef __WINDOWS_RESOURCESTRING_H 4 | #define __WINDOWS_RESOURCESTRING_H 5 | 6 | #include "Common/String.h" 7 | 8 | namespace NWindows { 9 | 10 | CSysString MyLoadString(UINT resourceID); 11 | #ifdef _UNICODE 12 | inline UString MyLoadStringW(UINT resourceID) 13 | { return MyLoadString(resourceID); } 14 | #else 15 | UString MyLoadStringW(UINT resourceID); 16 | #endif 17 | 18 | } 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/Synchronization.cpp: -------------------------------------------------------------------------------- 1 | // Windows/Synchronization.cpp 2 | 3 | #include "StdAfx.h" 4 | 5 | #include "Synchronization.h" 6 | 7 | namespace NWindows { 8 | namespace NSynchronization { 9 | 10 | CEvent::CEvent(bool manualReset, bool initiallyOwn, LPCTSTR name, 11 | LPSECURITY_ATTRIBUTES securityAttributes) 12 | { 13 | if (!Create(manualReset, initiallyOwn, name, securityAttributes)) 14 | throw "CreateEvent error"; 15 | } 16 | 17 | }} 18 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/Thread.h: -------------------------------------------------------------------------------- 1 | // Windows/Thread.h 2 | 3 | #ifndef __WINDOWS_THREAD_H 4 | #define __WINDOWS_THREAD_H 5 | 6 | #include "Handle.h" 7 | #include "Defs.h" 8 | 9 | namespace NWindows { 10 | 11 | class CThread: public CHandle 12 | { 13 | bool IsOpen() const { return _handle != 0; } 14 | public: 15 | bool Create(LPSECURITY_ATTRIBUTES threadAttributes, 16 | SIZE_T stackSize, LPTHREAD_START_ROUTINE startAddress, 17 | LPVOID parameter, DWORD creationFlags, LPDWORD threadId) 18 | { 19 | _handle = ::CreateThread(threadAttributes, stackSize, startAddress, 20 | parameter, creationFlags, threadId); 21 | return (_handle != NULL); 22 | } 23 | bool Create(LPTHREAD_START_ROUTINE startAddress, LPVOID parameter) 24 | { 25 | DWORD threadId; 26 | return Create(NULL, 0, startAddress, parameter, 0, &threadId); 27 | } 28 | 29 | DWORD Resume() 30 | { return ::ResumeThread(_handle); } 31 | DWORD Suspend() 32 | { return ::SuspendThread(_handle); } 33 | bool Terminate(DWORD exitCode) 34 | { return BOOLToBool(::TerminateThread(_handle, exitCode)); } 35 | 36 | int GetPriority() 37 | { return ::GetThreadPriority(_handle); } 38 | bool SetPriority(int priority) 39 | { return BOOLToBool(::SetThreadPriority(_handle, priority)); } 40 | 41 | bool Wait() 42 | { 43 | if (!IsOpen()) 44 | return true; 45 | return (::WaitForSingleObject(_handle, INFINITE) == WAIT_OBJECT_0); 46 | } 47 | 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /win/installer/7zstub/src/Windows/Time.h: -------------------------------------------------------------------------------- 1 | // Windows/Time.h 2 | 3 | #ifndef __WINDOWS_TIME_H 4 | #define __WINDOWS_TIME_H 5 | 6 | #include "Common/Types.h" 7 | #include "Windows/Defs.h" 8 | 9 | namespace NWindows { 10 | namespace NTime { 11 | 12 | inline bool DosTimeToFileTime(UInt32 dosTime, FILETIME &fileTime) 13 | { 14 | return BOOLToBool(::DosDateTimeToFileTime(UInt16(dosTime >> 16), 15 | UInt16(dosTime & 0xFFFF), &fileTime)); 16 | } 17 | 18 | const UInt32 kHighDosTime = 0xFF9FBF7D; 19 | const UInt32 kLowDosTime = 0x210000; 20 | 21 | inline bool FileTimeToDosTime(const FILETIME &fileTime, UInt32 &dosTime) 22 | { 23 | WORD datePart, timePart; 24 | if (!::FileTimeToDosDateTime(&fileTime, &datePart, &timePart)) 25 | { 26 | if (fileTime.dwHighDateTime >= 0x01C00000) // 2000 27 | dosTime = kHighDosTime; 28 | else 29 | dosTime = kLowDosTime; 30 | return false; 31 | } 32 | dosTime = (((UInt32)datePart) << 16) + timePart; 33 | return true; 34 | } 35 | 36 | const UInt32 kNumTimeQuantumsInSecond = 10000000; 37 | const UInt64 kUnixTimeStartValue = ((UInt64)kNumTimeQuantumsInSecond) * 60 * 60 * 24 * 134774; 38 | 39 | inline void UnixTimeToFileTime(UInt32 unixTime, FILETIME &fileTime) 40 | { 41 | UInt64 v = kUnixTimeStartValue + ((UInt64)unixTime) * kNumTimeQuantumsInSecond; 42 | fileTime.dwLowDateTime = (DWORD)v; 43 | fileTime.dwHighDateTime = (DWORD)(v >> 32); 44 | } 45 | 46 | inline bool FileTimeToUnixTime(const FILETIME &fileTime, UInt32 &unixTime) 47 | { 48 | UInt64 winTime = (((UInt64)fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime; 49 | if (winTime < kUnixTimeStartValue) 50 | { 51 | unixTime = 0; 52 | return false; 53 | } 54 | winTime = (winTime - kUnixTimeStartValue) / kNumTimeQuantumsInSecond; 55 | if (winTime > 0xFFFFFFFF) 56 | { 57 | unixTime = 0xFFFFFFFF; 58 | return false; 59 | } 60 | unixTime = (UInt32)winTime; 61 | return true; 62 | } 63 | 64 | }} 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /win/installer/LICENSE: -------------------------------------------------------------------------------- 1 | Please see the file toolkit/content/license.html for the copyright licensing 2 | conditions attached to this codebase, including copies of the licenses 3 | concerned. 4 | 5 | You are not granted rights or licenses to the trademarks of the 6 | Mozilla Foundation or any party, including without limitation the 7 | Firefox name or logo. 8 | 9 | For more information, see: http://www.mozilla.org/foundation/licensing.html 10 | -------------------------------------------------------------------------------- /win/installer/app.tag: -------------------------------------------------------------------------------- 1 | ;!@Install@!UTF-8! 2 | Title="Zotero" 3 | RunProgram="setup.exe" 4 | ;!@InstallEnd@! -------------------------------------------------------------------------------- /win/installer/baseLocale.nlf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/installer/baseLocale.nlf -------------------------------------------------------------------------------- /win/installer/baseLocale.nsh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/installer/baseLocale.nsh -------------------------------------------------------------------------------- /win/installer/branding.nsi: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | # NSIS branding defines for unofficial builds. 6 | # The official release build branding.nsi is located in other-license/branding/firefox/ 7 | # The nightly build branding.nsi is located in browser/installer/windows/nsis/ 8 | 9 | # BrandFullNameInternal is used for some registry and file system values 10 | # instead of BrandFullName and typically should not be modified. 11 | !define BrandFullNameInternal "Zotero" 12 | !define CompanyName "Corporation for Digital Scholarship" 13 | !define URLInfoAbout "https://www.zotero.org" 14 | !define URLUpdateInfo "https://www.zotero.org" 15 | -------------------------------------------------------------------------------- /win/installer/customLocale.nsh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/installer/customLocale.nsh -------------------------------------------------------------------------------- /win/installer/locales.nsi: -------------------------------------------------------------------------------- 1 | # This Source Code Form is subject to the terms of the Mozilla Public 2 | # License, v. 2.0. If a copy of the MPL was not distributed with this 3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | 5 | /** 6 | * "One off" locale configuration settings for RTL (e.g. locale text is read 7 | * right to left). 8 | */ 9 | 10 | ; Arabic 11 | !define ar_rtl 12 | 13 | ; Hebrew 14 | !define he_rtl 15 | 16 | ; Persian 17 | !define fa_rtl 18 | -------------------------------------------------------------------------------- /win/installer/overrideLocale.nsh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/installer/overrideLocale.nsh -------------------------------------------------------------------------------- /win/installer/setup.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/installer/setup.ico -------------------------------------------------------------------------------- /win/installer/updater_append.ini: -------------------------------------------------------------------------------- 1 | 2 | ; IMPORTANT: This file should always start with a newline in case a locale 3 | ; provided updater.ini does not end with a newline. 4 | ; Application to launch after an update has been successfully applied. This 5 | ; must be in the same directory or a sub-directory of the directory of the 6 | ; application executable that initiated the software update. 7 | [PostUpdateWin] 8 | ; ExeRelPath is the path to the PostUpdateWin executable relative to the 9 | ; application executable. 10 | ExeRelPath=uninstall\helper.exe 11 | ; ExeArg is the argument to pass to the PostUpdateWin exe 12 | ExeArg=/PostUpdate 13 | -------------------------------------------------------------------------------- /win/mozconfig: -------------------------------------------------------------------------------- 1 | # These probably don't all affect the stub, but they can't hurt 2 | export BUILDING_RELEASE=1 3 | export MOZILLA_OFFICIAL=1 4 | export MOZ_TELEMETRY_REPORTING=0 5 | ac_add_options --enable-official-branding 6 | ac_add_options --disable-tests 7 | ac_add_options --disable-debug 8 | 9 | # Uncomment to build the 64-bit version 10 | #ac_add_options --target=x86_64-pc-mingw32 11 | #ac_add_options --host=x86_64-pc-mingw32 12 | 13 | # Stylo packages are missing when skipping hg and building from a downloaded zip with the specific revision, 14 | # but the stub shouldn't be affected either 15 | ac_add_options --disable-stylo 16 | -------------------------------------------------------------------------------- /win/mozilla-60.patch: -------------------------------------------------------------------------------- 1 | diff --git a/browser/app/nsBrowserApp.cpp b/browser/app/nsBrowserApp.cpp 2 | index db2eb9637c57..a75b380f9424 100644 3 | --- a/browser/app/nsBrowserApp.cpp 4 | +++ b/browser/app/nsBrowserApp.cpp 5 | @@ -151,7 +151,13 @@ Bootstrap::UniquePtr gBootstrap; 6 | static int do_main(int argc, char* argv[], char* envp[]) { 7 | // Allow firefox.exe to launch XULRunner apps via -app 8 | // Note that -app must be the *first* argument. 9 | - const char* appDataFile = getenv("XUL_APP_FILE"); 10 | + UniqueFreePtr iniPath = BinaryPath::GetApplicationIni(); 11 | + if (!iniPath) { 12 | + Output("Couldn't find application.ini.\n"); 13 | + return 255; 14 | + 15 | + } 16 | + char *appDataFile = iniPath.get(); 17 | if ((!appDataFile || !*appDataFile) && (argc > 1 && IsArg(argv[1], "app"))) { 18 | if (argc == 2) { 19 | Output("Incorrect number of arguments passed to -app"); 20 | diff --git a/xpcom/build/BinaryPath.h b/xpcom/build/BinaryPath.h 21 | index 4721c5b5b36d..5269bd75c7b3 100644 22 | --- a/xpcom/build/BinaryPath.h 23 | +++ b/xpcom/build/BinaryPath.h 24 | @@ -261,6 +261,33 @@ class BinaryPath { 25 | return result; 26 | } 27 | 28 | + static UniqueFreePtr GetApplicationIni() { 29 | + char path[MAXPATHLEN]; 30 | + if (NS_FAILED(Get(path))) { 31 | + return nullptr; 32 | + } 33 | + 34 | + char *c = path + strlen(path); 35 | + while (c >= path && *c != '\\' && *c != '/') { 36 | + *c = NULL; 37 | + c--; 38 | + } 39 | + 40 | + if (c < path) { 41 | + return nullptr; 42 | + } 43 | + 44 | + char iniPath[MAXPATHLEN]; 45 | + int n = snprintf(iniPath, MAXPATHLEN, "%sapplication.ini", path); 46 | + if (n < 0 || n >= MAXPATHLEN) { 47 | + return nullptr; 48 | + } 49 | + 50 | + UniqueFreePtr result; 51 | + result.reset(strdup(iniPath)); 52 | + return result; 53 | + } 54 | + 55 | #ifdef MOZILLA_INTERNAL_API 56 | static nsresult GetFile(nsIFile** aResult) { 57 | nsCOMPtr lf; 58 | -------------------------------------------------------------------------------- /win/updater.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/updater.exe -------------------------------------------------------------------------------- /win/zotero_win32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/zotero_win32.exe -------------------------------------------------------------------------------- /win/zotero_win64.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zotero/zotero-standalone-build/acdec9df8330a8b7a52f5c8dc496ad6e09e9b955/win/zotero_win64.exe --------------------------------------------------------------------------------