NAME
Filesys::DfPortable - Perl extension for filesystem space.
SYNOPSIS
use Filesys::DfPortable;
($blocks, $bfree, $bavail) = dfportable("c:\\"); # Default block size is 1, which outputs bytes
if(defined($blocks)) {
print"Total bytes: $blocks\n";
print"Total bytes free: $bfree\n";
print"Total bytes avail to me: $bavail\n"
}
($blocks, $bfree, $bavail) = dfportable("/tmp", 1024); # Display output in 1K blocks
if(defined($blocks)) {
print"Total 1k blocks: $blocks\n";
print"Total 1k blocks free: $bfree\n";
print"Total 1k blocks avail to me: $bavail\n"
}
DESCRIPTION
This module provides a portable way to obtain filesystem disk space information.
The module should work with all versions of Windows (95 and up), all flavors of Unix, and Mac OS X (Darwin, Tiger, etc).
dfportable() requires a directory argument that represents the filesystem you want to query. There is also an optional block size argument so the you can tailor the size of the values returned. The default for block size is 1, this will cause the function to return the values in bytes. If you never use the block size argument, then you can think of any instance of "blocks" in this document to really mean "bytes".
The values returned are as followed: blocks = Total blocks for the filesystem. bfree = Total blocks free on the filesystem. bavail = Total blocks available to the user executing the Perl application. This can be different than bfree if you have per-user quotas on the filesystem, or if the super user has a reserved amount. bavail can also be a negative value because of this.
If the dfportable() call fails for any reason, it will return undef and set $!. This will probably happen if you do anything crazy like try to get the space for /proc, or if you pass an invalid filesystem, or if there is an internal error. dfportable() will croak() if you pass it a undefined value.
Requirements: Your system must contain statvfs(), statfs(), GetDiskFreeSpaceA(), or GetDiskFreeSpaceEx(). You must be running Perl 5.6 or higher.
AUTHOR
Ian Guthrie IGuthrie@aol.com
Copyright (c) 2006 Ian Guthrie. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
statvfs(2), df(1M), statfs(1M), GetDiskFreeSpaceA, GetDiskFreeSpaceEx
perl(1).