Skip to content

Commit

Permalink
Parser: skip over "total xxxx" lines in dir output
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Apr 5, 2015
1 parent a40cc36 commit 73aa844
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/parser.js
Expand Up @@ -7,6 +7,7 @@ var XRegExp = require('xregexp').XRegExp;

var REX_LISTUNIX = XRegExp.cache('^(?<type>[\\-ld])(?<permission>([\\-r][\\-w][\\-xstT]){3})(?<acl>(\\+))?\\s+(?<inodes>\\d+)\\s+(?<owner>\\S+)\\s+(?<group>\\S+)\\s+(?<size>\\d+)\\s+(?<timestamp>((?<month1>\\w{3})\\s+(?<date1>\\d{1,2})\\s+(?<hour>\\d{1,2}):(?<minute>\\d{2}))|((?<month2>\\w{3})\\s+(?<date2>\\d{1,2})\\s+(?<year>\\d{4})))\\s+(?<name>.+)$'),
REX_LISTMSDOS = XRegExp.cache('^(?<month>\\d{2})(?:\\-|\\/)(?<date>\\d{2})(?:\\-|\\/)(?<year>\\d{2,4})\\s+(?<hour>\\d{2}):(?<minute>\\d{2})\\s{0,1}(?<ampm>[AaMmPp]{1,2})\\s+(?:(?<size>\\d+)|(?<isdir>\\<DIR\\>))\\s+(?<name>.+)$'),
RE_ENTRY_TOTAL = /^total/,
RE_RES_END = /(?:^|\r?\n)(\d{3}) [^\r\n]*\r?\n/,
RE_EOL = /\r?\n/g,
RE_DASH = /\-/g;
Expand Down Expand Up @@ -205,7 +206,7 @@ Parser.parseListEntry = function(line) {
info.date = new Date(year, month - 1, day, hour, mins);

ret = info;
} else
} else if (!RE_ENTRY_TOTAL.test(line))
ret = line; // could not parse, so at least give the end user a chance to
// look at the raw listing themselves

Expand Down

0 comments on commit 73aa844

Please sign in to comment.