Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #804 from sideshowcoder/add_dir_exists
add Dir#exist? and Dir#exists?
- Loading branch information
Showing
with
19 additions
and 20 deletions.
- +1 −0 lib-topaz/bootstrap.rb
- +18 −0 lib-topaz/dir.rb
- +0 −10 spec/tags/core/dir/exist_tags.txt
- +0 −10 spec/tags/core/dir/exists_tags.txt
@@ -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 |