Path as an object in std.path

Michel Fortin michel.fortin at michelf.ca
Thu Jun 6 13:02:43 PDT 2013


On 2013-06-06 17:27:28 +0000, Walter Bright <newshound2 at digitalmars.com> said:

> That doesn't work for case sensitivity/insensitivity differences nor 
> does it work for drive letters like "C:" (which don't exist on Apple 
> systems, hence they can afford to dismiss them).

Have you never opened a local file in a windows web browser and took a 
look at the URL? The drive letter is there.

	file:///c:/path/to/the%20file.txt

The drive letter is simply the first part of the path on Windows.


> But there's no getting around the fact that "File" and "file" are 
> different paths under Windows, and are the same under Linux.

Actually, it doesn't depend on Linux or Windows or OS X. It depends on 
the filesystem used, be it FAT16, FAT32, NTFS, ext{1,2,3}, HFS+, 
Case-sensitive HFS+, etc. If you assume a specific case sensitivity 
setting by looking at the OS, that's a bug. You can mount NTFS and FAT 
on Linux or OS X, and Apple has Case-sensitive HFS+ for OS X and its 
the default on iOS. Then there's the whole issue about which locale to 
use for Unicode case-insensitive comparisons. I'd bet that different 
filesystems choose different approaches to this tricky problem.

So there's no way to normalize for case-sensitivity just by looking at 
a path or a URL, even if you know on which OS you're on. If you want to 
know for sure whether two paths are the same, or what is the normalized 
path, you need to ask the filesystem at some point. Anything else is 
based on fragile assumptions.


-- 
Michel Fortin
michel.fortin at michelf.ca
http://michelf.ca/



More information about the Digitalmars-d mailing list