diff --git a/doc/innoextract.1 b/doc/innoextract.1 index 63078a7..90b8c1d 100644 --- a/doc/innoextract.1 +++ b/doc/innoextract.1 @@ -79,7 +79,10 @@ Inno Setup installers can contain duplicate files with the same name. This optio Extract only one of the colliding files. The choice is done similar to how Inno Setup overwrites files during installation. This is the default. .TP "\fBrename\fP" -Rename files that would be overwritten using the "\fBoverwrite\fP" option by appending a suffix comprised of the file's language, the component it belongs to and/or a number to make the filename unique. The language suffix (if applicable) is also appended to the \fIdefault\fP file that would have been extracted with the "\fBoverwrite\fP" option. +Rename files that would be overwritten using the "\fBoverwrite\fP" action by appending a suffix comprised of the file's language, the component it belongs to and/or a number to make the filename unique. The language suffix (if applicable) is also appended to the \fIdefault\fP file that would have been extracted with the "\fBoverwrite\fP" action. +.TP +"\fBrename-all\fP" +Rename all colliding files by appending a suffix comprised of the file's language, the component it belongs to and/or a number to make the filename unique. The complete suffix is appended to both files that would have been overwritten using the "\fBoverwrite\fP" action and to those that would have overwritten other files. .TP "\fBerror\fP" Exit when a collision is detected. @@ -93,6 +96,7 @@ Exit when a collision is detected. 3. If no suffix was added by the previous steps, or if the filename is not yet unique, "\fB$\fP" (without quotes) followed by the lowest integer (starting at 0) to make the filename unique is appended. +With the "\fBrename\fP" action, steps 1 and 3 are only applied to files that would have been overwritten by the "\fBoverwrite\fP" action while the "\fBrename-all\fP" applies them to all files in the collision set. .TP \fB\-\-default\-language\fP \fILANG\fP Set a language as the default. diff --git a/src/cli/extract.cpp b/src/cli/extract.cpp index 54553bf..4dfb386 100644 --- a/src/cli/extract.cpp +++ b/src/cli/extract.cpp @@ -398,7 +398,7 @@ static bool rename_collision(const extract_options & o, FilesMap & processed_fil const setup::file_entry & file = other.entry(); - bool require_number_suffix = !first; + bool require_number_suffix = !first || (o.collisions == RenameAllCollisions); std::ostringstream oss; if(!common_component && !file.components.empty()) { @@ -456,7 +456,9 @@ static void rename_collisions(const extract_options & o, FilesMap & processed_fi common_language = common_language && other.entry().languages == file.languages; } - if(rename_collision(o, processed_files, path, base, true, common_language, true)) { + bool ignore_component = common_component || o.collisions != RenameAllCollisions; + if(rename_collision(o, processed_files, path, base, + ignore_component, common_language, true)) { processed_files.erase(path); } @@ -707,6 +709,8 @@ void process_file(const fs::path & file, const extract_options & o) { if(o.collisions == ErrorOnCollisions) { throw std::runtime_error("Collision: " + path); + } else if(o.collisions == RenameAllCollisions) { + collisions[internal_path].push_back(processed_file(&file, path)); } else { const setup::data_entry & newdata = info.data_entries[file.location]; @@ -752,7 +756,7 @@ void process_file(const fs::path & file, const extract_options & o) { } - if(o.collisions == RenameCollisions) { + if(o.collisions == RenameCollisions || o.collisions == RenameAllCollisions) { rename_collisions(o, processed_files, collisions); collisions.clear(); } diff --git a/src/cli/extract.hpp b/src/cli/extract.hpp index a635eff..dfa8122 100644 --- a/src/cli/extract.hpp +++ b/src/cli/extract.hpp @@ -41,6 +41,7 @@ struct format_error : public std::runtime_error { enum CollisionAction { OverwriteCollisions, RenameCollisions, + RenameAllCollisions, ErrorOnCollisions }; diff --git a/src/cli/main.cpp b/src/cli/main.cpp index 7b5c98b..9c73cd4 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -298,6 +298,8 @@ int main(int argc, char * argv[]) { o.collisions = OverwriteCollisions; } else if(collisions == "rename") { o.collisions = RenameCollisions; + } else if(collisions == "rename-all") { + o.collisions = RenameAllCollisions; } else if(collisions == "error") { o.collisions = ErrorOnCollisions; } else {