Page 1 of 1

[FATFS] filename and extension not preserving case-sensitive style

Posted: Tue Apr 17, 2018 9:08 am
by davdav
Hi everybody,

We use file system FATFS to store some files. File should be saved with "case-sensitive" name (i.e. "FOO.txt" is different from "foo.txt"). However I have checked that FATFS choose at its rights the name and extension upper-case, lower-case or camel-case..

In practice if I write a file with name "foo.TXT" with code

Code: Select all

	FILE *fp = fopen("/D/SYSTEM/foo.TXT", "w");

	if (fp != NULL)
	{
		if (fclose(fp) == 0)
		{
			Error = FALSE;
		}
	}
and then I read the dicrtory with code

Code: Select all

DIR* dir;				// pointer to the scanned directory.
struct dirent* entry;	// pointer to one directory entry.

dir = opendir("/D/SYSTEM");
if (!dir)
{
	ESP_LOGD(TAG_FS, "Failed to open dir %s for reading:%d", stringIn, errno);
}
else
{
	// scan the directory
	while ((entry = readdir(dir)))
	{
		ESP_LOGD(TAG_FS, "file:%s", entry->d_name);
	}
	
	closedir(dir);
}
I got from debug

Code: Select all

D (2568348) fs: file:foo.txt
In practice the extension of the file has been lower-cased. Is it correct a behaviuor like this?

Shouldn't I rely on the case sensitive of FATFS?

Thanks

Re: [FATFS] filename and extension not preserving case-sensitive style

Posted: Tue Apr 17, 2018 9:38 am
by ESP_Sprite
FAT filesystems always are case-insensitive, as far as I know. (See here, page 30: "All types of search operations within the file system (i.e. find, open, create, delete, rename) are case-insensitive.") I think Linux has a mode to mount it case-sensitively, but that's more-or-less a hack.

Re: [FATFS] filename and extension not preserving case-sensitive style

Posted: Tue Apr 17, 2018 10:45 am
by davdav
Thank you @ESP_sprite, in effect it seems FAT is case-insensitive and my approach was wrong.

So we need to find another solution to "sign" a file..

Thanks