Sign in to follow this  
supagu

[linux] case insensitive opening file

Recommended Posts

im porting code from windows to linux and then it dawns on me my data isnt loading as linux is case sensitive! so now i have to port my data! is there anyway i can do a canse insensitive fopen in c/c++ for linux?

Share this post


Link to post
Share on other sites
Not to my knowledge.
But is it so big a problem to have the names passed to fopen reflect the actual case-sensitive filenames?

Share this post


Link to post
Share on other sites
Let's say your application uses ResourceManager application. RM for short.

You call that application as RM -r under windows, and it will rebuild the index.

Now on linux you can't, since caps matter. So rather than complicate, you simply convert everything to lower or upper case, it doesn't matter.

So then you just end up running rm -r. And hilarity ensues.

Different capitalization means different files. Converting blindly between the two is Bad Idea(tm). Especially if running as root.

[BAD IDEA]
One way to do it is to convert your filenames to lowercase, then pass lowercase strings to fopen.
[BAD IDEA]

Other than that, manually change the filenames to be consistent. This has nothing to do with C++, but prevents a whole bunch of problems.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this