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

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

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

Postby davdav » Tue Apr 17, 2018 9:08 am

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

ESP_Sprite
Posts: 9020
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Tue Apr 17, 2018 9:38 am

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.

davdav
Posts: 208
Joined: Thu Nov 17, 2016 2:33 pm

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

Postby davdav » Tue Apr 17, 2018 10:45 am

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

Who is online

Users browsing this forum: No registered users and 186 guests