[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

[ANN] io-extra 0.1.0

djberg96

1/26/2005 5:47:00 PM

Hi all,

I'm happy to announce the release of io-extra 0.1.0.

What is it?
===========
This package provides a few extra methods for the IO class:

IO.closefrom(low_fd)
- Closes all open file descriptors greater than or equal to 'low_fd'.

IO.fdwalk(low_fd)
- Iterates over each open file descriptor and yields back a File
object.

IO#directio?
- Returns true or false, depending on whether or not directio has been
set
for the filehandle.

IO#directio=
- Allows you to set directio for the filehandle (for those platforms
that support it).

Where is it?
============
It can be found on the RAA or on the project page at
http://ruby-miscut....

Eh? Is this really necessary?
==============================
Q) What is the difference between your implementation of IO.closefrom
and a
pure Ruby version that looks something like this?

def IO.closefrom(n)
0.upto n do |fd|
IO.for_fd(fd).close
end
end

The primary difference is that this walks all file descriptors, rather
than only open file descriptors. However, I should note that this only
applies if your platform supports the closefrom() function. In that
case,
the only advantage is speed.

Q) What is the difference between your implementation of IO.fdwalk and
a pure
Ruby version that looks something like this?

def IO.fdwalk(n)
ObjectSpace.each_object(File){ |f|
yield f if f.fileno >= n
}
end

The primary difference is that this only closes Ruby file objects, not
necessarily every filehandle opened by the Ruby process. Think
system(), for
example.

Enjoy!

Dan