std.path review: second update

Jesse Phillips jessekphillips+d at gmail.com
Mon Aug 1 22:41:11 PDT 2011


On Mon, 01 Aug 2011 20:50:21 +0000, Jonathan M Davis wrote:

st my pragmatic, Windows-sentric view of things :)
> 
> The problem with that is that then you _can't_ have something like
> "foo..bar". Granted, that's not a normal thing to do, but it would be
> problematic if it ever happened.

You can, you just wouldn't build it with these functions. And frankly if 
you are using these then you probably wouldn't want foo..bar and wouldn't 
care that it ended up foo.bar or foo..bar. You just want the proper 
extension on the proper name, which is what you'd get.
 
> The primary danger I see with using null for no extension and empty for
> "." is
> 
> assert(extension("file.") == extension("file"));
> 
> That could cause problems for any program that actually runs into a file
> which ends with a ".". Now, if Linux, Windows, and Mac OS X all prevent
> files ending in a dot (which I seriously doubt), then it isn't really an
> issue. Having the difference between null and empty does make it
> possible to distinguish if you start doing stuff like

I disagree, that assertion should pass. They both have the same 
extension. If you really want to know if a file name ends in a dot,

assert("file."[$-1] == ".");

I just don't see a case where you'd be dealing with these too files and 
care to know the extension is explicitly empty or umm just empty.


More information about the Digitalmars-d mailing list