6.9 Getting the Free Space Available on a Specified Drive


You want to see how much free space is available in a directory or on a certain drive.

Technique

Use the diskfreespace() function, which returns the number of bytes available in a certain drive or directory:

 $free_space = diskfreespace("C:\"); 

Comments

Finding out the amount of free space in a directory seems like a trivial thing, sort of like those background faders that they have for JavaScript, or "under construction" signs on a Web page. To an extent, this is the case, but the diskfreespace() function can be very helpful when debugging or when you need to find out how much free space you have to work with when writing extensible scripts.

A little bit about the internals of the diskfreespace() function call: On Windows NT95982000, the diskfreespace() function ”if available ”makes the GetDiskFreeSpaceEx() function call; otherwise , it uses the GetDiskFreeSpace() function call. On other operating systems, it uses the statvfs or statfs function calls.



PHP Developer's Cookbook
PHP Developers Cookbook (2nd Edition)
ISBN: 0672323257
EAN: 2147483647
Year: 2000
Pages: 351

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net