Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Path-Tiny-0.028 Path::Tiny on win32 turns C:/ or C:\ into C: / absolute / realpath are broken

by xdg (Monsignor)
on Aug 19, 2013 at 10:49 UTC ( #1050011=note: print w/ replies, xml ) Need Help??


in reply to Path-Tiny-0.028 Path::Tiny on win32 turns C:/ or C:\ into C: / absolute / realpath are broken

FYI: This has been opened as issue #49.

Does this break on Linux

It should. So that's a test suite coverage failure.

I think I have a fix, but I have a broader question:

Is there any reason to allow a raw volume like "C:" (no trailing slash) or "\\server\share" as a Path::Tiny "path"? Or should I be fixing those to have a trailing slash so they are properly understood as referencing the root directory of those volumes?

Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.


Comment on Re: Path-Tiny-0.028 Path::Tiny on win32 turns C:/ or C:\ into C: / absolute / realpath are broken
Re^2: Path-Tiny-0.028 Path::Tiny on win32 turns C:/ or C:\ into C: / absolute / realpath are broken
by Corion (Pope) on Aug 19, 2013 at 10:58 UTC

    I would say that there is a misconception. C: does not reference the root directory of a volume. It references the current working directory of that volume.

    You should either prohibit this or handle it properly, not silently convert to something else, especially not a root directory. I think the failure mode of converting C: to C:/ is a very bad one:

    my $p= path("C:"); unlink $_ for $p->children;

    For UNC paths, I see no such bad failure mode of appending a trailing directory separator.

      C: does not reference the root directory of a volume

      I understand that. What I'm trying to get guidance on is how likely it is that people would use "C:" and not mean the root directory.

      If I understand you correctly, what probably needs to happen is to immediately turn C: into the absolute path for cwd on that volume via getdcwd.

      Is that right?

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

        Yes. I would consider it highly likely that people use the system as documented.

        Yes, getcwd getdcwd is the function that needs to get involved to make C: resolve correctly.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1050011]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2014-10-26 06:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (151 votes), past polls