• We should now be fully online following an overnight outage. Apologies for any inconvenience, we do not expect there to be any further issues.

FAT32 Question

AndyHui

Administrator Emeritus<br>Elite Member<br>AT FAQ M
Oct 9, 1999
13,141
17
81
It uses at least one file allocation unit.

The first allocation unit is required for the file itself. Additional file allocation units are used for the Long File Name, one for every 13 characters or part thereof over the regular 8.3 file name.
 

zephyrprime

Diamond Member
Feb 18, 2001
7,512
2
81
That's just the space on the directory table. I think he meant something else. Does a 0-byte file use allocation space not including the directory? (I would guess yes but that's just a guess)
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
I just had the idea of doing something like this to find out:

I made two files using MS Edit in DOS. One was test0.txt. I saved it as empty. The other is test1.txt. I hit space once and saved that one.

Then I issued this command:

DIR /v > test.txt

Test.txt looked like this:
Volume in drive C has no label
Volume Serial Number is 134F-19FD
Directory of C:\TEST
File Name Size Allocated Modified Accessed Attrib


. <DIR> 05-19-03 10:40p 05-19-03 D .
.. <DIR> 05-19-03 10:40p 05-19-03 D ..
TEST0 TXT 0 0 05-19-03 10:41p 05-19-03 A test0.txt
TEST TXT 0 0 05-19-03 10:49p 05-19-03 A test.txt
TEST1 TXT 3 4,096 05-19-03 10:41p 05-19-03 A test1.txt
3 file(s) 3 bytes
2 dir(s) 4,096 bytes allocated
1,865,256,960 bytes free
3,226,464,256 bytes total disk space, 42% in use

Yeah, small drive. I got it in the garbage. :cool:

The text formatting makes it hard to read, but you can see that test1.txt totals 3 bytes (my mistake... I'm guessing CR and LF?) and test0.txt totals 0. File test1.txt uses a whole 4k allocation unit, but test0.txt uses 0.

The conclusion is that a 0-byte file uses no file allocation units. (ignoring the FAT itself... file names, etc.)

The test.txt file is here for your viewing pleasure. :D
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
Originally posted by: kevinthenerd
...but you can see that test1.txt totals 3 bytes (my mistake... I'm guessing CR and LF?)

I'm gonna use a hex editor and an ASCII table to find out what those two mysterious bytes are. I have some theories: null, CR, LF, extra space, etc.
 

kevinthenerd

Platinum Member
Jun 27, 2002
2,908
0
76
The hex editor showed this:

20 0D 0A

20 = 32 = Space
0D = 13 = CR = Carriage Return
0A = 10 = LF = Line Feed

I guess I was right. MS Edit is pretty stupid to add that, IMHO.
 

glugglug

Diamond Member
Jun 9, 2002
5,340
1
81
A zero byte file in FAT uses zero allocation units. However, it increases the size of the directory it's in, by 40 bytes for an 8.3 filename IIRC, more for a long filename, possibly causing the directory to take an extra allocation unit.