James Britt wrote: > > So asks Dr. Scripto at Microsoft TechNet > > > http://www.microsoft.com/technet/scriptcenter/funzone/puzzle/default.mspx > > > At the very bottom, they say, "Or and it pains us to say this could > this be our fault? WhatÃÔ wrong with this script?" > > Well, it's obvious: the script is not written in Ruby. > > Maybe they need a few decent Ruby solutions. It's a good question. Wouldn't it be nice to have a cross-platform way of asking "how much disk space is available here?" Java's doing it soon! http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4057701 Is there a way of using df that's consistent across Linuxes/BSDs/Mac (-k perhaps?) Here's a start: class << self define_method :bytes_free, &begin require 'Win32API' df = Win32API.new("kernel32", "GetDiskFreeSpaceEx", "pppp", "i") proc do |dir| df.call(dir, ret=" ", " ", " "); ret.unpack("L")[0] end rescue LoadError proc do |dir| `df -k #{dir}`[/\n.{20} (\d+)/, 1].to_i end end end p bytes_free(".") p bytes_free("some/other/path") Cheers, Dave