Community
cancel
Showing results for 
Search instead for 
Did you mean: 
SergeyKostrov
Valued Contributor II
88 Views

Using short file names ( 8-dot-3 ) instead of long file names

Everybody knows that short file names ( 8-dot-3 ) could be used instead of long file names
with a C/C++ compiler option '/I' or with '#include "..."' directives in a C source file.

Are there any hidden problems with short file names when used on a Windows platform with NTFS
file system? My answer is Yes.

I recently lost almost 2 hours when a project build failed and it was unclear why it happened.
When I finally understood what happened I reproduced a problem.

Let's say there is a C source file with a directive:

...
#include "../Test/ThisIs~1.abc" // Long name is 'ThisIsTest.abc'
...

Do the following steps in a folder 'Test':

Step 1: Create a file 'ThisIsTest.abc'
Step 2: Create a copy 'ThisIsTest.bak.abc' of the file 'ThisIsTest.abc'
Step 3: Rename the file 'ThisIsTest.abc' to 'ThisIsTest.old.abc'
Step 4: Rename the file 'ThisIsTest.bak.abc' to 'ThisIsTest.abc'
Step 5: Delete the file 'ThisIsTest.old.abc'

Result is as follows:

When a C/C++ compiler will try to compile the C source file with a directive

...
#include "../Test/ThisIs~1.abc" // Long name is 'ThisIsTest.abc'
...

it won't find 'ThisIs~1.abc' file because it no longer exists! Instead, there is afile 'ThisIs~2.abc'!

Please take a look at enclosed screenshot from a test computer:


41310-TestFor8dot3File.jpg
0 Kudos
6 Replies
JenniferJ
Moderator
88 Views

Interesting. My guess is that you're developing platform independent code. This is a good tip.

Thanks for sharing.

Jennifer
SergeyKostrov
Valued Contributor II
88 Views

Just in case I've done the same steps, desribed in my initial post,on aFAT32 file system of a flash drive.
A final shortname was:

'ThisIs~1.abc'

It meansthat NTFS and FAT32 are a little bit "incompatible" when a short file name is assignedto a file.
andrewop_p_
Beginner
88 Views

Hello

you are welcome

for shorting a long file name, long path tool is the best option, try it.

 

.................

jimdempseyatthecove
Black Belt
88 Views

The short file name can be considered a hash code concatenated with ~SequenceNumber when the hash code cannot be unique.

Name collisions in the hash code are common. Upon collision, the SequenceNumber is generated such that it is unique for that particular hash code (in that specific directory). This means, depending on sequence of file creation, the ~SequenceNumber appendage may differ from time to time and/or from system to system as you have shown. It is the programmers responsibility to take this into consideration. This is not a fault of the file system.

*** This includes not assuming PROGRA~1 is "Program Files".

Windows could conceivably be (and most likely has been) installed on a DOS system supporting LFN's and having a preexisting folder named "Program Listings" or "Program anything else here".

Jim Dempsey

SergeyKostrov
Valued Contributor II
88 Views

>>...for shorting a long file name, long path tool is the best option, try it... That problem was detected and solved more than two years ago. Also, it is applicable Only for cases when 16-bit compilers, like Turbo C++ v3.x or OpenWatcom v2.x, are used. Thanks for your interest.
SergeyKostrov
Valued Contributor II
88 Views

>>...Just in case I've done the same steps, desribed in my initial post,on aFAT32 file >>system of a flash drive. A final shortname was: >> >> 'ThisIs~1.abc' Try to reproduce the problem on a legacy Windows XP Professional operating system.
Reply