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
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]Not familiar with the tar package, but don't you need to open the
zlib push gunzip $f
set result [tar::untar $f -chan]
close $f
zipfile in binary mode when reading?
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:
Indeed, that is what the documentation explicitly states:set f [open $zipfile]Not familiar with the tar package, but don't you need to open the
zlib push gunzip $f
set result [tar::untar $f -chan]
close $f
zipfile in binary mode when reading?
::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.
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
Alexandru <[email protected]> wrote:
I really searched the internet for a documentation of tar package.If you were using a sane os, then the documentation would be available locally on your machine from any shell by typing:
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.
man n tar
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.If you were using a sane os, then the documentation would be available
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.
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.
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.
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.If you were using a sane os, then the documentation would be available
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.
locally on your machine from any shell by typing:
man n tar
I respect all OSs (both Linux and Windows). Both are great in theirUse != Development -- Development /can/ occur on a different platform.
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.
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 theExcept that:
Tcl documentation is hard to find.
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.
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.
On 10/21/2022 6:26 PM, Alexandru wrote:Hi Ashok, that's a fast search engine you have there. I'll bookmark it and try to make it my default search page.
I really searched the internet for a documentation of tar package.Perhaps https://www.magicsplat.com/tcl-docs/docindex.html which contains
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.
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
Alexandru,even to cross check various Tcl stuff on both worlds simultaneously.
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
HTH,
Christian
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 714 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 133:48:11 |
| Calls: | 12,087 |
| Files: | 14,997 |
| Messages: | 6,517,349 |