Class: DRbFileClient
- Inherits:
-
DRbFileClientReadWrite
- Object
- DRbFileClientReadWrite
- DRbFileClient
- Defined in:
- lib/drb_fileclient.rb
Instance Method Summary collapse
- #chmod(permissions, raw_path) ⇒ Object
- #cp(raw_path, raw_path2) ⇒ Object
- #ls(raw_path) ⇒ Object
- #mv(raw_path, raw_path2) ⇒ Object
- #ru(path) ⇒ Object
- #ru_r(path) ⇒ Object
- #zip(filename_zip, a) ⇒ Object
Instance Method Details
#chmod(permissions, raw_path) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/drb_fileclient.rb', line 14 def chmod(, raw_path) if raw_path =~ /^dfs:\/\// then @@file, path = parse_path(raw_path) @@file.chmod , path else return FileUtils.chmod(, raw_path) end end |
#cp(raw_path, raw_path2) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/drb_fileclient.rb', line 26 def cp(raw_path, raw_path2) puts 'inside cp'.info if @debug if raw_path =~ /^dfs:\/\// then if @debug then puts ('raw_path: ' + raw_path.inspect).debug puts ('raw_path2: ' + raw_path2.inspect).debug end if raw_path[/^dfs:\/\/([^\/]+)/] == raw_path2[/^dfs:\/\/([^\/]+)/] then _, path = parse_path(raw_path) @@file, path2 = parse_path(raw_path2) @@file.cp path, path2 elsif raw_path2[/^dfs:\/\//] @@file, path = parse_path(raw_path) file2, path2 = parse_path(raw_path2) puts ('path: ' + path.inspect).debug if @debug puts ('path2: ' + path.inspect).debug if @debug content = @@file.read path file2.write path2, content else @@file, path = parse_path(raw_path) #file2, path2 = parse_path(raw_path2) puts ('path: ' + path.inspect).debug if @debug puts ('path2: ' + path2.inspect).debug if @debug content = @@file.read path File.write raw_path2, content end elsif raw_path2 =~ /dfs:\/\// then puts 'option2'.info if @debug file2, path2 = parse_path(raw_path2) puts ('path2: ' + path2.inspect).debug if @debug file2.write path2, File.read(raw_path) else puts 'option3'.info if @debug FileUtils.cp raw_path, raw_path2 end end |
#ls(raw_path) ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/drb_fileclient.rb', line 82 def ls(raw_path) return Dir[raw_path] unless @@directory or raw_path =~ /^dfs:\/\// if raw_path[0] == '/' then path = raw_path[1..-1] elsif raw_path =~ /^dfs:\/\// @@file, path = parse_path(raw_path) else path = File.join(@@directory, raw_path) end @@file.ls path end |
#mv(raw_path, raw_path2) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/drb_fileclient.rb', line 98 def mv(raw_path, raw_path2) unless @@directory or raw_path =~ /^dfs:\/\// then return FileUtils.mv raw_path, raw_path2 end if raw_path =~ /^dfs:\/\// then _, path = parse_path(raw_path) else path = File.join(@@directory, raw_path) end if raw_path2 =~ /^dfs:\/\// then _, path2 = parse_path(raw_path2) else path2 = File.join(@@directory, raw_path2) end @@file.mv path, path2 end |
#ru(path) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/drb_fileclient.rb', line 121 def ru(path) return DirToXML.new(path, verbose: false).latest unless @@directory \ or path =~ /^dfs:\/\// if path =~ /^dfs:\/\// then @@file, path2, addr = parse_path(path) else path2 = File.join(@@directory, path) end found = @@file.ru path2 return (addr + found) if found and addr end |
#ru_r(path) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/drb_fileclient.rb', line 137 def ru_r(path) unless @@directory or path =~ /^dfs:\/\// then return DirToXML.new(path, recursive: true, verbose: false).latest end if path =~ /^dfs:\/\// then @@file, path2, addr = parse_path(path) else path2 = File.join(@@directory, path) end found = @@file.ru_r path2 return (addr + found) if found and addr end |
#zip(filename_zip, a) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/drb_fileclient.rb', line 154 def zip(filename_zip, a) puts '@@directory: ' + @@directory.inspect if @debug unless @@directory or filename_zip =~ /^dfs:\/\// then Zip::File.open(zipfile_zip, Zip::File::CREATE) do |x| a.each do |filename, buffer| x.get_output_stream(filename) {|os| os.write buffer } end end end if filename_zip =~ /^dfs:\/\// then @@file, filepath = parse_path(filename_zip) else filepath = File.join(@@directory, filename_zip) end @@file.zip filepath, a end |