http://d.puremagic.com/issues/show_bug.cgi?id=7002


Jonathan M Davis <jmdavisp...@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisp...@gmx.com
           Platform|Other                       |All
         OS/Version|Windows                     |All


--- Comment #3 from Jonathan M Davis <jmdavisp...@gmx.com> 2011-11-27 20:14:40 
PST ---
The _only_ way to know for sure if a path points to a file is to use std.file -
typically either std.file.isFile on a string or isFile on a std.file.DirEntry.

The fact that a path does not end in a directory separator does not say
anything about whether it's a directory or a file. As such, depending on
whether it does or not seems like a bad idea. A path which _does_ end in a
directory separator _is_ directory (assuming that the path is valid), but the
lack of one means nothing.

isValidFilename essentially assumes that it's getting the base name of a file
or directory and verifies that it's valid. isValidPath essentilally splits on
the directory separator and calls isValidFilename on each of those components
(I believe that it's somewhat more complicated than that, but that's
essentially what it's doing. So, isValidFilename is going to return false if
the name that it's given contains a directory separator and isValidPath doesn't
care about the directory separator, since it's effectively splitting on it. In
_neither_ case are they concerned about whether ending in a directory separator
or not indicates a file or a directory.

So, if you want a function which returns whether a particular path is
definitively for a directory or not (i.e. ends in a directory separator), then
a new one needs to be created as opposed to changing what any of the current
functions are doing. But it seems to me that if you want to do _that_, all you
need to do is

assert(path.endsWith(dirSeparator));

What are you looking for beyond that?

As I said, the _lack_ of a directory separator doesn't mean that the path is
for a file, so you can only _really_ know if you use std.file.isFile. So, given
that and the fact that endsWith will tell you whether a path ends with a
directory separator, I'm not sure what more you're really looking for here.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to