[filesystem] is path comparison case-insensitive on Windows?

Hi, I couldn't find this info in the Filesystem documentation, so I thought I'd ask here: is equality comparison between path objects case-insensitive on Windows? I think it ought to be, since the operating system treats two paths differing by case only to be the same, but I thought I'd double-check. Thanks, Nate

On 15 June 2012 07:12, Nathan Ridge
I couldn't find this info in the Filesystem documentation, so I thought I'd ask here: is equality comparison between path objects case-insensitive on Windows?
Two paths are compared using lexicographical comparison, it says in the docs. Looking at the implementation, it is case-sensitive lexicographical order. BTW, the documentation only points "Case sensitivity is a property of the pathname itself, and not the platform" So, IMO it is correct to assume filesystem::path is case-sensitive regardless OS. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net

Hello,
On Fri, Jun 15, 2012 at 4:55 AM, Mateusz Loskot
On 15 June 2012 07:12, Nathan Ridge
wrote: I couldn't find this info in the Filesystem documentation, so I thought I'd ask here: is equality comparison between path objects case-insensitive on Windows?
Two paths are compared using lexicographical comparison, it says in the docs. Looking at the implementation, it is case-sensitive lexicographical order.
BTW, the documentation only points
"Case sensitivity is a property of the pathname itself, and not the platform"
I would suggest that case sensitivity is a property of the file system, not the path name and certainly not the platform. In our product we use boost::filesystem extensively in a cross-platform context, and we always check case sensitivity whenever we see a file system that we haven't seen before. The check consists in taking the name of a known file in the new file system, converting it to upper or lower case depending on the current state of the name, and checking whether the converted name exists or not. This of course will fail in a situation where the files hello and HELLO exist in the same directory, but we assume that case is an aberration. Cheers, Will
So, IMO it is correct to assume filesystem::path is case-sensitive regardless OS.
Best regards, -- Mateusz Loskot, http://mateusz.loskot.net _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Isn't it what you want? http://www.boost.org/libs/filesystem/v3/doc/reference.html#equivalent

Hello, On Fri, Jun 15, 2012 at 1:35 PM, Paulo Márcio Figueiredo Alves < pauloalves1986@gmail.com> wrote:
Isn't it what you want? http://www.boost.org/libs/filesystem/v3/doc/reference.html#equivalent
No, because I don't want hard links to be equivalent. Cheers, Will
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Isn't it what you want? http://www.boost.org/libs/filesystem/v3/doc/reference.html#equivalent
Not quite. Suppose I want to test whether a file has a "jpg" extension (case insensitive on Windows). I would like to be able to do: path file = ...; path jpeg_ext = ".jpg"; ... if (file.extension() == jpeg_ext) and have the comparison return true for "something.JPG" on Windows. I can't do if (file.extension().equivalent(jpeg_ext)) because equivalent() requires that one of the paths exists(). So what should I do instead? #if __WIN32__ if (iequals(file.extension().string(), jpeg_ext.string()) #else if (file.extension() == jpeg_ext) #endif seems like I'm doing the library's job here... Regards, Nate

Hello,
On Fri, Jun 15, 2012 at 3:41 PM, Nathan Ridge
Isn't it what you want? http://www.boost.org/libs/filesystem/v3/doc/reference.html#equivalent
Not quite. Suppose I want to test whether a file has a "jpg" extension (case insensitive on Windows). I would like to be able to do:
That would be case insensitive on NTFS, not on all Windows file systems.
path file = ...; path jpeg_ext = ".jpg"; ... if (file.extension() == jpeg_ext)
and have the comparison return true for "something.JPG" on Windows.
I can't do
if (file.extension().equivalent(jpeg_ext))
because equivalent() requires that one of the paths exists().
So what should I do instead?
#if __WIN32__ if (iequals(file.extension().string(), jpeg_ext.string())
You can't check whether a file system is case sensitive at compile time. Cheers, Will
#else if (file.extension() == jpeg_ext) #endif
seems like I'm doing the library's job here...
Regards, Nate
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Isn't it what you want? http://www.boost.org/libs/filesystem/v3/doc/reference.html#equivalent
Not quite. Suppose I want to test whether a file has a "jpg" extension (case insensitive on Windows). I would like to be able to do:
That would be case insensitive on NTFS, not on all Windows file systems.
path file = ...; path jpeg_ext = ".jpg"; ... if (file.extension() == jpeg_ext)
and have the comparison return true for "something.JPG" on Windows.
I can't do
if (file.extension().equivalent(jpeg_ext))
because equivalent() requires that one of the paths exists().
So what should I do instead?
#if __WIN32__ if (iequals(file.extension().string(), jpeg_ext.string())
You can't check whether a file system is case sensitive at compile time.
Good point. It just reinforces my point, which is that the library should take care of this rather than the user having to. Regards, Nate

On 2012-06-15 22:41, Nathan Ridge wrote:
Isn't it what you want? http://www.boost.org/libs/filesystem/v3/doc/reference.html#equivalent
Not quite. Suppose I want to test whether a file has a "jpg" extension (case insensitive on Windows). I would like to be able to do:
path file = ...; path jpeg_ext = ".jpg"; .... if (file.extension() == jpeg_ext)
and have the comparison return true for "something.JPG" on Windows.
In this particular case, you should really use case-insensitive comparison on /all/ platforms (and check for ".jpeg" in addition to ".jpeg"). It's not unusual to find files with an uppercase ".JPG" extension on case-sensitive file systems. -- Rainer Deyke (rainerd@eldwood.com)
participants (5)
-
Mateusz Loskot
-
Nathan Ridge
-
Paulo Márcio Figueiredo Alves
-
Rainer Deyke
-
Will Mason