std.path.getName(): Screwy by design?
Jonathan M Davis
jmdavisProg at gmx.com
Tue Mar 1 08:32:05 PST 2011
On Tuesday 01 March 2011 05:35:38 Steven Schveighoffer wrote:
> On Tue, 01 Mar 2011 08:13:33 -0500, Lars T. Kyllingstad
>
> <public at kyllingen.nospamnet> wrote:
> > On Tue, 01 Mar 2011 08:02:44 -0500, Steven Schveighoffer wrote:
> >> On Tue, 01 Mar 2011 04:16:36 -0500, Jonathan M Davis
> >>
> >> <jmdavisProg at gmx.com> wrote:
> >>> I can understand if the path stuff
> >>> can't deal with / or \ in file names (that's probably not worth trying
> >>> to get to
> >>> work right), but it _should_ be able to handle directories with dots in
> >>> them and
> >>> files with no extension.
> >>
> >> / and \ are not legal in names on any filesystem that I know of.
> >>
> >> -Steve
> >
> > On a *NIX machine, try
> >
> > touch "c:\\foo\\bar"
> >
> > You may be surprised. ;)
>
> bleh... that seems useless :) I purposely checked FAT before posting,
> because I was sure Unix disallowed backslashes, I wanted to make sure FAT
> didn't allow slashes.
>
> Holy crap, something that DOS got right and Unix didn't!
>
> From this page: http://en.wikipedia.org/wiki/Filename, it appears that
> really, the only disallowed character in unix filenames is '/'. Even '*'
> is allowed as a filename. How... horrible.
Actually, a number of unix file systems allow / in the name too. The extX file
systems don't, but reiserFS, btrfs, and XFS are some of those which do. The only
character which is _certain_ that it can't be valid in a file name, I believe is
NUL. However, given how much of a royal pain it would be to handle / correctly
in file names and how so few programs are able to handle files with / in their
name, I don't think that it's worth trying to make std.path handle file names
with / in them correctly. _Maybe_ it should handle \ correctly on Linux, but
even then, I'd argue that it shouldn't be trying to special case it.
Now, as for other characters like * or :, I've found it to be _very_ useful to
be able to put those in file names - particularly when ripping music - and the
fact that Windows is far more restrictive in what it allows in file names is
highly annoying. I _like_ the fact that Linux lets you put pretty much any
character in a file name. I do think that trying to fully support / and \ is
pushing it however - particularly since it's highly unlikely that they'll be
handled correctly by other programs anyway. Too many programmers have already
assumed that they aren't legal characters in file names.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list