Skip Menu |

This queue is for tickets about the File-System CPAN distribution.

Report information
The Basics
Id: 13514
Status: resolved
Priority: 40/40
Queue: File-System

People
Owner: hanenkamp [...] cpan.org
Requestors: hanenkamp [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.13
Fixed in: 1.14



Subject: basename returns '' for the root instead of '/'
I got an email from Zev Benjamin stating: Hi Andrew, I've been using the various File::System modules for a project of mine and noticed that calling basename on a File::System::Object that is the root of the file system returns the empty string. This stems from the fact that File::Basename, which your modules use, have this behavior. There has been Perl mailing list traffic that indicates that the behavior is unlikely to change due to backwards compatibility reasons. However, it is still arguably the incorrect bahavior. I just wanted to bring this to your attention and ask whether your modules' behavior are likely to change in the future with respect to basename. Also note that the POD for File::System::Object states under dirname, 'If the object represents the root path of the file system (i.e., .. = .), then it is possible that "basename" = "dirname" = "path".' Zev
Zev sent me links to the specific conversations about dirname: http://aspn.activestate.com/ASPN/Mail/Message/perl5-porters/2725798 http://aspn.activestate.com/ASPN/Mail/Message/perl5-porters/2725713 Because I insist on using Unix-style naming conventions in the VFS and because these conversations state that dirname() and basename() are defined arbitrarily and because the behavior could change (though, it would appear it won't for now), I'm probably just going to invent my own implementation. Probably, I'll just split paths on '/' and pop the last non-empty entry. I.e., dirname("/test/path/") = "/test" dirname("/test/path") = "/test" dirname("/test/") = "/" dirname("/test") = "/" dirname("/") = "/" I'll probably do this by reducing traling slashes to nothing and multiple neighboring slashes to a single slash. That would probably be the most consistent way I can think of.
The behavior has been changed so that the basename of "/" is "/" and so is the dirname. The behavior should now always match the documentation.