Problem with win32api function

Mark Hammond MarkH at ActiveState.com
Fri Apr 13 10:26:41 EDT 2001


Dublanc, David wrote:

> I have a problem with the fonction win32file.GetDiskFreeSpace

> 

> The maximum number of space is : 65536 bytes. So if the hard disk capacity

> is > 2 Go, the function returns a wrong result.

> 

> Do you have solution for this problem ?


Check out the documentation in the help files - the number of bytes is 
not returned, but 4 different values are to help you calculate it:

"number of sectors per cluster, the number of bytes per sector, the 
total number of free clusters on the disk and the total number of 
clusters on the disk"

 >>> import win32file
 >>> spc, bps, free_c, tot_c = win32file.GetDiskFreeSpace("F:\\")
 >>> print 1L * free_c * spc * bps
2477039616
 >>>

Note the "1L" will prevent integer overflow - this little wart should be 
removed in a Python coming your way soon :)

Mark.




More information about the Python-list mailing list