• Pack and Unpack archive of multiple files and directories

    From Alexandru@21:1/5 to All on Fri Oct 21 01:34:30 2022
    I'm creating using the tar package to create an archive of multiple files and directories.
    Since I could not find a manual for the tar package, I had to read the source code and other forums online to get close to a solution, which is not working right now.

    The method used to create the archive is:

    set fd [open $zipfile wb]
    zlib push gzip $fd -level 9
    tar::create $fd $paths -chan
    close $fd

    where as $paths a list of full file paths is.
    Creating the archive works.

    Here is the code to unpack the same archive:

    set f [open $zipfile]
    zlib push gunzip $f
    set result [tar::untar $f -chan]
    close $f

    I get this type of error:
    couldn't open "<filename> 100644 0 0 226212 1432372742" : filename is invalid on this platform

    Seems like the untar package cannot handle correctly multiple file names in the header.
    The first file name in ther archive is handled correctly. The second one is somehow cut in the middle and instead following data is attached to the file name.

    Is this a bug? Or am I using the wrong method to unpack?

    Many thanks
    Alexadru

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ashok@21:1/5 to Alexandru on Fri Oct 21 15:08:05 2022
    Not familiar with the tar package, but don't you need to open the
    zipfile in binary mode when reading?

    /Ashok

    On 10/21/2022 2:04 PM, Alexandru wrote:
    I'm creating using the tar package to create an archive of multiple files and directories.
    Since I could not find a manual for the tar package, I had to read the source code and other forums online to get close to a solution, which is not working right now.

    The method used to create the archive is:

    set fd [open $zipfile wb]
    zlib push gzip $fd -level 9
    tar::create $fd $paths -chan
    close $fd

    where as $paths a list of full file paths is.
    Creating the archive works.

    Here is the code to unpack the same archive:

    set f [open $zipfile]
    zlib push gunzip $f
    set result [tar::untar $f -chan]
    close $f

    I get this type of error:
    couldn't open "<filename> 100644 0 0 226212 1432372742" : filename is invalid on this platform

    Seems like the untar package cannot handle correctly multiple file names in the header.
    The first file name in ther archive is handled correctly. The second one is somehow cut in the middle and instead following data is attached to the file name.

    Is this a bug? Or am I using the wrong method to unpack?

    Many thanks
    Alexadru

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Ashok on Fri Oct 21 12:43:04 2022
    Ashok <[email protected]> wrote:
    On 10/21/2022 2:04 PM, Alexandru wrote:
    I'm creating using the tar package to create an archive of multiple
    files and directories. Since I could not find a manual for the tar
    package, I had to read the source code and other forums online to
    get close to a solution, which is not working right now.

    Here is the code to unpack the same archive:

    set f [open $zipfile]
    zlib push gunzip $f
    set result [tar::untar $f -chan]
    close $f

    Not familiar with the tar package, but don't you need to open the
    zipfile in binary mode when reading?

    Indeed, that is what the documentation explicitly states:

    ::tar::untar tarball args
    Extracts tarball. -file and -glob limit the extraction
    to files which exactly match or pattern match the given
    argument. No error is thrown if no files match. Returns
    a list of filenames extracted and the file size. The
    size will be null for non regu- lar files. Leading path
    seperators are stripped so paths will always be relative.

    ...

    -chan If this option is present tarball is
    interpreted as an open channel. **It is assumed
    that the channel was opened for reading, and
    configured for binary input.** The com- mand will
    not close the channel.

    Presuming that the sample code was copied from Alexandru's codebase,
    the issue here is failing to set the channel to binary mode after
    opening it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Rich on Fri Oct 21 05:56:46 2022
    Rich schrieb am Freitag, 21. Oktober 2022 um 14:43:08 UTC+2:
    Ashok <[email protected]> wrote:
    On 10/21/2022 2:04 PM, Alexandru wrote:
    I'm creating using the tar package to create an archive of multiple
    files and directories. Since I could not find a manual for the tar
    package, I had to read the source code and other forums online to
    get close to a solution, which is not working right now.

    Here is the code to unpack the same archive:

    set f [open $zipfile]
    zlib push gunzip $f
    set result [tar::untar $f -chan]
    close $f

    Not familiar with the tar package, but don't you need to open the
    zipfile in binary mode when reading?
    Indeed, that is what the documentation explicitly states:

    ::tar::untar tarball args
    Extracts tarball. -file and -glob limit the extraction
    to files which exactly match or pattern match the given
    argument. No error is thrown if no files match. Returns
    a list of filenames extracted and the file size. The
    size will be null for non regu- lar files. Leading path
    seperators are stripped so paths will always be relative.

    ...

    -chan If this option is present tarball is
    interpreted as an open channel. **It is assumed
    that the channel was opened for reading, and
    configured for binary input.** The com- mand will
    not close the channel.

    Presuming that the sample code was copied from Alexandru's codebase,
    the issue here is failing to set the channel to binary mode after
    opening it.

    I really searched the internet for a documentation of tar package.
    It's only now that I searched using "tcl lib ::tar::untar" and could get to the documentation page.
    For example searching "tcl tk tar package" doesn't help.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Ashok on Fri Oct 21 05:51:50 2022
    Ashok schrieb am Freitag, 21. Oktober 2022 um 11:38:07 UTC+2:
    Not familiar with the tar package, but don't you need to open the
    zipfile in binary mode when reading?

    /Ashok
    On 10/21/2022 2:04 PM, Alexandru wrote:
    I'm creating using the tar package to create an archive of multiple files and directories.
    Since I could not find a manual for the tar package, I had to read the source code and other forums online to get close to a solution, which is not working right now.

    The method used to create the archive is:

    set fd [open $zipfile wb]
    zlib push gzip $fd -level 9
    tar::create $fd $paths -chan
    close $fd

    where as $paths a list of full file paths is.
    Creating the archive works.

    Here is the code to unpack the same archive:

    set f [open $zipfile]
    zlib push gunzip $f
    set result [tar::untar $f -chan]
    close $f

    I get this type of error:
    couldn't open "<filename> 100644 0 0 226212 1432372742" : filename is invalid on this platform

    Seems like the untar package cannot handle correctly multiple file names in the header.
    The first file name in ther archive is handled correctly. The second one is somehow cut in the middle and instead following data is attached to the file name.

    Is this a bug? Or am I using the wrong method to unpack?

    Many thanks
    Alexadru

    Indeed. Thanks Ashok for the tip. That was the issue.
    This works now and I get a list of file paths.
    Also Umlaute look fine the Tcl console, so I guess unpacking the archive with Tcl should solve the encoding problem.

    set f [open $zipfile rb]
    zlib push gunzip $f
    set result [tar::untar $f -chan]
    close $f

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Rich on Fri Oct 21 06:39:43 2022
    Rich schrieb am Freitag, 21. Oktober 2022 um 15:35:06 UTC+2:
    Alexandru <[email protected]> wrote:
    I really searched the internet for a documentation of tar package.
    It's only now that I searched using "tcl lib ::tar::untar" and could
    get to the documentation page. For example searching "tcl tk tar
    package" doesn't help.
    If you were using a sane os, then the documentation would be available locally on your machine from any shell by typing:

    man n tar

    I respect all OSs (both Linux and Windows). Both are great in their own way. But I use Windows because most desktop engineers are using Windows.
    I strongly believe that the Tcl should be more available to Windows users, in order to have a bright future.
    Telling me to go and use another OS won't solve the issue that the Tcl documentation is hard to find.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Alexandru on Fri Oct 21 14:14:26 2022
    Alexandru <[email protected]> wrote:
    Rich schrieb am Freitag, 21. Oktober 2022 um 15:35:06 UTC+2:
    Alexandru <[email protected]> wrote:
    I really searched the internet for a documentation of tar package.
    It's only now that I searched using "tcl lib ::tar::untar" and could
    get to the documentation page. For example searching "tcl tk tar
    package" doesn't help.
    If you were using a sane os, then the documentation would be available
    locally on your machine from any shell by typing:

    man n tar

    I respect all OSs (both Linux and Windows). Both are great in their
    own way. But I use Windows because most desktop engineers are using
    Windows. I strongly believe that the Tcl should be more available to
    Windows users, in order to have a bright future.

    Use != Development -- Development /can/ occur on a different platform.
    I write Tcl tools for myself that I use on $job's windows machine by
    creating them on Linux.

    Telling me to go and use another OS won't solve the issue that the
    Tcl documentation is hard to find.

    Except that:

    1) no one in the Tcl world controls how google handles their searches,
    nor what google returns, so there is little the Tcl world can do to
    make random google searches work better

    2) to get usefulness from a google search, the individual entering the
    search has to warp their search input string around googles
    limitations.

    Searching: "tcllib documentation" in google returns this as the top
    hit:

    Standard Tcl Library (tcllib)

    Clicking it results in this page:

    https://www.tcl.tk/software/tcllib/

    On that page is this link:

    HTML documentation

    Clicking it results in this page:

    https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/toc.md

    Doing a local "find in page" for "tar" (the name of the module is
    "tar") results in finding this link down the page:

    tar Tar file creation, extraction & manipulation

    clicking that results in this page appearing:

    https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/tar/tar.md

    Which finally provides the html version of the tcllib tar manual page.


    One can do all of the above, vs, on an OS where 'man' works, locally
    typing:

    man n tar

    To get the same docs, without needing to jump through the google hoops
    to get there.


    It seems there is a different google search string that is quicker, but
    only because the wiki links to the manpage.

    Entering "tcllib documentation tar" into google returns (for me at
    least) as the top link this wiki page:

    https://wiki.tcl-lang.org/page/Tcllib+tar

    Which under the "Documentation" header at the top of that page is a
    link to the html tar module docs.

    So only two links away instead of about four (and dependent upon the
    fact that someone added the documentation link to the wiki page). But
    still two "further clicks" away vs. immediate direct local access.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Alexandru on Fri Oct 21 13:35:02 2022
    Alexandru <[email protected]> wrote:
    I really searched the internet for a documentation of tar package.
    It's only now that I searched using "tcl lib ::tar::untar" and could
    get to the documentation page. For example searching "tcl tk tar
    package" doesn't help.

    If you were using a sane os, then the documentation would be available
    locally on your machine from any shell by typing:

    man n tar

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Rich on Fri Oct 21 08:03:32 2022
    Rich schrieb am Freitag, 21. Oktober 2022 um 16:14:30 UTC+2:
    Alexandru <[email protected]> wrote:
    Rich schrieb am Freitag, 21. Oktober 2022 um 15:35:06 UTC+2:
    Alexandru <[email protected]> wrote:
    I really searched the internet for a documentation of tar package.
    It's only now that I searched using "tcl lib ::tar::untar" and could
    get to the documentation page. For example searching "tcl tk tar
    package" doesn't help.
    If you were using a sane os, then the documentation would be available
    locally on your machine from any shell by typing:

    man n tar

    I respect all OSs (both Linux and Windows). Both are great in their
    own way. But I use Windows because most desktop engineers are using Windows. I strongly believe that the Tcl should be more available to Windows users, in order to have a bright future.
    Use != Development -- Development /can/ occur on a different platform.
    I write Tcl tools for myself that I use on $job's windows machine by creating them on Linux.
    Telling me to go and use another OS won't solve the issue that the
    Tcl documentation is hard to find.
    Except that:

    1) no one in the Tcl world controls how google handles their searches,
    nor what google returns, so there is little the Tcl world can do to
    make random google searches work better

    2) to get usefulness from a google search, the individual entering the search has to warp their search input string around googles
    limitations.

    Searching: "tcllib documentation" in google returns this as the top
    hit:

    Standard Tcl Library (tcllib)

    Clicking it results in this page:

    https://www.tcl.tk/software/tcllib/

    On that page is this link:

    HTML documentation

    Clicking it results in this page:

    https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/toc.md

    Doing a local "find in page" for "tar" (the name of the module is
    "tar") results in finding this link down the page:

    tar Tar file creation, extraction & manipulation

    clicking that results in this page appearing:

    https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/tcllib/files/modules/tar/tar.md

    Which finally provides the html version of the tcllib tar manual page.


    One can do all of the above, vs, on an OS where 'man' works, locally
    typing:

    man n tar

    To get the same docs, without needing to jump through the google hoops
    to get there.


    It seems there is a different google search string that is quicker, but
    only because the wiki links to the manpage.

    Entering "tcllib documentation tar" into google returns (for me at
    least) as the top link this wiki page:

    https://wiki.tcl-lang.org/page/Tcllib+tar

    Which under the "Documentation" header at the top of that page is a
    link to the html tar module docs.

    So only two links away instead of about four (and dependent upon the
    fact that someone added the documentation link to the wiki page). But
    still two "further clicks" away vs. immediate direct local access.

    Some things I would like to add:

    I don't use google search engine. I use DuckDuckGo, but there isn't much difference between the two reagarding the results (if I use google, I use it in prive mode so that there is no influence from the search history, DuckDuckGo works like this by
    design).

    The manual page provided (https://core.tcl-lang.org/tcllib/doc/trunk/embedded/md/toc.md) does not contain the typical html keywords, which are parsed by search engines. So I think there is indeed something that can be done to improve the online
    documentation.

    Having to use some Windows specific packages in my Tcl/tk app, I don't see how I could develop on Linux. Besides: I don want to, since that would mean to have two different OSs installed on my laptop.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ashok@21:1/5 to Alexandru on Fri Oct 21 20:53:04 2022
    On 10/21/2022 6:26 PM, Alexandru wrote:

    I really searched the internet for a documentation of tar package.
    It's only now that I searched using "tcl lib ::tar::untar" and could get to the documentation page.
    For example searching "tcl tk tar package" doesn't help.

    Perhaps https://www.magicsplat.com/tcl-docs/docindex.html which contains
    a searchable index of Tcl+extensions might help (shameless plug).

    Or https://www.magicsplat.com/tcl-docs/docindex.html?search=tar would
    list the relevant pages.

    /Ashok

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Ashok on Fri Oct 21 10:20:12 2022
    Ashok schrieb am Freitag, 21. Oktober 2022 um 17:23:09 UTC+2:
    On 10/21/2022 6:26 PM, Alexandru wrote:

    I really searched the internet for a documentation of tar package.
    It's only now that I searched using "tcl lib ::tar::untar" and could get to the documentation page.
    For example searching "tcl tk tar package" doesn't help.
    Perhaps https://www.magicsplat.com/tcl-docs/docindex.html which contains
    a searchable index of Tcl+extensions might help (shameless plug).

    Or https://www.magicsplat.com/tcl-docs/docindex.html?search=tar would
    list the relevant pages.

    /Ashok
    Hi Ashok, that's a fast search engine you have there. I'll bookmark it and try to make it my default search page.
    But then again, your site was not found by normal internet seach.
    Could you make the results indexable by the crawlers?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Werner@21:1/5 to All on Fri Oct 21 14:48:07 2022
    Alexandru,

    you could try out to install WSL on your Windows development system with a decent Debian in it to be one mouse click away of invoking the apropriate "man ..." command. The currently easiest way to have both worlds at your fingertips. Which enables you
    even to cross check various Tcl stuff on both worlds simultaneously.

    HTH,
    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alexandru@21:1/5 to Christian Werner on Fri Oct 21 16:15:32 2022
    Christian Werner schrieb am Freitag, 21. Oktober 2022 um 23:48:09 UTC+2:
    Alexandru,

    you could try out to install WSL on your Windows development system with a decent Debian in it to be one mouse click away of invoking the apropriate "man ..." command. The currently easiest way to have both worlds at your fingertips. Which enables you
    even to cross check various Tcl stuff on both worlds simultaneously.

    HTH,
    Christian

    Thanks Christian.
    WSL is awsome, had no idea that it's so easy to use Linux on Windows.
    I will need more than one reason to start using it though. For now.
    I like how efficient Linux OS is. Such a pitty, that Windows rules the world...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)