Browse Source

In unarchiveToDirectory(), make zero-byte files in the archive delete existing files instead of overwrite them.

tags/v2.2.3
Andrew Belt 1 year ago
parent
commit
f90e1d0d0b
2 changed files with 9 additions and 0 deletions
  1. +3
    -0
      include/system.hpp
  2. +6
    -0
      src/system.cpp

+ 3
- 0
include/system.hpp View File

@@ -146,6 +146,9 @@ or

tar -xf archivePath --zstd -C dirPath

As a special case, zero-byte files in the archive cause the unarchiver to delete existing files instead of overwriting them.
This is useful for removing presets in .vcvplugin packages, for example.

Throws on error.
*/
void unarchiveToDirectory(const std::string& archivePath, const std::string& dirPath);


+ 6
- 0
src/system.cpp View File

@@ -575,6 +575,12 @@ static void unarchiveToDirectory(const std::string& archivePath, const std::vect
archive_entry_set_pathname(entry, entryPath.c_str());
#endif

// Delete zero-byte files
if (archive_entry_filetype(entry) == AE_IFREG && archive_entry_size(entry) == 0) {
remove(entryPath);
continue;
}

// Write entry to disk
r = archive_write_header(disk, entry);
if (r < ARCHIVE_OK)


Loading…
Cancel
Save