[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Disk Free Space

Mickael Faivre-Macon

1/23/2006 7:58:00 PM

Hi,

Is a way to know free disk space left other that using Win32 API or a
system call on linux ?

Mickael.


6 Answers

Michael Fellinger

1/24/2006 2:29:00 AM

0

for linux, it is the command dfno idea about easy ways to do that on windows - but there sure is someapi-call for that too...2006/1/24, Mickael Faivre-Macon <faivrem@gmail.com>:> Hi,>> Is a way to know free disk space left other that using Win32 API or a> system call on linux ?>> Mickael.>>

Timothy Goddard

1/24/2006 2:40:00 AM

0

This is highly OS-specific so I sincerely doubt there is a general
method. Different OSes treat disks entirely differently. To demonstrate
the complexity, simply ask yourself these questions: Is a network share
a disk? A folder on a remote FTP server? A loop device mounting a file
on a remote SMB server accessed via a VPN? The file itself?

Try either using a system-specific call for each platform you may be
operating on or simply try to write your stuff to the disk, catching
the appropriate error if it fails.

Jeff Schwab

1/24/2006 12:18:00 PM

0

Mickael Faivre-Macon wrote:

> Is a way to know free disk space left other that using Win32 API or a
> system call on linux ?

On {U,Li}n[iu]x, df.
On Windows, dir. It's the last line of output.

Joel VanderWerf

1/24/2006 6:46:00 PM

0

Jeffrey Schwab wrote:
> Mickael Faivre-Macon wrote:
>
>> Is a way to know free disk space left other that using Win32 API or a
>> system call on linux ?
>
> On {U,Li}n[iu]x, df.
> On Windows, dir. It's the last line of output.

You can install the GnuWin32 tools on windows to get df working there, IIRC.

--
vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407


Edwin van Leeuwen

1/24/2006 6:55:00 PM

0

Mickael Faivre-Macon wrote:
> Hi,
>
> Is a way to know free disk space left other that using Win32 API or a
> system call on linux ?
>
> Mickael.

A way to directly make the correct system call from ruby:
size = 64
unpack_fmt = 'iiiiiiiiiiiiiiii'
foo = ' ' * size
syscall(99, "/mountpoint", foo)
type, @bsize, @blocks, @bfree, @bavail, @files, @ffree, tmp,tmp,@namelen
= foo.unpack(unpack_fmt)
usage=100*(@blocks-@bfree)/@blocks

(Copied from someone who wrote a ruby script that did the same thing as
df.)

Edwin

--
Posted via http://www.ruby-....


Mickael Faivre-Macon

1/28/2006 11:53:00 AM

0

I thought there would be a portable library to manage disk in general.
But thank you all for your replies.
Mickael.