Skip to content

Commit e22af55

Browse files
committed
Distinguish files & directories in "list"
1 parent 7a10d81 commit e22af55

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ Default overwrite mode is set to "Overwrite All existing files without prompt" u
109109
* `data.method` string
110110
* `data.solid` string
111111
* `data.blocks` number
112+
* `data.directories` array (same as `data.files`)
112113
* `data.files` array
113114

114115
* `data.files[].attr` string

lib/list.js

+15-8
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ function ArchiveInfo() {
2121
this.method = undefined;
2222
this.solid = undefined;
2323
this.blocks = undefined;
24+
this.directories = [];
2425
this.files = [];
2526
}
2627

27-
function ArchiveFile() {
28+
function ArchiveEntry() {
2829
this.attr = undefined;
2930
this.compressed = undefined;
3031
this.date = undefined;
@@ -54,13 +55,19 @@ module.exports = function (archive, switches) {
5455
lines.forEach(function (line) {
5556
var res = regex.exec(line);
5657
if (res) {
57-
var file = new ArchiveFile();
58-
file.date = new Date(res[1]);
59-
file.attr = res[2];
60-
file.size = parseInt(res[3], 10) || 0;
61-
file.compressed = parseInt(res[4]) || 0;
62-
file.name = res[5];
63-
info.files.push(file);
58+
var entry = new ArchiveEntry();
59+
entry.date = new Date(res[1]);
60+
entry.attr = res[2];
61+
entry.size = parseInt(res[3], 10) || 0;
62+
entry.compressed = parseInt(res[4]) || 0;
63+
entry.name = res[5];
64+
65+
if (~(entry.attr || '').indexOf('D')) {
66+
info.directories.push(entry);
67+
} else {
68+
info.files.push(entry);
69+
}
70+
6471
} else {
6572
properties.some(function (property) {
6673
if (tools.start(line, property + ' = ')) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "p7zip",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "A node wrapper for 7z including latest version of 7za",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)