Home > Archive > PERL Beginners > April 2004 > [Free Disk Space] : in Windows using perl
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
[Free Disk Space] : in Windows using perl
|
|
| Suresh Pasupula 2004-04-22, 4:33 pm |
|
Hi,
Is there anyway to find out "Free Disk Space" in Windows using PERL?
Assume I have a function say GetFreeDiskSpace(). I can specify some path
as a parameter to GetFreeDiskSpace() and want to get the return value in
bytes for available disk. The path can contain "Local Drive Name" or
"Share Name" or "Shared IP Address".
Further enhancement to this can be, I pass second parameter to it for
specifying the how the return value should be i.e. "Bytes" or "Kilo
Bytes" or "Mega Bytes" etc.
Regards
~Suresh
Confidentiality Notice
The information contained in this electronic message and any attachments tothis message are intended
for the exclusive use of the addressee(s) and may contain confidential orprivileged information. If
you are not the intended recipient, please notify the sender at Wipro orMailadmin@wipro.com immediately
and destroy all copies of this message and any attachments.
| |
|
|
| Jenda Krynicky 2004-04-22, 6:33 pm |
| From: <suresh.pasupula@wipro.com>
> Is there anyway to find out "Free Disk Space" in Windows using PERL?
> Assume I have a function say GetFreeDiskSpace(). I can specify some
> path as a parameter to GetFreeDiskSpace() and want to get the return
> value in bytes for available disk. The path can contain "Local Drive
> Name" or "Share Name" or "Shared IP Address".
use Win32::FileOp qw(GetDiskFreeSpace);
# c:\> ppm install Win32::FileOp
my $freeSpaceOnC = GetDiskFreeSpace( 'c:');
my $freeSpaceOnShare = GetDiskFreeSpace( '\\\\server\share');
# these numbers would respect the user's quota!
If you want to get the total amout of (free) space you just use this
function in list context:
($freeSpaceForUser, $totalSize, $totalFreeSpace)
= GetDiskFreeSpace $path;
> Further enhancement to this can be, I pass second parameter to it for
> specifying the how the return value should be i.e. "Bytes" or "Kilo
> Bytes" or "Mega Bytes" etc.
Sorry you have to do this yourself. The function above tells you the
number of bytes.
HTH, Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
|
|
|
|
|