Hi,
I need an equivalent of $subj php function in ruby... I have a directory
and I need to find out how much I can save there... Only idea I have is
to find mountpoint and then parse /proc, but it's very ugly solution
Thank you for help.
Hi,
I need an equivalent of $subj php function in ruby... I have a directory
and I need to find out how much I can save there... Only idea I have is
to find mountpoint and then parse /proc, but it's very ugly solution
Thank you for help.
Darken wrote:
I need an equivalent of $subj php function in ruby... I have a directory
and I need to find out how much I can save there... Only idea I have is
to find mountpoint and then parse /proc, but it's very ugly solution
You can do this simply if not truly portably like so:
class << self
define_method :disk_free_space, &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}`[/\S+\s+\S+\s+\S+\s+(\d+)/, 1].to_i * 1024
end
end
end
Obviously if your `df -k foo` gives you output in a different format,
you'll need to change the regular expression. (The way I've written it,
it's looking for available space in 1k blocks in the fourth column.)
Cheers,
Dave
Darken wrote:
Hi,
I need an equivalent of $subj php function in ruby... I have a directory
and I need to find out how much I can save there... Only idea I have is
to find mountpoint and then parse /proc, but it's very ugly solution
There was a thread here on ruby-talk not long ago on this very topic.
Search the archives.
--
James Britt
"People want simple stories."
Thank you... parsing df output is working fine... anyway,it will be nice
to have more... ruby.. solution.
Darken wrote:
I need an equivalent of $subj php function in ruby... I have a directory
and I need to find out how much I can save there... Only idea I have is
to find mountpoint and then parse /proc, but it's very ugly solution
You can do this simply if not truly portably like so:class << self
define_method :disk_free_space, &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}`[/\S+\s+\S+\s+\S+\s+(\d+)/, 1].to_i * 1024
end
end
endObviously if your `df -k foo` gives you output in a different format,
you'll need to change the regular expression. (The way I've written it,
it's looking for available space in 1k blocks in the fourth column.)Cheers,
Dave
I was googling and searching newsgroups archive before I asked, can you
help me a bit please?
Darken wrote:
Hi,
I need an equivalent of $subj php function in ruby... I have a directory
and I need to find out how much I can save there... Only idea I have is
to find mountpoint and then parse /proc, but it's very ugly solutionThere was a thread here on ruby-talk not long ago on this very topic.
Search the archives.
I googled around out of curiosity and it looks like there used to be something called "filesystem" by Mike Hall. But it's no longer available. Anyone on the list know what happened to it?
-Mat
On Jun 22, 2006, at 11:03 AM, Darken wrote:
Thank you... parsing df output is working fine... anyway,it will be nice
to have more... ruby.. solution.
Start from here:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/193509
Remember that the newsgroups comp.lang.ruby has been disconnected due
to circumstances beyond control.
-austin
On 6/22/06, Darken <lokean.darken@gmail.com> wrote:
I was googling and searching newsgroups archive before I asked, can you
help me a bit please?
--
Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/
* austin@halostatue.ca * You are in a maze of twisty little passages, all alike. // halo • statue
* austin@zieglers.ca
Austin wrote:
Remember that the newsgroups comp.lang.ruby has been disconnected due
to circumstances beyond control.
I dare say there are those whose control it is not beyond. God, for
example, Matz, if he had a reason, or even possibly James Edward Gray
II who said a week or two ago that he might have a new gateway server
in the works.
Cheers,
Dave
Unfortunately, it isn't necessarily controllable, even for Matz or
James. It is, in part, dependent upon a service provider's
willingness. The original gateway went down because the host of the
gateway changed from service provider A to service provider B. When
signing up with provider B, they gateway host had discussed with them
the possibility of doing mailing-list/newsgroup gateway and had been
assured that it would be okay. When the switch was done, however,
provider B reneged on this.
With increasing numbers of hosting providers dropping support for
Usenet, what makes you think that it would be "easy" to manage this?
-austin
On 6/22/06, Dave Burt <dave@burt.id.au> wrote:
Austin wrote:
> Remember that the newsgroups comp.lang.ruby has been disconnected due
> to circumstances beyond control.
I dare say there are those whose control it is not beyond. God, for
example, Matz, if he had a reason, or even possibly James Edward Gray
II who said a week or two ago that he might have a new gateway server
in the works.
--
Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/
* austin@halostatue.ca * You are in a maze of twisty little passages, all alike. // halo • statue
* austin@zieglers.ca
Austin Ziegler wrote:
On 6/22/06, Dave Burt <dave@burt.id.au> wrote:
I dare say there are those whose control it is not beyond.
With increasing numbers of hosting providers dropping support for
Usenet, what makes you think that it would be "easy" to manage this?
I never said the word "easy," nor did I intend to imply anything more
than that it can be done. But does no word from James mean that
possibility's fallen through?
Cheers,
Dave
Don't know. We'd have to ask them. But it may not be within James's
control at this point.
-austin
On 6/25/06, Dave Burt <dave@burt.id.au> wrote:
Austin Ziegler wrote:
> On 6/22/06, Dave Burt <dave@burt.id.au> wrote:
>> I dare say there are those whose control it is not beyond.
> With increasing numbers of hosting providers dropping support for
> Usenet, what makes you think that it would be "easy" to manage this?
I never said the word "easy," nor did I intend to imply anything more
than that it can be done. But does no word from James mean that
possibility's fallen through?
--
Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/
* austin@halostatue.ca * You are in a maze of twisty little passages, all alike. // halo • statue
* austin@zieglers.ca