Add lzx archive support via unlzx

This commit is contained in:
Bryan Ashby 2018-05-31 20:58:24 -06:00
parent 39be44434a
commit 37e5948f65
3 changed files with 39 additions and 5 deletions

View File

@ -207,7 +207,12 @@ module.exports = class ArchiveUtil {
extractPath : extractPath,
};
const action = haveFileList ? 'extract' : 'decompress';
let action = haveFileList ? 'extract' : 'decompress';
if('extract' === action && !_.isObject(archiver[action])) {
// we're forced to do a full decompress
action = 'decompress';
haveFileList = false;
}
// we need to treat {fileList} special in that it should be broken up to 0:n args
const args = archiver[action].args.map( arg => {
@ -222,7 +227,7 @@ module.exports = class ArchiveUtil {
let proc;
try {
proc = pty.spawn(archiver[action].cmd, args, this.getPtyOpts());
proc = pty.spawn(archiver[action].cmd, args, this.getPtyOpts(extractPath));
} catch(e) {
return cb(e);
}
@ -278,13 +283,17 @@ module.exports = class ArchiveUtil {
});
}
getPtyOpts() {
return {
// :TODO: cwd
getPtyOpts(extractPath) {
const opts = {
name : 'enigma-archiver',
cols : 80,
rows : 24,
env : process.env,
};
if(extractPath) {
opts.cwd = extractPath;
}
// :TODO: set cwd to supplied temp path if not sepcific extract
return opts;
}
};

View File

@ -415,6 +415,12 @@ function getDefaultConfig() {
offset : 2,
archiveHandler : 'Lha',
},
'application/x-lzx' : {
desc : 'LZX Archive',
sig : '4c5a5800',
offset : 0,
archiveHandler : 'Lzx',
},
'application/x-7z-compressed' : {
desc : '7-Zip Archive',
sig : '377abcaf271c',
@ -473,6 +479,24 @@ function getDefaultConfig() {
}
},
Lzx : {
//
// 'unlzx' command can be obtained from:
// * Debian based: https://launchpad.net/~rzr/+archive/ubuntu/ppa/+build/2486127 (amd64/x86_64)
// * Source: http://xavprods.free.fr/lzx/
//
decompress : {
cmd : 'unlzx',
// unzlx doesn't have a output dir option, but we'll cwd to the temp output dir first
args : [ '-x', '{archivePath}' ],
},
list : {
cmd : 'unlzx',
args : [ '-v', '{archivePath}' ],
entryMatch : '^\\s+([0-9]+)\\s+[^\\s]+\\s+[0-9]{2}:[0-9]{2}:[0-9]{2}\\s+[0-9]{1,2}-[a-z]{3}-[0-9]{4}\\s+[a-z\\-]+\\s+\\"([^"]+)\\"$',
}
},
Arj : {
//
// 'arj' command can be obtained from:

View File

@ -16,6 +16,7 @@ function startup(cb) {
const ADDITIONAL_EXT_MIMETYPES = {
ans : 'text/x-ansi',
gz : 'application/gzip', // not in mime-types 2.1.15 :(
lzx : 'application/x-lzx', // :TODO: submit to mime-types
};
_.forEach(ADDITIONAL_EXT_MIMETYPES, (mimeType, ext) => {