tarballjs icon indicating copy to clipboard operation
tarballjs copied to clipboard

Two question

Open qcscofield opened this issue 2 years ago • 6 comments

  1. I read a tgz file have some LongLink named files. What is it? {name: '././@LongLink', type: 'L', size: 105, header_offset: 16896}

  2. 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.

qcscofield avatar Nov 11 '21 06:11 qcscofield

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

ankitrohatgi avatar Nov 11 '21 07:11 ankitrohatgi

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?

qcscofield avatar Nov 11 '21 08:11 qcscofield

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.

ankitrohatgi avatar Nov 11 '21 18:11 ankitrohatgi

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.

qcscofield avatar Nov 12 '21 03:11 qcscofield

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!

ChuckIsReady avatar Aug 26 '22 04:08 ChuckIsReady

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

ChuckIsReady avatar Aug 29 '22 07:08 ChuckIsReady