using os.stat to determine stat.st_blocks on OS that supports it?

emile at fenx.com emile at fenx.com
Tue May 9 07:52:36 CEST 2000


This returns the bytes used, not the disk size.  For example, on my
win95 box 
files grow in block size increments of 4096 bytes.  On the RH6 box, the
block 
size is 1024.  The actual disk file size will be at least the next
higher block 
size increment.  If the file size follows some sort of high water mark,
even
a file of 10 bytes could use any number of blocks.

There are certainly ways of determining block size for a given file
system, but
none that I could think of that didn't shell out one way or another.

Emile van Sebille
emile at fenx.com

>>> rec = 80000*' '
>>> open(r'c:\temp.tst','w+b').write(rec)
>>> os.stat(r'c:\temp.tst')
(33206, 0, 2, 1, 0, 0, 80000, 957769200, 957821668, 957821667)
>>> os.path.getsize(r'c:\temp.tst')
80000


aaron sterling <aarons at cyberspace.org> wrote in message
news:<3917BAB6.6E277DE at cyberspace.org>...
> have you tried os.path.getsize()
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
>




More information about the Python-list mailing list