Class: S3fsr
- Inherits:
-
Object
- Object
- S3fsr
- Defined in:
- lib/s3fsr.rb
Instance Method Summary collapse
- #can_delete?(path) ⇒ Boolean
- #can_mkdir?(path) ⇒ Boolean
- #can_rmdir?(path) ⇒ Boolean
- #can_write?(path) ⇒ Boolean
- #contents(path) ⇒ Object
- #delete(path) ⇒ Object
- #directory?(path) ⇒ Boolean
- #executable?(path) ⇒ Boolean
- #file?(path) ⇒ Boolean
-
#initialize(root) ⇒ S3fsr
constructor
A new instance of S3fsr.
- #mkdir(path) ⇒ Object
- #read_file(path) ⇒ Object
- #rmdir(path) ⇒ Object
- #size(path) ⇒ Object
- #touch(path) ⇒ Object
- #write_to(path, data) ⇒ Object
Constructor Details
Instance Method Details
#can_delete?(path) ⇒ Boolean
290 291 292 |
# File 'lib/s3fsr.rb', line 290 def can_delete?(path) o = get_object(path) ; o == nil ? false : o.is_file? end |
#can_mkdir?(path) ⇒ Boolean
296 297 298 299 |
# File 'lib/s3fsr.rb', line 296 def can_mkdir?(path) return false if get_object(path) != nil get_parent_object(path).is_directory? end |
#can_rmdir?(path) ⇒ Boolean
304 305 306 307 308 |
# File 'lib/s3fsr.rb', line 304 def can_rmdir?(path) return false if path == '/' return false unless get_object(path).is_directory? get_object(path).contents.length == 0 end |
#can_write?(path) ⇒ Boolean
270 271 272 273 274 275 276 277 |
# File 'lib/s3fsr.rb', line 270 def can_write?(path) o = get_object(path) if o != nil o.is_file? else d = get_parent_object(path) ; d == nil ? false : d.can_write_files? end end |
#contents(path) ⇒ Object
251 252 253 254 |
# File 'lib/s3fsr.rb', line 251 def contents(path) o = get_object(path) o == nil ? "" : o.contents end |
#delete(path) ⇒ Object
293 294 295 |
# File 'lib/s3fsr.rb', line 293 def delete(path) get_object(path).delete end |
#directory?(path) ⇒ Boolean
255 256 257 |
# File 'lib/s3fsr.rb', line 255 def directory?(path) o = get_object(path) ; o == nil ? false : o.is_directory? end |
#executable?(path) ⇒ Boolean
261 262 263 |
# File 'lib/s3fsr.rb', line 261 def executable?(path) false end |
#file?(path) ⇒ Boolean
258 259 260 |
# File 'lib/s3fsr.rb', line 258 def file?(path) o = get_object(path) ; o == nil ? false : o.is_file? end |
#mkdir(path) ⇒ Object
300 301 302 303 |
# File 'lib/s3fsr.rb', line 300 def mkdir(path) child_key = @root.path_to_key path[1..-1] get_parent_object(path).create_dir(child_key) end |
#read_file(path) ⇒ Object
267 268 269 |
# File 'lib/s3fsr.rb', line 267 def read_file(path) get_object(path).value end |
#rmdir(path) ⇒ Object
309 310 311 |
# File 'lib/s3fsr.rb', line 309 def rmdir(path) get_object(path).delete end |
#size(path) ⇒ Object
264 265 266 |
# File 'lib/s3fsr.rb', line 264 def size(path) get_object(path).size end |
#touch(path) ⇒ Object
312 313 314 315 316 317 318 319 |
# File 'lib/s3fsr.rb', line 312 def touch(path) o = get_object(path) if o != nil o.touch else write_to(path, "") end end |
#write_to(path, data) ⇒ Object
278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/s3fsr.rb', line 278 def write_to(path, data) o = get_object(path) if o != nil o.write data else d = get_parent_object(path) if d != nil child_key = @root.path_to_key path[1..-1] d.create_file(child_key, data) end end end |