Using an FreeRTOS + FAT library, following the 8.3 format if DirectoryName/FolderName exceeds 8 character then it is truncating the space.
example: fold/Dir Name: Test Folder–> it is showing as "TestFo~"1
but expecting it as “Test F~1”
As far as I know, there is no “official” defined method for generating the short (8.3) name for a long file name. Using the space in the short name is problematic, as it says the name must be quoted to be used on command lines, so some algorithms will drop them when shortening the name.
mkdir "Test Folder"
dir /x
Thu, 05-Sep-24 14:02 <DIR> TESTFO~1 Test Folder
When creating a 8.3 filename that already exists, a number may be added, which can range from “~1” to “~999999” in order to find a unique 8.3 filename.
The space in “Test Folder” has been removed in “TESTFO”.
So the latest possible attempt to create an 8.3 filename would be “T~999999”.
This function determines which characters are valid and which aren’t:
Thanks for the Reply @htibosch.
Expecting space in dir/fol name should like ex: Test Folder → Test Fo~1.
if the dir name is less than <8 characters including space,
it will display like : “Test Fol” → “Test Fol”.
Made changes in FF_ValidShortChar(), space is valid character.
Got it, But I have requirement to enable the space in folder name. as attached image expecting folder name “NEW FO~1”
if it is 8.3 format, dir name is less than 8character with space. then space will not be truncated.
This will be checking SD card. exa: “Test Fol”—> "Test Fol "
I think I am missing something here. The link Hein shared above, says that 8.3 filename cannot contain space. You say that you have a requirement to have space in the name. Are you saying that you have a requirement to be non-complaint? What is the reasoning?
My guess is this is a result of 8.3 being just a “de-facto” standard that wasn’t actually formally defined as to its rules, only the example implementations of it by Microsoft (and other code writers) that were not consistent. From what I remember, it was quite possible in the DOS days to create filenames in programs that were non-complaint with there ability to be used in other parts of the system. File/Directory names with spaces was one such feature, which might need quotes around them in some contexts.
This is a bit like the fact that in Unix, a file name is actually built of ANY arbitray sequence of bytes, with just the values of 0 and 47 decimal (the character ‘/’) being special, 0 being the end of the name and 47 decimal separating the name into path levels. Parts of DOS just took the 11 bytes as is, but other parts put restrictions on them, allowing the creation of “impossible” file names.
Any program that requires using an 8.3 file name that doesn’t meet the simplest definition (being just an 8.3 name built of the basic allowed characters, which don’t include space) is asking to have problems. It especially shouldn’t assume a given conversion from a long file name, that makes me think the program really was expecting a file system with long file names, and then hacked to work on an 8.3 system.