Proposal for std.path replacement

Regan Heath regan at netmail.co.nz
Mon Mar 7 02:17:44 PST 2011


On Sat, 05 Mar 2011 16:32:55 -0000, Lars T. Kyllingstad  
<public at kyllingen.nospamnet> wrote:
> The only disagreement seems to be about the naming, so let's have a round
> of voting.  Here are a few alternatives for each function.  Please say
> which ones you prefer.
>
>  * dirSeparator, dirSep, sep
>  * currentDirSymbol, currentDirSym, curDirSymbol
>  * basename, baseName, filename, fileName
>  * dirname, dirName, directory, getDir, getDirName
>  * drivename, driveName, drive, getDrive, getDriveName
>  * extension, ext, getExt, getExtension
>  * stripExtension, stripExt

Is it just me that feels dirName and getDirName are ambiguous?

i.e. in the path:
   c:\temp\folder\name\file.ext

There are 3 directories:
  - Their "names" are 'temp', 'folder' and 'name'
  - Their "paths" are c:\temp, c:\temp\folder and c:\temp\folder\name

It's the reason I think baseName is clearer than fileName, with fileName  
you're not sure if it means the complete/full filename including  
directories or just the filename itself, with or without extension.  
baseName (perhaps once you're used to the idea of it) implies the shorter  
form.  In fact.. why not call baseName on directories too, to remove the  
leading path components.

e.g.

getDir("c:\temp\folder\name\file.ext")           -> "c:\temp\folder\name"
baseName(getDir("c:\temp\folder\name\file.ext")) -> "name"

-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list