Skip to content

Commit

Permalink
Distinguish files & directories in "list"
Browse files Browse the repository at this point in the history
  • Loading branch information
jbdemonte committed Jan 2, 2017
1 parent 7a10d81 commit e22af55
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Default overwrite mode is set to "Overwrite All existing files without prompt" u
* `data.method` string
* `data.solid` string
* `data.blocks` number
* `data.directories` array (same as `data.files`)
* `data.files` array

* `data.files[].attr` string
Expand Down
23 changes: 15 additions & 8 deletions lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ function ArchiveInfo() {
this.method = undefined;
this.solid = undefined;
this.blocks = undefined;
this.directories = [];
this.files = [];
}

function ArchiveFile() {
function ArchiveEntry() {
this.attr = undefined;
this.compressed = undefined;
this.date = undefined;
Expand Down Expand Up @@ -54,13 +55,19 @@ module.exports = function (archive, switches) {
lines.forEach(function (line) {
var res = regex.exec(line);
if (res) {
var file = new ArchiveFile();
file.date = new Date(res[1]);
file.attr = res[2];
file.size = parseInt(res[3], 10) || 0;
file.compressed = parseInt(res[4]) || 0;
file.name = res[5];
info.files.push(file);
var entry = new ArchiveEntry();
entry.date = new Date(res[1]);
entry.attr = res[2];
entry.size = parseInt(res[3], 10) || 0;
entry.compressed = parseInt(res[4]) || 0;
entry.name = res[5];

if (~(entry.attr || '').indexOf('D')) {
info.directories.push(entry);
} else {
info.files.push(entry);
}

} else {
properties.some(function (property) {
if (tools.start(line, property + ' = ')) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "p7zip",
"version": "2.0.0",
"version": "2.1.0",
"description": "A node wrapper for 7z including latest version of 7za",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit e22af55

Please sign in to comment.