Skip to content

Commit

Permalink
File.exist? rescues errors and returns false.
Browse files Browse the repository at this point in the history
  • Loading branch information
drbrain committed Jun 18, 2008
1 parent a863748 commit b6b1de1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions kernel/core/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def self.executable_real?(path)

def self.exist?(path)
Stat.stat?(path) ? true : false
rescue SystemCallError
false
end

def self.expand_path(path, dir_string = nil)
Expand Down
28 changes: 24 additions & 4 deletions kernel/core/filetest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,29 @@ def zero?(path)
end

def self.after_loaded
module_function :blockdev?, :chardev?, :directory?, :executable?, :executable_real?,
:exist?, :exists?, :file?, :grpowned?, :identical?, :owned?, :pipe?,
:readable?, :readable_real?, :setgid?, :setuid?, :size, :size?, :socket?,
:sticky?, :symlink?, :writable?, :writable_real?, :zero?
module_function :blockdev?,
:chardev?,
:directory?,
:executable?,
:executable_real?,
:exist?,
:exists?,
:file?,
:grpowned?,
:identical?,
:owned?,
:pipe?,
:readable?,
:readable_real?,
:setgid?,
:setuid?,
:size,
:size?,
:socket?,
:sticky?,
:symlink?,
:writable?,
:writable_real?,
:zero?
end
end

0 comments on commit b6b1de1

Please sign in to comment.