Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Correct cluster size
Message
 
To
20/08/2001 09:21:47
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00546141
Message ID:
00546166
Views:
22
This message has been marked as a message which has helped to the initial question of the thread.
>>>How do I get the correct cluster size for a disk?
>>>
>>>The built-in command in VFP, sys(2022), always returns 32KB for networked drives, but also for FAT32 drives, even if they are local.
>>>
>>>Hilmar.
>>
>>The GetDiskFreeSpace() API call used to correctly return this information. However, with the advent of disks greater than 2 gb, it is not reliable since it caps the amount of space at 2 gb, adjusting the values returned accordingly. In short, this sort of information cannot be reliably returned even from the API.

Hilmar,

>No, no, 'tis not the free space I want, but the cluster size.

I know. GetDiskFreeSpace() returns the bytes per sector and the sectors per cluster, in addition to other information.

>I wrote a small utility, which I called "Who's gobbling my hard disk", that totals file sizes for each folder. For accurate information, for a specific disk, I need the cluster size. For instance, on my current "C:" drive, a 100-byte batch-file actually uses 4 KB, because that is the cluster size I am using.
>
>Since sys(2022) isn't trustworthy (see my original message), I gave the user the option of selecting the cluster size.

How?

>This I will do anyway, even if I find out how to get the cluster size: it may be useful to know how much space would be used somewhere else. For instance, if I copy files to a ZIP disk (cluster size: 2 KB, I believe).
>
The only reliable way to do it across all Win32 platform and file systems is to write get the amount of free space, write a small temporary file, and get the amount of free space afterwards.

FWIW, here's the GetDiskFreeSpace() syntax:
DECLARE INTEGER GetDiskFreeSpace IN Win32API;
  STRING @lpRootPathName, INTEGER @lpSectorsPerCluster,;
  INTEGER @lpBytesPerSector, INTEGER @lpNumberOfFreeClusters,;
  INTEGER @lpTotalNumberOfClusters
lcpath = "C:\"
STORE 0 TO lnsectors, lnbytes, lnfree, lntotal
? GetDiskFreeSpace(@lcpath, @lnsectors, @lnbytes, @lnfree, @lntotal)
? lnsectors * lnbytes && Cluster size
On a Win2K box it accurately reports a 4K cluster size. On a Win98SE box, it reports 32K, when in reality the cluster size is 4K.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform