@FILESIZE ... allocated space

May 20, 2008
11,285
95
Syracuse, NY, USA
DIR /G gets it right (agrees with GetCompressedFileSize()).
@FILESIZE[file,b,a] gets it wrong.

Code:
v:\> d 0.btm
2018-03-26  21:45          11,591  0.btm

v:\> d /g 0.btm
2018-03-26  21:45           4,096  0.btm

v:\> echo %@filesize[0.btm,b]
11591

v:\> echo %@filesize[0.btm,b,a]
12288
 
May 20, 2008
11,285
95
Syracuse, NY, USA
When does it work correctly? I use NTFS. Is that a bad one? @FILESIZE[,,a] seems to always give the (uncompressed) file size rounded up to the size of an allocation unit.

It seems @FILESIZE[,,a] would benefit from using GetCompressedFileSize (as DIR /G does). In fact, in just a few tests, GetCompressedFileSize acutally returns a multiple of the allocation unit. Below (last command) @IPOW gives the result of GetCompressedFileSize (with no tinkering); I don't think it's a coincidence that the three compressed sizes are multiples of 4096! And GetCompressedFileSize gives the normal size if the file is not compressed.

Code:
v:\> d /s v:\0.btm;cksum.exe
2018-03-26  21:45          11,591  0.btm
2017-01-15  14:30          47,104  cksum.exe
2017-01-15  14:30          53,760  cksum.exe

v:\> d /s /g v:\0.btm;cksum.exe
2018-03-26  21:45           4,096  0.btm
2017-01-15  14:30          32,768  cksum.exe
2017-01-15  14:30          36,864  cksum.exe

v:\> do f in /l v:\0.btm v:\cksum\32\cksum.exe v:\cksum\64\cksum.exe ( echo %@IPOW[%f] )
4096
32768
36864
 
Similar threads
Thread starter Title Forum Replies Date
rps Fixed @filesize[...,a] space allocated values incorrect Support 2
vefatica @FILESIZE[] ... allocated ... unexpected results Support 0
rps @FILESIZE[....,a] allocated size not matching Dir results Support 8
Joe Caverly @FILESIZE and NTFS File Stream Support 1
M @Files and @FileSize failures... Support 2
M @FileSize - How is this possible? Support 10
M @Files, @FileSize returning nothing... Support 7
M A (minor) limitation of @FileSize... Support 6
JohnQSmith WAD Incorrect results from @FILESIZE Support 9
H @filesize result for directory? Support 2
dcantor Build 56 @FILESIZE problem Support 2
R Fixed Bytes Allocated Total Incorrect in V17 b52 Support 1
M How to? Find out the total allocated size of a directory tree... Support 7
Alpengreis [TCMD v25.00.24] Small space problem with the DE translation in Prefs-GUI Support 1
Joe Caverly Echo message works without the space? Support 3
jbanaszczyk Alias with space in the name Support 3
vefatica WAD @FILEREADB outputs a leading space ... Support 2
C How to? MOVE and handling out of space Support 2
Exolon Space within path and FOR Support 4
aedthuio Folder with space char Support 6
vefatica START /DESKTOP="name with space" ... Support 4
W File completion without space/executable extensions Support 3
Stefano Piccardi replace tcc process space? Support 8
H variable programfiles(x86) loses space Support 1
D unzip /d in directory with space in name Support 1
thorntonpg removing directory with space at the end Support 3

Similar threads