Module: WebHDFS::FileUtils
- Defined in:
- lib/rake_hdfs/hdfs_fileutils.rb
Class Method Summary collapse
- .exist?(file, options = {}) ⇒ Boolean
- .ls(path, options = {}) ⇒ Object
- .mtime(path, options = {}) ⇒ Object
- .stat(path, options = {}) ⇒ Object
- .uptodate?(new, old_list, options = {}) ⇒ Boolean
Class Method Details
.exist?(file, options = {}) ⇒ Boolean
4 5 6 7 8 9 10 11 |
# File 'lib/rake_hdfs/hdfs_fileutils.rb', line 4 def exist?(file, ={}) begin client.stat(file, ) return true rescue FileNotFoundError => e return false end end |
.ls(path, options = {}) ⇒ Object
13 14 15 16 17 |
# File 'lib/rake_hdfs/hdfs_fileutils.rb', line 13 def ls(path, ={}) opts = .dup fu_log "ls #{path}" if opts.delete(:verbose) client.list(path, ) end |
.mtime(path, options = {}) ⇒ Object
39 40 41 42 |
# File 'lib/rake_hdfs/hdfs_fileutils.rb', line 39 def mtime(path, = {}) file_stat = stat(path, ) file_stat["modificationTime"] end |
.stat(path, options = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/rake_hdfs/hdfs_fileutils.rb', line 20 def stat(path, ={}) opts = .dup fu_log "stat #{path}" if opts.delete(:verbose) client.stat(path, ) end |
.uptodate?(new, old_list, options = {}) ⇒ Boolean
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rake_hdfs/hdfs_fileutils.rb', line 27 def uptodate?(new, old_list, = {}) return false unless exist?(new) new_time = mtime(new) old_list.each do |old| if exist?(old) return false unless new_time > mtime(old) end end true end |