-
Notifications
You must be signed in to change notification settings - Fork 0
API
Content()
will list all the files and folders in an archive, as well as give some information about these entries.
ArchiveManager.Content('path/to/archive',function(error,files){
if(error){
console.error(error);
return;
}
//files: array of objects in format : {string: name, number: size, boolean: directory}
});
Create()
will create a new archive file at outputPath
with the files specified in the newFiles
array.
ArchiveManager.Create(['path/to/file/1','path/to/file/2',...],'path/to/archive', function(error,outcome){
//outcome: true if the creation was successful (usually true, if there was no errors)
});
You can create a new archive using buffers as well:
ArchiveManager.Create(['name/of/file/1','name/of/file/2',...],[buffer_file_1, buffer_file_2,...], 'path/to/archive', function(error,outcome){
});
NOTE: In-Place edits are currently not supported by libarchive, so this could be very slow for large archives.
Append()
works like Create()
, except the data already in the archive will be preserved. Any file in the archive with the same name as one you wish to append will be overwritten.
ArchiveManager.Append(['path/to/file/1','path/to/file/2',...], 'path/to/archive', function(error,outcome){
//outcome: true if the appending was successful (usually true, if there was no errors)
});
Append()
will also work with buffers:
ArchiveManager.Append(['name/of/file/1','name/of/file/2',...], [buffer_file_1, buffer_file_2,...], 'path/to/archive', function(error,outcome){
});
Extract()
will put all the contents of the archive speified by archivePath
to outputPath
ArchiveManager.Extract('path/to/archive', 'path/to/output', function(error,outcome){
//outcome: true if the extraction was successful (usually true, if there was no errors)
});
Read()
will allow you to copy a file from an archive into memory to be used any way a buffer can. This is particullarly useful for JSON files and images.
ArchiveManager.Read('path/in/archive','path/to/archive', function(error,data){
//data: buffer containing the contents of the file
});
Remove()
will delete all the files in the archive specified in teh fileNames
array.
ArchiveManager.Remove(['name/of/file/1','name/of/file/2',...],'path/to/archive', function(error,outcome){
//outcome: true if the extraction was successful (usually true, if there was no errors)
});