Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
[ANN] io-extra 0.1.0
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Daniel Berger, post: 4456834"] 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 [URL]http://ruby-miscutils.sf.net[/URL]. 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 [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
[ANN] io-extra 0.1.0
Top