diff --git a/include/system.hpp b/include/system.hpp index 3ac71d13..a5d0d5f4 100644 --- a/include/system.hpp +++ b/include/system.hpp @@ -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); diff --git a/src/system.cpp b/src/system.cpp index a4b3599c..2a182fc1 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -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)