[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

check available disk space

jim

9/16/2008 4:23:00 PM

Does anyone know how I can write a Ruby script that can check for
available disk space on the current working directory? I'd like to be
able to run the script from Windows and Linux.
3 Answers

Tod Beardsley

9/16/2008 4:51:00 PM

0

When dealing with file systems, I usually find myself switching on a
File.exists?

>> result = (File.exists?('C:\\') ? `dir /-C` : `df .`).split("\n").last
=> "/dev/sda1 110650276 52580520 52449016 51% /"

This assumes only two filesystem styles (Windows and Linux)

On Tue, Sep 16, 2008 at 11:17 AM, jim <jhavero@gmail.com> wrote:
> Does anyone know how I can write a Ruby script that can check for
> available disk space on the current working directory? I'd like to be
> able to run the script from Windows and Linux.
>
>



--
todb@planb-security.net | ICQ: 335082155 | Note: Due to Google's
privacy policy <http://tinyurl.com... and the United States'
policy on electronic surveillance <http://tinyurl.com...,
please do not IM/e-mail me anything you wish to remain secret.

Daniel Berger

9/16/2008 7:43:00 PM

0



On Sep 16, 10:17=A0am, jim <jhav...@gmail.com> wrote:
> Does anyone know how I can write a Ruby script that can check for
> available disk space on the current working directory? I'd like to be
> able to run the script from Windows and Linux.

gem install sys-filesystem

Regards,

Dan

Marc Heiler

9/16/2008 10:30:00 PM

0

Woot, i didn't know about 'dir /-C'

Shame on my windows-noob head. Ruby is even nice on windows! :-)
--
Posted via http://www.ruby-....