Thread overview
[Issue 7001] New: std.path.baseName and isValidFilename wrong documentation
Nov 24, 2011
Andrej Mitrovic
Nov 24, 2011
Andrej Mitrovic
Dec 07, 2011
Jonathan M Davis
Dec 07, 2011
Andrej Mitrovic
Dec 07, 2011
Jonathan M Davis
Dec 26, 2011
Jonathan M Davis
November 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7001

           Summary: std.path.baseName and isValidFilename wrong
                    documentation
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-11-24 12:59:09 PST ---
"Returns the name of a file, without any leading directory and with an optional suffix chopped off. "

It should be:
Returns the name of a file *or directory*, without any leading directory and
with an optional suffix chopped off.

Note the assert:
assert (baseName("dir/subdir/") == "subdir");

Secondly:
isValidFilename
"Checks that the given file or directory name is valid. "
should be:
"Checks that the given file name is valid."

It does *not* verify directory names, only filenames.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 24, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7001



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-11-24 13:00:44 PST ---
(In reply to comment #0)
> "Returns the name of a file, without any leading directory and with an optional suffix chopped off. "
> 
> It should be:
> Returns the name of a file *or directory*, without any leading directory and
> with an optional suffix chopped off.
> 

That refers to std.path.baseName.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7001


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-12-06 21:05:51 PST ---
And how does isValidFilename not validate directory names?

There's no really zero difference between a file and a directory as far as paths go except anything to the left of the rightmost directory separator must be a directory or drive. I believe that both std.path and std.file have a tendancy to use the term file even when it applies to directories - which is fairly typical in such documentation, I believe - though in some cases it can be confusing. Already, as far Posix is concerned, what you'd typically refer to as a file would be a "regular" file rather than a file.

In any case, baseName is arguably correct as-is, though it certainly wouldn't hurt to add "or directory" to it, and I don't see what's incorrect about isValidFilename. It validates a file or directory name. The only complaint in that regard that I can think of that you might be making is the fact that something like "dir/" would return false for it, and since directory separators are invalid in both directory and file names, I don't see that as a problem. So, unless you have another argument that I can't think of, I don't know what your issue with isValidFilename could be.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7001



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-12-06 23:00:04 PST ---
(In reply to comment #2)
> and since directory separators
> are invalid in both directory and file names

Why are they invalid in directory names?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 07, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7001



--- Comment #4 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-12-06 23:14:01 PST ---
If you have /dir or dir/, the name of the directory is dir, not /dir, or dir/. It is illegal on Posix systems to have a directory name with / in it, just like it's illegal on Windows systems to have a directory name with \ in it. A _path_ can have the directory separator for the current OS in it, but not a file or directory name, and isValidFilename is checking file _names_, not paths.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7001


Lars T. Kyllingstad <bugzilla@kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@kyllingen.net


--- Comment #5 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2011-12-26 11:37:55 PST ---
Here, "file" means a node in a file system, and it encompasses normal files as well as directories, symbolic links, named pipes, device files and sockets.

In that sense, "file or directory" may be redundant.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=7001



--- Comment #6 from Jonathan M Davis <jmdavisProg@gmx.com> 2011-12-26 14:02:45 PST ---
I believe that Posix at least uses the term regular file for normal files, and then still uses the term file for everything. It _can_ be a bit confusing, but I don't know a better way to go about it. Unfortunately, the term file can be ambiguous due to differences in its usage.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 01, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7001


Lars T. Kyllingstad <bugzilla@kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


--- Comment #7 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2012-02-01 14:33:48 PST ---
It seems the confusion has been cleared up, so I'm closing this.  If anyone still disagrees, please reopen.

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