Subject: Use ruby script to determine if there is enough space left on a device
	Date: mer 21 ago 13 02:28:39 +0200

Quoting Marc Heiler (lists / ruby-forum.com):

> So a pure ruby solution is preferred.

Some years ago I had a similar need. I wrote the following, which
manages to be pure Ruby, but is also ABSOLUTELY NON-PORTABLE (I work
only on Linux):

def partition_occupation(fn)
  b=' '*128
  syscall(137,fn,b)
  a=b.unpack('QQQQQ')
  (a[2]-a[4]).to_f/a[2]
end

Returns a floating value from 0 to 1, which represents the current
occupation of the partition that includes the file whose path is
passed as input.

The proper way would be to include an appropriate method in the Ruby
source code (dir.c, possibly). But to propose a patch, you'd have to
know how to obtain this value in windows, too (on posix systems you'd
use statvfs, as Eric mentions). And you'd have to be comfortable with
the entanglement of ifdefs that render that code multi-platform.

Carlo

-- 
  *         Se la Strada e la sua Virtu' non fossero state messe da parte,
* K * Carlo E. Prelz - fluido / fluido.as             che bisogno ci sarebbe
  *               di parlare tanto di amore e di rettitudine? (Chuang-Tzu)