Skip to content
Permalink
Browse files

Merge pull request #804 from sideshowcoder/add_dir_exists

add Dir#exist? and Dir#exists?
  • Loading branch information
alex committed Jul 13, 2013
2 parents bdb4a50 + 6c04759 commit 1c30c086d350ca17cdfe644d7a4bfab82954692f
Showing with 19 additions and 20 deletions.
  1. +1 −0 lib-topaz/bootstrap.rb
  2. +18 −0 lib-topaz/dir.rb
  3. +0 −10 spec/tags/core/dir/exist_tags.txt
  4. +0 −10 spec/tags/core/dir/exists_tags.txt
@@ -15,6 +15,7 @@
load_bootstrap.call("errno.rb")
load_bootstrap.call("file.rb")
load_bootstrap.call("fixnum.rb")
load_bootstrap.call("dir.rb")
load_bootstrap.call("hash.rb")
load_bootstrap.call("integer.rb")
load_bootstrap.call("io.rb")
@@ -0,0 +1,18 @@
class Dir

def self.exists?(dirname)
if dirname.respond_to?(:to_path)
dirname = dirname.to_path
end
begin
!!new(dirname)
rescue Errno::ENOENT, Errno::ENOTDIR
false
end
end

class << self
alias :exist? :exists?
end

end
@@ -1,11 +1 @@
fails:Dir.exist? returns true if the given directory exists
fails:Dir.exist? returns true for '.'
fails:Dir.exist? returns true for '..'
fails:Dir.exist? understands non-ASCII paths
fails:Dir.exist? understands relative paths
fails:Dir.exist? returns false if the given directory doesn't exist
fails:Dir.exist? doesn't require the name to have a trailing slash
fails:Dir.exist? doesn't expand paths
fails:Dir.exist? returns false if the argument exists but is a file
fails:Dir.exist? calls #to_path on non String arguments
fails:Dir.exist? doesn't set $! when file doesn't exist
@@ -1,11 +1 @@
fails:Dir.exists? returns true if the given directory exists
fails:Dir.exists? returns true for '.'
fails:Dir.exists? returns true for '..'
fails:Dir.exists? understands non-ASCII paths
fails:Dir.exists? understands relative paths
fails:Dir.exists? returns false if the given directory doesn't exist
fails:Dir.exists? doesn't require the name to have a trailing slash
fails:Dir.exists? doesn't expand paths
fails:Dir.exists? returns false if the argument exists but is a file
fails:Dir.exists? calls #to_path on non String arguments
fails:Dir.exists? doesn't set $! when file doesn't exist

0 comments on commit 1c30c08

Please sign in to comment.
You can’t perform that action at this time.