Skip to content

Commit

Permalink
adding comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mansurt committed Jun 26, 2017
1 parent 6e1603e commit 8e24384
Showing 1 changed file with 84 additions and 9 deletions.
93 changes: 84 additions & 9 deletions lib/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,50 @@ function parseProperty(data, propObj, requiredPropertyArr) {
/*
* Output of 7z with slt option contains 7z version. '--', metaData, '----------', and fileData for each archived file separated by an empty line.
* Both metaData and fileData are set of <key> = <value> separated by a new line
* Example:
* 7-Zip [64] 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18
* p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)
*
* Listing archive: password_protected_zip_with_pdf_pass_is_1234.ZIP
*
* --
* Path = password_protected_zip_with_pdf_pass_is_1234.ZIP
* Type = zip
* Physical Size = 31703
*
* ----------
* Path = allowed_image.jpg
* Folder = -
* Size = 34530
* Packed Size = 28839
* Modified = 2016-02-29 19:01:01
* Created = 2016-02-29 19:01:01
* Accessed = 2016-02-29 19:01:01
* Attributes = ....A
* Encrypted = +
* Comment =
* CRC = 2A63718C
* Method = ZipCrypto Deflate
* Host OS = FAT
* Version = 20
*
* Path = ski_equipment.pdf
* Folder = -
* Size = 3903
* Packed Size = 2550
* Modified = 2016-03-08 13:29:14
* Created = 2016-03-08 13:29:14
* Accessed = 2016-03-08 13:29:14
* Attributes = ....A
* Encrypted = +
* Comment =
* CRC = 20B2CC8A
* Method = ZipCrypto Deflate
* Host OS = FAT
* Version = 20
*
*
* End of example output
* params:
* data - cmd output to parse
* filesRequiredFields - file required field, if not null, then other fields won't be parsed
Expand Down Expand Up @@ -183,6 +226,7 @@ function parseSltOutputStream(data, filesRequiredFields, parsingProgress) {
parsingProgress.files = [];
}


//parse files
for (i = i + 1; i < lines.length; ++i) {
if (lines[i].length === 0) {
Expand All @@ -199,15 +243,46 @@ function parseSltOutputStream(data, filesRequiredFields, parsingProgress) {
// ignoring it and returns all file data to be aggregated for next iteration
// file start line data saved in startFileDataLine
//
// iterating ignore the last part since output ends with "\n\n" and
// in case the last byte of the streamed chunked data is '\n' we want to remove it and append it to next chunk
// since we use split("\n") and we might mistakenly identify the it as delimiter
// for example the following if "\n\na" is split and streamed in two chunks "\n\n" and "a" will get different results,
// to prevent that will ignore last '\n' in data and append it to next chunk
// > "\n\na".split("\n")
// [ '', '', 'a' ]
// > "\n\n".split("\n")
// [ '', '', '' ]
// Note that iteration ignores the last part for
// case that the last byte of the streamed chunked data is '\n' we want to remove it and append it to next chunk
// since we use split("\n") and we might mistakenly identify it as delimiter (parsing the file's data as two files)
//
// for example, if the following streams in two chunks:
// Path = allowed_image.jpg
// Folder = -
// Size = 34530
// Packed Size = 28839
// Modified = 2016-02-29 19:01:01
// Created = 2016-02-29 19:01:01
// Accessed = 2016-02-29 19:01:01
// Attributes = ....A
// Encrypted = +
// Comment =
// CRC = 2A63718C
// Method = ZipCrypto Deflate
// Host OS = FAT
// Version = 20
//
// chunk 1:
// Path = allowed_image.jpg
// Folder = -
// Size = 34530
// Packed Size = 28839
// Modified = 2016-02-29 19:01:01
// Created = 2016-02-29 19:01:01
// Accessed = 2016-02-29 19:01:01
//
// chunk 2:
// Attributes = ....A
// Encrypted = +
// Comment =
// CRC = 2A63718C
// Method = ZipCrypto Deflate
// Host OS = FAT
// Version = 20
//
//
// Since output ends with "\n\n" the las file in the stream should be parsed successfully
return lines.slice(startFileDataLine).join("\n");
}
// finish to parse the file, adding it to parsingProgress.files
Expand Down

0 comments on commit 8e24384

Please sign in to comment.