I want to make a check in the preprocessor if the file system is case-insensitive.
Till now I was assuming macOS always has case-insensitive paths, but recently I read that it depends on file system.
I just needed a way to make this check in #if
, so I can set my array size accordingly.
This would be a very bad idea unless you have very specific needs. One system can have multiple file systems, where some are case sensitive and some are not. That's not even unusual. This alone proves that the task is impossible to solve in the general case. It's theoretically possible to do this at compile time for a given path. But to make it even worse, these circumstances can change. Let's say that your program read and/or writes to /path/to/data
, and then the user decides to replace the file system with something else. Now your program is broken.
The best solution for most problems related to this is probably to not assume anything about the case sensitiveness during compilation. Find out during execution instead.
But one thing worth mentioning is that modern case insensitive filesystems do preserve the original case of the filename. An example of a filesystem that is non case preserving is FAT used in the old MS-DOS, but that filesystem is very rare today. You will find it hard to find someone who is not a retro-fan using them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With