The thing is, the file is extracted to a location which is the
directory name of the archived file. So the -dir option has no
effect.
I'm assuming that the manual is not consistent with the source code.
Is this true or am I wrong?
Rich schrieb am Dienstag, 25. Oktober 2022 um 14:45:56 UTC+2:
Alexandru <alexandr...@meshparts.de> wrote:
The thing is, the file is extracted to a location which is theYou have the source code to the tar module. A little looking into that
directory name of the archived file. So the -dir option has no
effect.
I'm assuming that the manual is not consistent with the source code.
Is this true or am I wrong?
file and you can answer your own question about why, with your inputs
[*], the code is not acting in the way you expect based on what the
documentation says.
[*] This part is rather important. We could look, but without knowing
what the exact strings were, we might miss the reason why it seems to
be not working as documented for you.
Thanks. Indeed, I looked now and it seems, that the documentation is promissing somthing that is not implemented in the code. According
to the docs, the -file option can be a full path, not only the "tail"
of the path:
-file fileName Only extract the file with this name. The name is
matched against the complete path stored in the archive including directories.
The dir option only states:
-dir dirName Directory to extract to. Uses pwd if none is
specified
So it should work with both full path names and path tails.
In the untar procedure, the row 34 does
set name [file join $dir $name]
So it assumes, that, when dir is specified, the name is only the tail
or at least a relative to dir.
Would you confirm the above?
I will modify the source code and see if I can commit it to the
repository.
Alexandru <alexandr...@meshparts.de> wrote:
The thing is, the file is extracted to a location which is the
directory name of the archived file. So the -dir option has no
effect.
I'm assuming that the manual is not consistent with the source code.You have the source code to the tar module. A little looking into that
Is this true or am I wrong?
file and you can answer your own question about why, with your inputs
[*], the code is not acting in the way you expect based on what the documentation says.
[*] This part is rather important. We could look, but without knowing
what the exact strings were, we might miss the reason why it seems to
be not working as documented for you.
Alexandru <alexandr...@meshparts.de> wrote:
Rich schrieb am Dienstag, 25. Oktober 2022 um 14:45:56 UTC+2:
Alexandru <alexandr...@meshparts.de> wrote:
The thing is, the file is extracted to a location which is theYou have the source code to the tar module. A little looking into that
directory name of the archived file. So the -dir option has no
effect.
I'm assuming that the manual is not consistent with the source code.
Is this true or am I wrong?
file and you can answer your own question about why, with your inputs
[*], the code is not acting in the way you expect based on what the
documentation says.
[*] This part is rather important. We could look, but without knowing
what the exact strings were, we might miss the reason why it seems to
be not working as documented for you.
Thanks. Indeed, I looked now and it seems, that the documentation is promissing somthing that is not implemented in the code. According
to the docs, the -file option can be a full path, not only the "tail"
of the path:
-file fileName Only extract the file with this name. The name isThat's not my reading of the documentation for -file.
matched against the complete path stored in the archive including directories.
The docs state the string given to "-file" is "matched against the full
path" which is stored in the tar file. It is defining how the string
given to -file is used to decide if a tar entry is suitable for
extraction, but not explicitly stating that the -file string should be
a full path itself. Note that it also does not exclude the string
given to -file from being a partial or full path, so at best it is
slightly ambigious as to whether the code was written to provide for
the string given as the -file parameter containing a path and a name simultaneously.
The dir option only states:
-dir dirName Directory to extract to. Uses pwd if none is
specified
So it should work with both full path names and path tails.I'd say it is ambigious when -file is a full path (from the docs
alone).
In the untar procedure, the row 34 does
set name [file join $dir $name]
So it assumes, that, when dir is specified, the name is only the tail
or at least a relative to dir.
Would you confirm the above?You are correct as to line 34, but you missed mentioning line 28 which
does:
set name [string trimleft $header(prefix)$header(name) /]
Which, provided name is not a windows path with drive letter, would
convert name into a relative path. Note that 'name' is the name stored
inside the tar header for the file.
I'm betting your tar file contains entries with names that look like
this:
c:/Users/User/dir/dir/file
And so line 28 is not removing leading / characters because of the
stupid windows drive letter leftover from the msdos world.
I will modify the source code and see if I can commit it to theYes, there is a 'bug', in that the code did not consider the possible
repository.
full path names that can occur from windows when converting names from
the tar file into relative paths.
About fixing the bug...
I'll nee a function that checks if a file path is absolute or not.
I was thinking something like this below, but not sure if this still works for Linux OS:
proc ::tar::isabsolute {path} {
return [expr {[string match -nocase [file normalize $path] $path]}]
}
Is this platform independent?
Hi Alexandru,Thanks Paul, completly forgot about that one (I'm actually using it in my code).
Use the Tcl command "file pathtype" for this task.
Paul
Am 25.10.2022 um 18:38 schrieb Alexandru:
About fixing the bug...
I'll nee a function that checks if a file path is absolute or not.
I was thinking something like this below, but not sure if this still works for Linux OS:
proc ::tar::isabsolute {path} {
return [expr {[string match -nocase [file normalize $path] $path]}]
}
Is this platform independent?
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 463 |
Nodes: | 16 (2 / 14) |
Uptime: | 156:55:37 |
Calls: | 9,384 |
Calls today: | 4 |
Files: | 13,561 |
Messages: | 6,095,919 |