FAQ

On 7/9/05, Glenn Linderman wrote:
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
Test1

D:\dev\junct>cd ..

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

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

d:
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?
im not sure if your script exploited the structure i set up properly or not.

I had d:\dev\junct\foo -> d:\dev\test

so creating a directory in junct doesnt create it in test. Heres the
full output with me adding directories to resolve the "cant find
directory" errors. I ran the script you requested three times as
"junct.bat".

D:\dev>junction junct\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.bat

D:\dev>d:

D:\dev>md \dev\junct\bar

D:\dev>cd \dev\junct

D:\dev\junct>cd foo\..\bar

D:\dev\junct\bar>cd ..

D:\dev\junct>cd foo

D:\dev\junct\foo>cd ..

D:\dev\junct>cd \dev\test

D:\dev\test>cd foo\..\bar
The system cannot find the path specified.

D:\dev\test>cd ..

D:\dev>cd foo
The system cannot find the path specified.

D:\dev>cd ..

D:\>cd dev\test

D:\dev\test>dir
Volume in drive D is Data
Volume Serial Number is C836-51DB

Directory of D:\dev\test

2005-07-08 16:24 <DIR> .
2005-07-08 16:24 <DIR> ..
2005-07-08 16:24 6 foo.txt
1 File(s) 6 bytes
2 Dir(s) 69,569,888,256 bytes free

D:\dev\test>md foo

D:\dev\test>cd ..

D:\dev>junct.bat

D:\dev>d:

D:\dev>md \dev\junct\bar
A subdirectory or file \dev\junct\bar already exists.

D:\dev>cd \dev\junct

D:\dev\junct>cd foo\..\bar

D:\dev\junct\bar>cd ..

D:\dev\junct>cd foo

D:\dev\junct\foo>cd ..

D:\dev\junct>cd \dev\test

D:\dev\test>cd foo\..\bar
The system cannot find the path specified.

D:\dev\test>cd ..

D:\dev>cd foo
The system cannot find the path specified.

D:\dev>cd ..

D:\>cd dev\test

D:\dev\test>dir
Volume in drive D is Data
Volume Serial Number is C836-51DB

Directory of D:\dev\test

2005-07-09 08:35 <DIR> .
2005-07-09 08:35 <DIR> ..
2005-07-09 08:35 <DIR> foo
2005-07-08 16:24 6 foo.txt
1 File(s) 6 bytes
3 Dir(s) 69,569,888,256 bytes free

D:\dev\test>cd foo

D:\dev\test\foo>cd ..

D:\dev\test>md bar

D:\dev\test>cd ..

D:\dev>junct.bat

D:\dev>d:

D:\dev>md \dev\junct\bar
A subdirectory or file \dev\junct\bar already exists.

D:\dev>cd \dev\junct

D:\dev\junct>cd foo\..\bar

D:\dev\junct\bar>cd ..

D:\dev\junct>cd foo

D:\dev\junct\foo>cd ..

D:\dev\junct>cd \dev\test

D:\dev\test>cd foo\..\bar

D:\dev\test\bar>cd ..

D:\dev\test>cd foo

D:\dev\test\foo>cd ..

D:\dev\test>



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

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 16 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