A (minor) limitation of @FileSize...

May 24, 2010
855
0
Northlake, Il
First, to demonstrate the situation, the following commands and their results:
Code:
[Z:\Copy]echo %@Comma[%@fileSize[dos\Deleted.btm,b,a]]
36,864
 
[Z:\]PDir /(zca zc fpn) Z:\DOS\Deleted.btm
         12,288          34,422 Z:\DOS\Deleted.btm
At first, this kind of surprised me, but then I remembered the (probable!) reason:
Code:
[Z:\]attrib Z:\dos\Deleted.btm
___A______C____  Z:\dos\Deleted.btm
I'd turned disk compression on on my RAM disk a while back and had entirely forgotten about it (no surprise, there!).

Now I'll note that there are a lot of arguments for/against disk compression, and I don't intend to get into any of them. I'll just note three things:

#1. I do not have compression turned on for any of my physical hard disks, just the RAM disk which isn't all that large (234 Megabytes).

#2. I have been told (although I fully admit that I know of no simple way of verifying this) that for small files (which most of the files on my RAM disk are most of the time), compression has very low, if not essentially zero, cost. This is because files less than one cluster in size are not compressed at all.

#3. I've never noticed anything even close to a performance hit on this RAM disk, virtually all disk operations are effectively instantaneous. That could be because the CPU in this laptop is dual-core with a clock speed greater than 3GHz, but if that's the case it means that compression is probably worthwhile even in (at least some) directories of my physical hard disks.

And to verify just how little performance impact there is, I copied the entire contents of the RAM disk to another RAM disk and timed it. This was 676 files, (only) 6,230,016 bytes so maybe not a real good test, but it is a RAM disk and space is quite limited. It takes only 1.61 seconds to do this copy, which isn't a whole lot of time by any measure. (In fact, this is making me consider compressing some directories on my hard disk(s).)

So the bottom line is that I think that there should be at least one way to get @FileSize to report the true amount of disk space taken up by a file, not just it's "theoretical" size.
 
May 24, 2010
855
0
Northlake, Il
An easy workaround: Function TrueFileSize=`%@Trim[%@Replace[^,,,%@ExecStr[PDir %1 /(ZCA)]]]`

Just due to the wonders of TCC! (Although my original comment still remains valid.)
 
May 20, 2008
11,378
98
Syracuse, NY, USA
An easy workaround: Function TrueFileSize=`%@Trim[%@Replace[^,,,%@ExecStr[PDir %1 /(ZCA)]]]`

Just due to the wonders of TCC! (Although my original comment still remains valid.)
That could be a little briefer.
Code:
v:\4utilcopy> function truesize `%@word[0,%@execstr[pdir /(za) %1]]`
 
v:\4utilcopy> echo %@filesize[4Utils.ncb]
19729408
 
v:\4utilcopy> echo %@truesize[4Utils.ncb]
9355264
 
v:\4utilcopy> attrib 4Utils.ncb
___A______C____  V:\4utilcopy\4Utils.ncb
 
May 20, 2008
11,378
98
Syracuse, NY, USA
WAD -- @FILESIZE returns the size as reported by Windows.

If you want to request a new function returning the compressed size, submit it in the Feedback forum.
Rex, is it WAD that PDIR's /(za) gives a result different from that of %@FILESIZE[,,a]? One (not me) might not like that!
 
May 20, 2008
11,378
98
Syracuse, NY, USA
Rex, is it WAD that PDIR's /(za) gives a result different from that of %@FILESIZE[,,a]? One (not me) might not like that!
Actually, it would seem that @FILESIZE[,,a] should give the compressed size since that's how much disk space is being used by the file.
 
May 24, 2010
855
0
Northlake, Il
Well, Vince, I agree with you in that that's what %@FileSize[xxx,b,a] should report. But as Rex as indicated, he's just using a Windows API function, and it does what it does (and our opinion(s) on how stupid that really is really don't count!). As far as your "improved" function goes, you are right, I just did what I did off the "top of my head" without thinking about it too deeply (and that meant I just used and did the "standard" things I do on a regular basis).

And Rex, I've already written function(s) that do exactly what I want to do, so I'm not sure it's worth adding/changing anything unless somebody else has got a specific request. But thank you.
 
Similar threads
Thread starter Title Forum Replies Date
M An undocumented limitation and an associated minor bug... Support 1
Peter Murschall Some minor flaws Support 15
Alpengreis Documentation Minor issue in help file for view /E Support 1
D WAD Minor Post Installation Bug in V18 Support 1
dcantor Help file minor error Support 0
R Minor Cosmetic Issue in Take Command Window Support 2
D Minor problem. Incorrect value internal var _dir_files Support 7
jbanaszczyk help files: minor inconsistency Support 2
D Fixed Minor problem: output not alligned in the tree command Support 1
S Suggested minor improvements for www.jpsoft.com Support 5
M Just a minor annoyance re one particular plugin... Support 25
M Just a minor oddity... Support 9
Dan Glynhampton Documentation v15 help: Minor niggles Support 0
Dan Glynhampton Documentation Minor issues with HELP Support 0
M A minor complaint... Support 9
Charles Dye Minor nit: DIR /F, IFTP, colorization Support 4
vefatica Install two minor versions Support 4
A minor documentation fix - command line editing Support 0
A del /w [minor documentation fix] Support 0
A Minor documentation fix ["-" on command line] Support 3
Roedy WAD Minor long-standing install problems Support 6
M A minor but annoying issue with the "MD" command... Support 20
R A couple of minor issues with new forum. Support 4
M A somewhat humorous minor-request related to "Shift" command... Support 4
gschizas (minor) Help topic "Colors, Color Names and Codes" is wrong Support 0
M Minor "For" issue... Support 1
M A question about new behavior that’s a minor irritation… Support 16
S SETARRAY - minor issue Support 0
H Minor bug in v12 SENDMAIL Support 0
J ZIP Help - minor quibble Support 0
S BDEBUGGER - minor issue Support 2
gschizas Minor (really minor) registration issue Support 0
S Virtual disk detection, minor enhancement requests Support 0
S Minor HELP issues Support 1
Charles Dye Minor installer quirk Support 1
M Is there any way to work around this (apparent) limitation of TCC? Support 59
A Limitation regarding creation of shortcut keys for "copy" Support 0
M Is there a way to get around this limitation of file names? Support 12
S 10.0.55 - @FILEARRAY limitation Support 4
Joe Caverly @FILESIZE and NTFS File Stream Support 1
vefatica @FILESIZE[] ... allocated ... unexpected results Support 0
rps @FILESIZE[....,a] allocated size not matching Dir results Support 8
rps Fixed @filesize[...,a] space allocated values incorrect Support 2
vefatica @FILESIZE ... allocated space Support 7
M @Files and @FileSize failures... Support 2
M @FileSize - How is this possible? Support 10
M @Files, @FileSize returning nothing... Support 7
JohnQSmith WAD Incorrect results from @FILESIZE Support 9
H @filesize result for directory? Support 2
dcantor Build 56 @FILESIZE problem Support 2

Similar threads