Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Get the available space in a partition using as input a directory?

by Not_a_Number (Parson)
on Jul 12, 2013 at 19:10 UTC ( #1044053=note: print w/ replies, xml ) Need Help??


in reply to Get the available space in a partition using as input a directory?

You missed this bit from the OP:

This would have to work on Linux, Mac and Windows (my emphasis)

Neither stat nor statvfs work on Windows.

Here's a kludge to get the available space on your current Windows drive:

my $free = ( split ' ', qx{ dir|find "bytes free" } )[2]; $free =~ s/\D//g;

But that is Perl 5. I don't know if Perl 4 even provides a way to make a system call to Windows...


Comment on Re: Get the available space in a partition using as input a directory?
Select or Download Code
Replies are listed 'Best First'.
Re^2: Get the available space in a partition using as input a directory?
by choroba (Canon) on Jul 12, 2013 at 19:16 UTC
    bytes free
    Aren't MS Windows localized, i.e. this would work only for English users?
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

      Yup, you're right.

      Here's an updated kludge:

      my $free = ( split "\n", qx{ dir } )[-1]; $free = ( split ' ', $free )[2]; $free =~ s/\D//g; print $free;

      Works for at least French and English...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1044053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2015-07-29 12:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls