Proposal for std.path replacement

"Jérôme M. Berger" jeberger at free.fr
Sun Mar 6 09:04:12 PST 2011


spir wrote:
> On 03/06/2011 09:37 AM, Rainer Schuetze wrote:
>> Looks good overall. I have a few comments and nitpicks though:
> 
> I think all your questions are sensible, Rainer.
> 
>>>    basename("dir/subdir/")             -->  "subdir"
>>>    directory("dir/subdir/")      -->  "dir"
>>
>> Is this what everybody expects? I'm not sure, but another possibility
>> would be
>> to treat these as if "dir/subdir/." is passed. What is the result of
>> directory("/") or directory("d:/")?
> 
> Depends. We must make clear whether such funcs work:
> 1. indifferently for file and dir names, in which case we get the above
> results,
> 2. differently for file & dir names, in which case we would have
> "dir/subdir/" as result of both operations above,
> 3. only for file names, in which case we throw an error when these
> functions are called on dir names.
> 
> I find both solutions 1. and 2. conceptually problematic; the second one
> only a bit less. Maybe the only sensible choice is 3.?
> 
	This does not make sense because there is no way to tell whether
"foo/bar" is intended as a file name or a dir name. IMO the only
sensible thing to do is to split on the last path separator:
everything to the right is the base name (or everything if there is
no separator) and everything to the left is the dir name. This has
the two very important advantages:

- It is a simple rule, so is easy to remember;

- It does not need the path to exists and it does not need to know
whether the path is intended as a file or dir.

		Jerome
-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20110306/f1ba8c23/attachment.pgp>


More information about the Digitalmars-d mailing list