Skip to main content

Modify archive

Adds, replaces and deletes files in an existing 7z archive

Function ModifyArchive(Val Archive, Val AddableFiles = Undefined, Val DeletablePaths = Undefined, Val Settings = Undefined) Export

ParameterCLI optionTypeRequiredDescription
Archive--srcString, BinaryDataPath to the archive on disk or binary data
AddableFiles--additionsMap Of KeyAndValueKey: archive path; value: file path or binary data
DeletablePaths--deletionsArray Of StringPaths of files in the archive for deletion
Settings--settingsMap Of KeyAndValueModification settings. See GetArchiveModificationStructure
Returns

BinaryData, Map Of KeyAndValue - Result of the operation for the archive on the disk or new binary data of the archive

tip

Parameters with Binary data type can also accept file paths on disk and URLs


1C:Enterprise/OneScript code example
ArchivePath = Parameters["SevenZ_ArchivePath"];
NewFilePath = Parameters["SevenZ_NewFilePath"];

AddableFiles = New Map;
AddableFiles.Insert("extra/info.txt", NewFilePath);
AddableFiles.Insert("readme.txt" , GetBinaryDataFromString("Replaced readme content", "UTF-8"));

DeletablePaths = New Array;
DeletablePaths.Add("config/settings.json");
DeletablePaths.Add("missing/path.txt");

Result = OPI_7z.ModifyArchive(ArchivePath, AddableFiles, DeletablePaths);
# JSON data can also be passed as a path to a .json file

oint 7z ModifyArchive \
--src "/tmp//opi_sevenz_63920079973933/archive_buffer.7z" \
--additions "{'extra/info.txt':'/tmp//opi_sevenz_63920079973933/extra_info.txt','readme.txt':'/tmp/0pu3uq4c.pcr'}" \
--deletions "['config/settings.json','missing/path.txt']"
Result
{
"result": true
}