Class PhusionPassenger::Utils::FileSystemWatcher::DirInfo |
In: | lib/phusion_passenger/utils/file_system_watcher.rb
Parent: | Object

Methods

- changed?
- new

Constants

DOT | = | "."
DOTDOT | = | ".."

Public Class methods
new(filename, stat)

[ show source ]

         # File lib/phusion_passenger/utils/file_system_watcher.rb, line 123
    123:                         def initialize(filename, stat)
    124:                                 @filename = filename
    125:                                 @stat = stat
    126:                                 @subfiles = {}
    127:                                 Dir.foreach(filename) do |entry|
    128:                                         next if entry == DOT || entry == DOTDOT
    129:                                         subfilename = "#{filename}/#{entry}"
    130:                                         @subfiles[entry] = FileInfo.new(subfilename, File.stat(subfilename))
    131:                                 end
    132:                         end

Public Instance methods
changed?()

[ show source ]

         # File lib/phusion_passenger/utils/file_system_watcher.rb, line 134
    134:                         def changed?
    135:                                 new_stat = File.stat(@filename)
    136:                                 if @stat.ino != new_stat.ino || !new_stat.directory? || @stat.mtime != new_stat.mtime
    137:                                         return true
    138:                                 end
    139:
    140:                                 count = 0
    141:                                 Dir.foreach(@filename) do |entry|
    142:                                         next if entry == DOT || entry == DOTDOT
    143:                                         subfilename = "#{@filename}/#{entry}"
    144:
    145:                                         file_info = @subfiles[entry]
    146:                                         if !file_info || file_info.changed?(false)
    147:                                                 return true
    148:                                         else
    149:                                                 count += 1
    150:                                         end
    151:                                 end
    152:
    153:                                 return count != @subfiles.size
    154:                         rescue Errno::EACCES, Errno::ENOENT
    155:                                 return true
    156:                         end