diff --git a/core/archive_util.js b/core/archive_util.js index e0d102d9..c3915389 100644 --- a/core/archive_util.js +++ b/core/archive_util.js @@ -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; } }; diff --git a/core/config.js b/core/config.js index 2564c256..b782531f 100644 --- a/core/config.js +++ b/core/config.js @@ -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: diff --git a/core/mime_util.js b/core/mime_util.js index a110572c..b9a7c5af 100644 --- a/core/mime_util.js +++ b/core/mime_util.js @@ -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) => {