Hi
Can I close all open files, without having the file descriptors?
Like File.close("myfile*.txt")
Or File.close("/tmp/*")
What is finalization? block-ending?
Ps: ruby-doc.org now has a very big font for the boxes-contents, this was
better before.
I'm going to admit I'm not 100% on this, but I think your question
verges on meaningless: it's not up to Ruby to keep track of file
descriptors. And without an FD, how does it know what to tell the OS's
close() to close? What if there are files open from other programs? Yes,
Ruby *could* keep track of file descriptors for files it -- or
sub-modules -- open... but, really, that's your program's job, not
Ruby's. I can envision oodles of edge cases where this goes poorly, vs.
asking you to keep track of what you've opened.
Anyone who's savvier than me, please feel free to pipe up...
-Ken
···
On 2016-09-06 15:39, A Berger wrote:
Hi
Can I close all open files, without having the file descriptors?
Like File.close("myfile*.txt")
Or File.close("/tmp/*")
What is finalization? block-ending?
Ps: ruby-doc.org [1] now has a very big font for the boxes-contents, this was better before.
No, I absolutely agree. Just think of a fairly common case of file
descriptors inherited from the parent process: the Ruby interpreter
would not have any way to know what they refer to. Also, if only the
name is known then the Ruby program would not have a File instance to
use for reading and writing. The whole question does not make sense.
If File instances need to be found by name then a Hash will do which
maps from name to File.
Kind regards
robert
···
On Tue, Sep 6, 2016 at 9:49 PM, Ken D'Ambrosio <ken@jots.org> wrote:
I'm going to admit I'm not 100% on this, but I think your question verges on
meaningless: it's not up to Ruby to keep track of file descriptors. And
without an FD, how does it know what to tell the OS's close() to close?
What if there are files open from other programs? Yes, Ruby *could* keep
track of file descriptors for files it -- or sub-modules -- open... but,
really, that's your program's job, not Ruby's. I can envision oodles of
edge cases where this goes poorly, vs. asking you to keep track of what
you've opened.
Anyone who's savvier than me, please feel free to pipe up...