Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bytes in a directory
Message
 
To
31/03/1998 09:42:26
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00088089
Message ID:
00088421
Views:
34
>>>>>Are there VFP functions that return the total bytes in a directory and bytes of individuals files? Thanks in advance.
>>>>>
>>>>>Andy Ahrndt
>>>>>aahrndt@mindspring.com
>>>>
>>>>FSIZE() will return file size (if SET COMPATIBLE ON). You can collect all file names into array using ADIR() and calculate total size looping through this array.
>>>
>>>Actually, while it will show use the number of bytes used, it won't show you the amount of disk space in use, since files are allocated in fixed-size blocks, resulting in wasted space (slack space) at the end of each file. You need to determine the blocksize of the partition being used, and then examine the size of each file, and compute the number of blocks used per file. The total number of blocks in use is the total space taken up on the drive, including the slack space in each file allocation. Add to this the size of the directory in blocks (trivial to compute in the old DOS world, but non-trivial with LFNs, and especially with file systems like NTFS and NetWare), multiply the result by the blocksize, and you have the current space allocated to the directory..
>>>
>>>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).
>George,
>I'm in trouble with sys(2022) or win32api getdiskfreespace. They both return 32768 for my 4.3 Gb drive (you see I make use of your sample APIs). But I have fat32 and cluster size is 4096. Also drvinfo class in files section return wrong info (I think uses getdiskfreespace). If you have any handy solution for it I would like to know.
>Cetin

You're right, and I don't know why this is. I'll have to investigate, and, if I find anything out I'll post.
George

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

Click here to load this message in the networking platform