Skip to content

Latest commit

 

History

History
40 lines (34 loc) · 1.59 KB

extract.md

File metadata and controls

40 lines (34 loc) · 1.59 KB

extract(algorithm, parameters[, callback])

Extract an archive to the specified destination.

  • algorithm <String>: select the algorithm to use, values possible are: 7z, zip, tar
  • parameters <Object>: parameters object to send
    • archive <String>: archive to extract. (global)
    • destination <String>: directory to extract the files. (global)
    • password <String>: password to use to compress the archive. (7z only)
  • callback <Function>
    • error <Error>
  • progressCallback <Function>
    • progress <Object>: progress information
      • total <Number>: total bytes to compress (Windows only)
      • progress <Number>: progress
      • ratio <Number>: compression ratio (Windows only)
      • fileProcessed <String>: file currently processed (on Linux and Mac it seems not accurate)

Exemple

const sevenzip = require('@steezcram/sevenzip');

// By set the destination as a directory, the archive name will be: test.7z
sevenzip.extract('7z', {archive: 'C:\\Users\\public\\Desktop\\test.7z', destination: 'C:\\Users\\tcroi\\Desktop\\test'}, (error) => {
    if (error) throw error;
}, (progress) => {
    console.log(progress);
});

Using await

const sevenzip = require('@steezcram/sevenzip');

// By set the destination as a directory, the archive name will be: test.7z
const error = await sevenzip.extract('7z', {archive: 'C:\\Users\\public\\Desktop\\test.7z', destination: 'C:\\Users\\tcroi\\Desktop\\test'}, null, (progress) => {
    console.log(progress);
});
if (error) throw error;