Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bytes in a directory
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00088089
Message ID:
00088380
Vues:
34
>>Computing the space needed when moving files is similar, except that the blocksize of the target drive needs to be used in the calculation (you still use the number of bytes in use in actual use for each file; the slack space changes as the blocksize changes.)
>>
>>Ed
>
>Actually, Ed, getting the cluster size of a drive isn't too hard with VFP (or for that matter the versions that preceded it). All you need to is call SYS(2022).

I'm well aware of this, but SYS(2022) requires a drive letter notation, and unfortunately (or fortunately, depends on your POV) I often have an unmapped UNC as a target. A simple call to one of the WNetAddConnection() family API calls to map the UNC to an unallocated drive does solve the problem, however, I've had problems releasing dynamic drive mappings, mostly at app shutdown under VFP, leaving only the alternative of not releasing the drive mapping or exiting via a call to ExitProcess(). You can get the logical disk characteristics of a share via the API without mapping and unmapping, and you only write this once, at least in theory <g>.

The real PITA is not getting the blocksize, but computing the size of the directory allocation needed on the target system when disk space is really tight. FAT volumes without LFNs were trivial, since you had a fixed number of directory entries per block that was easily computed; LFNs complicated things, since the nuumber of directory entry structures required per filename varies according to the length of the filename. NT, various ?nix filesystems and NetWare have even more complex requirements because of how their directories are structured, and because there is (or can be) security information that further increases the amount of space required per file or per directory.

Compression makes anything but a ceiling value pure guesswork - you can get physical allocation in blocks through the API, but determining the actual size of the base allocation unit is a problem, especially with compression methods like DriveSpace and NetWare that use suballocation units for small files to reduce slack space on your system.

As long as overestimation of physical space required isn't a problem, and you aren't so tight on free space that the size of the directory structures is a problem, it is pretty easy to do...

Ed
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