On 21 January 2018 at 16:07, Stefan Bodewig <bode...@apache.org> wrote:
> On 2018-01-05, Torsten Curdt wrote:
>
>>>>    TarArchiveEntry("C:\foo\bar") -> "/foo/bar"
>>>>    TarArchiveEntry("D:\foo\bar") -> "/foo/bar"
>
>>> "strip the drive letter" predates preserveLeadingSlashes
>
>> Might be but I guess the only question is how to fix it without breaking
>> too many things.
>> I am not such a big fan of "preserveLeadingSlashes" either.
>
> We inherited that from Ant and it really stems from a rather odd usecase
> over there.
>
>>> I could be convinced that we should only strip drive letters when we
>>> don't preserve leading slashes either :-)
>
>> IMO there is just no case at all when compress should strip drive letters.
>> Sure it might be convenient (for some) but this is too much magic.
>
> Again, I have no idea what tar ports do on Windows. By now all my
> Windows instances run the Linux subsystem if I want to use tar.
>
> This is what GNU tar does on Linux:
>
> $ tar cf x.tar /tmp
> tar: Removing leading `/' from member names
>
> so us stripping leading slashes by default is completely in line with
> what the CLI tar does.
>
>>> Usually tar archives do not contain absolute path names at all.
>
>> Which is also why the current constructors have a huge potential of
>> ambiguity and misinterpretation IMO.
>
> I've just now changed the javadocs to explicitly state how names get
> constructed. I've left out documenting what happens to drive letters so
> I don't need to change it depending on the outcome of this discussion :-)
>
>> If it should be relative and you pass a File - relative to what?
>
> It is File.getPath() so it is the string argument passed to the File
> constructor.
>
>> It might be worth checking with Windows users to see what the expected
>> behaviour might be.
>
> Allow me to point out that this has been the behavior of the class for
> far more than ten years and no Windows user has ever complained.
> Neither here nor in Ant land. This may indicate the behavior is not too
> surprising. It may also indicate that most people really only want to
> use relative file names regardless of platform.

Any other behaviour is potentially dangerous so must be optional.

>> But even then - I still think silently stripping is the wrong thing to
>> do.
>
> The contract of tar archives is they contain relative path names. GNU
> tar strips leading slashes both when creating archives and when
> extracting archives who's entry names contain leading slashes. Sticking
> with that contract I still believe we should remove leading slashes by
> default - and removing the drive letters is the Windows equivalent of it
> IMHO. That's why I suggest to keep the drive letter in the
> preserveLeadingSlashes == true case.

I would expect the Windows default behaviour to generate/use relative
names only.
This means dropping both the drive letter *and* any leading \ or /.

Optionally, tar should be able to preserve/use absolute path names.
But the user must specify this.

> Cheers
>
>         Stefan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to