FAQ

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
Test1

D:\dev\junct>cd ..

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

D:\dev>type test.echo
test2
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. 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.


--
perl -Mre=debug -e "/just|another|perl|hacker/"

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

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

People

Translate

site design / logo © 2022 Grokbase