file system case sensitive

I use Keil's file system on a NXP ARM with SD Card. I want to create filenames in lowercase, but when I initialise a string, e.g. strcpy(file_str, "myfile.dat") and do a fopen() with that name it creates a file using uppercase letters.

By chance I found that if I do a strcat after I initialised the string, e.g. strcat(file_str, "_anything") and then do a fopen() the file is created with lowercase letters.

Can someone explain this and how can I create files using lowercase letters?

Parents
  • Why lowercase? The FAT file system may be able to store files with lower case, but it is a file system where case is not expected to matter, i.e. you are not expected to store two files with names only differing in case.

    Because of this, a fopen of "charlie.txt" should match "charlie.txt", "Charlie.Txt", "Charlie.TXT", "CHARLIE.TXT", "ChArLiE.TxT", ...

    The normal way to solve this is to always convert all names to either upper or lower case before performing a match. An fopen operation intended to create a file must do this, to verify that the new file name does not collide with any other name already in that directory.

    In the end, the Keil FS is optimized to use a minimum of data and code space, so it isn't unreasonable that they do convert all file names to a fixed case before doing any real work. The alternative would to always use stricmp(), but in some situations this function may be a bit slow because of the extra work it needs to do for every character comparison.

Reply
  • Why lowercase? The FAT file system may be able to store files with lower case, but it is a file system where case is not expected to matter, i.e. you are not expected to store two files with names only differing in case.

    Because of this, a fopen of "charlie.txt" should match "charlie.txt", "Charlie.Txt", "Charlie.TXT", "CHARLIE.TXT", "ChArLiE.TxT", ...

    The normal way to solve this is to always convert all names to either upper or lower case before performing a match. An fopen operation intended to create a file must do this, to verify that the new file name does not collide with any other name already in that directory.

    In the end, the Keil FS is optimized to use a minimum of data and code space, so it isn't unreasonable that they do convert all file names to a fixed case before doing any real work. The alternative would to always use stricmp(), but in some situations this function may be a bit slow because of the extra work it needs to do for every character comparison.

Children
More questions in this forum