Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Correct cluster size
Message
De
20/08/2001 20:46:10
 
 
À
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:
00546538
Vues:
16
>>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...
>
Disclaimer: I consider George Tasker to be technically reliable, and a reasonably good friend even though we've never met face to face, so I'm not completely unbiased.

Let me suggest you trust George; his recommendation of the API is spot on, and his recommendation on writing a small file and checking it's actual disk space consumption is dead on, too; with NTFS, or FAT systems with DriveSpace installed, you have the issues of sub-cluster file space allocation and automatic compression. In RAID arrays, the unit of allocation is most likely a multiple of the base space allocation unit (min NTFS partition cluster size) * (number of RAID spindles - 1) is common if NTFS compression is not used, and OBTW, compression and sub-cluster allocation is controlled at the file or folder level so the rules aren't consistent. The API call will return the correct base space allocation unit of the logical volume.

Maybe familiarizing yourself with Windows internals would be a worthwhile thing to work towards.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform