tarballjs
tarballjs copied to clipboard
Two question
-
I read a tgz file have some LongLink named files. What is it? {name: '././@LongLink', type: 'L', size: 105, header_offset: 16896}
-
Some files read out named txxx./flash_all_except_storage0000775. It should named txxx./flash_all_except_storage.sh. What is 0000755 mean ?
Thank you author.
Hey, I have not yet implemented the support for longer file+path names. The current implementation only supports tarballs that are in total 100 characters or less in length - there's some extra logic needed to handle longer paths that is not yet implemented. I think that is what you are running into
Hi,
100byte filename like blew: 512(header)+512(content)*n+512(end)
Do you know how the longer file+path names store in disk ? for example: (1300) 512(header)+512(only-long-name)+512(only-long-name)+512(content)*n+512(end) Is that how it works?
It's been some time since I dug deep into tar documentation, perhaps this is more helpful: https://stackoverflow.com/questions/2078778/what-exactly-is-the-gnu-tar-longlink-trick
btw, I am curious about what you are using for unzipping the tarball from tgz
to tar
. I am also curious why you didn't pick some other package for this :) I made this simple tarball utility to unblock myself when working on WebPlotDigitizer.
I found an article using your code, so I used it. Most of the other decompression tools are node based and I don’t need them. I use it for decompress flash rom tar. Thank you very much.
This is a very good library and easy to use. It is also the only tar library on GitHub that I can run correctly on the browser. I think it is as good as jszip, but it may not get the same number of stars because of the lack of a good readme.
Back to the main point, I'm making a data import package for mock system. Its data structure is server address / interface name / mock scene, so it is very easy to exceed 100 characters. I look forward to your improving the function of long string name. Thank you very much!
supportLongFileName(name, opts) {
if (name.length > 100) {
let te = new TextEncoder();
let arr = te.encode(name);
this.fileData.push({
name: '././@LongLink',
array: arr,
type: 'longLink',
size: arr.length,
dataType: 'array',
opts: opts,
});
}
}
addFolder(name, opts) {
this.supportLongFileName(name, opts);
this.fileData.push({
name: name,
type: 'directory',
size: 0,
dataType: 'none',
opts: opts,
});
}
addTextFile(name, text, opts) {
this.supportLongFileName(name, opts);
let te = new TextEncoder();
let arr = te.encode(text);
this.fileData.push({
name: name,
array: arr,
type: 'file',
size: arr.length,
dataType: 'array',
opts: opts,
});
}
_writeFileType(typeStr, header_offset) {
// offset: 156
let typeChar = '0';
if (typeStr === 'file') {
typeChar = '0';
} else if (typeStr === 'directory') {
typeChar = '5';
} else if (typeStr === 'longLink') {
typeChar = 'L';
}
let typeView = new Uint8Array(this.buffer, header_offset + 156, 1);
typeView[0] = typeChar.charCodeAt(0);
}
by rewrite this four fn, it support long file name, hahah :D