Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Correct cluster size
Message
De
20/08/2001 09:45:37
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00546141
Message ID:
00546181
Vues:
15
>I know. GetDiskFreeSpace() returns the bytes per sector and the sectors per cluster, in addition to other information.

OK, thank you very much. I am new to Win-API; and I thought: GetDiskFreeSpace() only gives me the free disk space.

>
>>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?

A combobox on the main form. The options are: "Auto" (i.e., autodetect), "512 bytes", "1 KB", "2 KB", ..., "32 KB" (all powers of 2 in between).

>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.

I disagree: this is not reliable. Another user or process may increase or decrease the free disk space in the meantime. Unless I create a thousand small temp files, and round to the nearest power of 2...

>FWIW, here's the GetDiskFreeSpace() syntax:
...


OK, I'll check into it. Thanks again.

>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.

Perhaps this is the reason VFP reports the wrong cluster size! If that is the case, unfortunately, there is no additional benefit in using the Win-API. BTW, I did get correct information (using the VFP function) on a machine with Windows NT 4. The problem is, precisely, on machines with Windows 98. And the problem seems to appear only on FAT32 partitions.

Is there an API function to report how much space is "really used" (round up to the nearest cluster) by a file? 'Cause I do get correct information when I check a file's properties in the Explorer.

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform