Dav Coleman wrote:
> Hi,
>
> I've been trying to locate the source for File.open and I'm having no luck.
> [...]
> Are the core classes only defined in compiled binary perhaps?
>

Yes.

> If so, I have another question. Using RoR I'm running into a problem
> due to too many open files. I want to find the File.open source (or
> IO.open maybe) and add in some sort of debugging so I can log every
> file being opened to help debug the issue. Is there a way I can do
> this without going to the actual source?
>
> Thanks for any advice.


Try something like this at the top of your prog:

#-----------------------------------------------
class File
  class << self
    alias :real_open :open
    def open(*args, &blk)
      p [:File_open] + args  # <-----<<
      real_open(*args, &blk)
    end
  end
end

module Kernel
  alias :real_open :open
  def open(*args, &blk)
    p [:Knl_open] + args     # <-----<<
    real_open(*args, &blk)
  end
end

#-----------------------------------------------
# TEST ...

fname = File.exist?('NUL') ? 'NUL' : '/dev/null'

File.open(fname) {}
open(fname) {}
#-----------------------------------------------


daz