Proposal for std.path replacement

spir denis.spir at gmail.com
Mon Mar 7 05:32:23 PST 2011


On 03/07/2011 01:08 PM, Lars T. Kyllingstad wrote:
>> Alternately, we could ignore the distinction between file and directory
>> >  - as we're essentially just parsing strings here - and have two
>> >  functions:
>> >
>> >  lastComponent("dir/subdir/")  ->  "subdir" lastComponent("dir/subdir")
>> >  ->  "subdir"
>> >
>> >  allButLastComponent("dir/subdir/") ->  "dir/"
>> >  allButLastComponent("dir/subdir")  ->  "dir/"
> That's how it's done now, and how I think it should be.  The two paths
> "dir/subdir" and "dir/subdir/" both refer to the same object in the file
> system, namely "subdir".  baseName gives you the name of the object
> referred to by a path, while dirName gives you the directory containing
> said object.  Whether that object is a file or a directory is
> irrelevant.  (And if you need to know what it is, there is always
> std.file.isDir and isFile.)

After some more thought, I think you are right on this point. Precisely because 
of possible trailing '/'. If OSes were clearer and more consistent, then we 
could and certainly should make a useful semantic distinction.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list