On approximately 7/8/2005 2:07 PM, came the following characters from
the keyboard of demerphq:
On 7/8/05, Michael G Schwern wrote:
On Fri, Jul 08, 2005 at 03:50:49PM +0200, demerphq wrote:

Im not sure if this is useful, but many of the things that File::Spec
tries to do on win32 are actually supported directly by the Win32 API.
IMO at least some of File::Spec's behaviour could take advantage of
this API.

Win32::GetFullPathName() is the one i have in mind when I say this.

perl -e "use Win32; print Win32::GetFullPathName(qq[foo\\..\\bar]);"

outputs "CWD\bar".

So if you strip off the CWD from the result of
Win32::GetFullPathName() you get the OS'es solution of this problem,
which should bypass all of these issues.
Does it? It still leaves us asking the question: can we assume foo\..\bar ==
bar on Windows? Just because a system call does it that way doesn't mean
its right.

Well, i suppose you are correct. Im not entirely sure what scenario I
should be testing here, but i beleive the problem you are thinking of
is due to symlinks to a directory? If so then the win32 equivelent
would be a junction I think and in that case yes, foo\..\bar == bar.

D:\dev\junct>junction foo

Junction v1.03 - Win2K junction creator and reparse point viewer
Copyright (C) 2000-2002 Mark Russinovich
Systems Internals - http://www.sysinternals.com

D:\dev\junct\foo: JUNCTION
Substitute Name: d:\dev\test

D:\dev\junct>echo Test1 > foo\..\test.echo

D:\dev\junct>type test.echo

D:\dev\junct>cd ..

D:\dev>echo test2 > test\..\test.echo

D:\dev>type test.echo
OK, you have just proven that the file is the same whether accessed by
one name or the other. Now that you have the junction set up, how about
reporting on the results of:

md \dev\junct\bar
cd \dev\junct
cd foo\..\bar
cd ..
cd foo
cd ..
cd \dev\test
cd foo\..\bar
cd ..
cd foo
cd ..

showing all the prompts that display the current path name in the sequence?

And even then, one would have to test the function of GetFullPathName
separately, but if a discrepancy shows up in the above test, then
foo\..\bar != bar all the time.
Anyhow, should this discussion drag on any longer without resolution there's
a simple yardstick to use: Which retains the most information? Not
collapsing .. does.
Actually, if you knew that GetFullPathName was sensitive to and properly
handled junction points, and it collapsed the name, you would get more
information that way.
So given that the current implementation is clearly
wrong, and if we can't decide between the two right implementations, pick
the one that's safest to at least give a correct answer. Then we can
discuss some more and maybe have switch to the other one.

Sure. My comment was mostly that by using the Win32 API's one can do
this type of stuff more reliably than with File::Spec. With the
emphasis intended to be more on "this type of stuff" than on the
particular problem that lead to this thread.

To be honest i would really like to see the expected behaviour of
canonpath when called on a relative path explicitly defined. IMO
canonpath should act more like rel2abs, insofar as it should support
an optional $base argument to use instead of CWD when trying to clean
up a relative path.
Glenn -- http://nevcal.com/
Having identified a vast realm of ignorance, Wolfram is saying that much
of this realm lies forever outside the light cone of human knowledge.
-- Michael Swaine, Dr Dobbs Journal, Sept 2002

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 11 of 19 | next ›
Discussion Overview
groupperl5-porters @
postedJul 6, '05 at 9:00p
activeJul 12, '05 at 1:15a



site design / logo © 2022 Grokbase