1 /* 2 * Copyright (C) 2014-2020 Daniel Scharrer 3 * 4 * This software is provided 'as-is', without any express or implied 5 * warranty. In no event will the author(s) be held liable for any damages 6 * arising from the use of this software. 7 * 8 * Permission is granted to anyone to use this software for any purpose, 9 * including commercial applications, and to alter it and redistribute it 10 * freely, subject to the following restrictions: 11 * 12 * 1. The origin of this software must not be misrepresented; you must not 13 * claim that you wrote the original software. If you use this software 14 * in a product, an acknowledgment in the product documentation would be 15 * appreciated but is not required. 16 * 2. Altered source versions must be plainly marked as such, and must not be 17 * misrepresented as being the original software. 18 * 3. This notice may not be removed or altered from any source distribution. 19 */ 20 21 /*! 22 * \file 23 * 24 * Routines to extract/list files from an Inno Setup archive. 25 */ 26 #ifndef INNOEXTRACT_CLI_EXTRACT_HPP 27 #define INNOEXTRACT_CLI_EXTRACT_HPP 28 29 #include <stdexcept> 30 #include <string> 31 #include <vector> 32 33 #include <boost/cstdint.hpp> 34 #include <boost/filesystem/path.hpp> 35 36 #include "setup/filename.hpp" 37 38 struct format_error : public std::runtime_error { format_errorformat_error39 explicit format_error(const std::string & reason) : std::runtime_error(reason) { } 40 }; 41 42 enum CollisionAction { 43 OverwriteCollisions, 44 RenameCollisions, 45 RenameAllCollisions, 46 ErrorOnCollisions 47 }; 48 49 struct extract_options { 50 51 bool quiet; 52 bool silent; 53 54 bool warn_unused; //!< Warn if there are unused files 55 56 bool list_sizes; //!< Show size information for files 57 bool list_checksums; //!< Show checksum information for files 58 59 bool data_version; //!< Print the data version 60 #ifdef DEBUG 61 bool dump_headers; //!< Dump setup headers 62 #endif 63 bool list; //!< List files 64 bool test; //!< Test files (but don't extract) 65 bool extract; //!< Extract files 66 bool list_languages; //!< List available languages 67 bool gog_game_id; //!< Show the GOG.com game id 68 bool show_password; //!< Show password check information 69 bool check_password; //!< Abort if the provided password is incorrect 70 71 bool preserve_file_times; //!< Set timestamps of extracted files 72 bool local_timestamps; //!< Use local timezone for setting timestamps 73 74 bool gog; //!< Try to extract additional archives used in GOG.com installers 75 bool gog_galaxy; //!< Try to re-assemble GOG Galaxy files 76 77 bool extract_unknown; //!< Try to extract unknown Inno Setup versions 78 79 bool extract_temp; //!< Extract temporary files 80 bool language_only; //!< Extract files not associated with any language 81 std::string language; //!< Extract only files for this language 82 std::vector<std::string> include; //!< Extract only files matching these patterns 83 84 boost::uint32_t codepage; 85 86 setup::filename_map filenames; 87 CollisionAction collisions; 88 std::string default_language; 89 90 std::string password; 91 92 boost::filesystem::path output_dir; 93 extract_optionsextract_options94 extract_options() 95 : quiet(false) 96 , silent(false) 97 , warn_unused(false) 98 , list_sizes(false) 99 , list_checksums(false) 100 , data_version(false) 101 , list(false) 102 , test(false) 103 , extract(false) 104 , list_languages(false) 105 , gog_game_id(false) 106 , show_password(false) 107 , check_password(false) 108 , preserve_file_times(false) 109 , local_timestamps(false) 110 , gog(false) 111 , gog_galaxy(false) 112 , extract_unknown(false) 113 , extract_temp(false) 114 , language_only(false) 115 , collisions(OverwriteCollisions) 116 { } 117 118 }; 119 120 void process_file(const boost::filesystem::path & installer, const extract_options & o); 121 122 #endif // INNOEXTRACT_CLI_EXTRACT_HPP 123