Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two question #1

Open
qcscofield opened this issue Nov 11, 2021 · 6 comments
Open

Two question #1

qcscofield opened this issue Nov 11, 2021 · 6 comments

Comments

@qcscofield
Copy link

  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.

@ankitrohatgi
Copy link
Owner

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

@qcscofield
Copy link
Author

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?

@ankitrohatgi
Copy link
Owner

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.

@qcscofield
Copy link
Author

qcscofield commented Nov 12, 2021

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.

@ChuckIsReady
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants