Skip to content
Permalink
Browse files

Remove Tessel struct-fu 8to16 workaround

Fixes: #22
  • Loading branch information...
Juan Cruz Viotti
Juan Cruz Viotti committed Dec 7, 2015
1 parent 3db5606 commit 969edb46e7e5f971318d997e70bcfd7770870111
Showing with 9 additions and 10 deletions.
  1. +9 −10 dir.js
19 dir.js
@@ -268,26 +268,25 @@ dir.addFile = function (vol, dirChain, entryInfo, opts, cb) {
var workaroundTessel427 = ('\uFFFF'.length !== 1);
var S_lde_f = S.longDirEntry.fields,
ENTRY_CHUNK_LEN = (S_lde_f.Name1.size + S_lde_f.Name2.size + S_lde_f.Name3.size)/2,
paddedName = (workaroundTessel427) ? require('struct-fu/8to16').fixString(name) : name,
partialLen = paddedName.length % ENTRY_CHUNK_LEN,
partialLen = name.length % ENTRY_CHUNK_LEN,
paddingNeeded = partialLen && (ENTRY_CHUNK_LEN - partialLen);
if (workaroundTessel427) {
if (paddingNeeded--) paddedName.push(0);
while (paddingNeeded-- > 0) paddedName.push(0xFFFF);
if (paddingNeeded--) name.push(0);
while (paddingNeeded-- > 0) name.push(0xFFFF);
} else {
if (paddingNeeded--) paddedName += '\u0000';
while (paddingNeeded-- > 0) paddedName += '\uFFFF';
if (paddingNeeded--) name += '\u0000';
while (paddingNeeded-- > 0) name += '\uFFFF';
}
// now fill in as many entries as it takes
var off = 0,
ord = 1;
while (off < paddedName.length) entries.push({
while (off < name.length) entries.push({
Ord: ord++,
Name1: paddedName.slice(off, off+=S_lde_f.Name1.size/2),
Name1: name.slice(off, off+=S_lde_f.Name1.size/2),
Attr_raw: S.longDirFlag,
Chksum: null,
Name2: paddedName.slice(off, off+=S_lde_f.Name2.size/2),
Name3: paddedName.slice(off, off+=S_lde_f.Name3.size/2)
Name2: name.slice(off, off+=S_lde_f.Name2.size/2),
Name3: name.slice(off, off+=S_lde_f.Name3.size/2)
});
entries[entries.length - 1].Ord |= S.lastLongFlag;
}

0 comments on commit 969edb4

Please sign in to comment.
You can’t perform that action at this time.