Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Re: Re: get the size of a LARGE file

by TheHobbit (Pilgrim)
on Apr 25, 2002 at 10:20 UTC ( [id://161907]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: get the size of a LARGE file
in thread get the size of a LARGE file

Hi,
beside the fact that st_blksize is not the blocksize but only the system preferred bloksize, there is a much more upsetting problem. Multiplying the number of blocks by the size of one block does not give you the size of the file. See the following example, where the file a just contains 4 carcters.

@a = stat "a"; print "Real size = $a[7]\n"; print "blocksize * blocknum = ",$a[11]*$a[12],"\n";
prints
size = 4 blocksize * blocknum = 32768
and everyone will agree that a file size function which returns 32768 instead of 4 is quite wrong.

Of course, one my object that 32768 is the space that the file is taking up on your HD, but this is another story, as Kipling would have said.

Cheers
Leo TheHobbit

Replies are listed 'Best First'.
Re: Re: Re: Re: get the size of a LARGE file
by dws (Chancellor) on Apr 25, 2002 at 14:59 UTC
    Multiplying the number of blocks by the size of one block does not give you the size of the file.

    When the filesize is up in the gigabytes, the bytes lost by multiplying file blocks by disk blocksize are down in the noise. Given the uses that file sizes of this magnitude are put to (e.g., how much tape is needed to back this file up; how long will it take to move this file from A to B, and how much disk space will it need when it gets there), losing a few bytes doesn't matter.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://161907]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-04-20 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found