For Programmers: Free Programming Magazines  


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.
Jeff 'Japhy' Pinyan

2004-04-22, 4:33 pm

On Apr 23, suresh.pasupula@wipro.com said:

>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".


Download the Win32::DriveInfo module from CPAN (you can probably use ppm
to get it).

http://search.cpan.org/~mblaz/Win32-DriveInfo-0.06/
http://search.cpan.org/~mblaz/Win32...06/DriveInfo.pm

--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.]
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com