Class: FileSystem::LocalFileSystem
- Inherits:
-
Object
- Object
- FileSystem::LocalFileSystem
- Defined in:
- lib/swineherd/filesystem/filesystems.rb
Defined Under Namespace
Classes: LocalFile
Instance Method Summary collapse
-
#cp(srcpath, dstpath) ⇒ Object
Works like UNIX cp -r.
-
#entries(dirpath) ⇒ Object
Give contained files/dirs.
-
#exists?(path) ⇒ Boolean
Does this exist?.
-
#mkpath(path) ⇒ Object
Make directory path if it does not (partly) exist.
-
#mv(srcpath, dstpath) ⇒ Object
Works like UNIX mv.
-
#open(path, mode = "r", &blk) ⇒ Object
Open a file in this filesystem.
-
#rm(path) ⇒ Object
Works like rm -r.
-
#type(path) ⇒ Object
Return file type (“dir” or “file” or “symlink”).
Instance Method Details
#cp(srcpath, dstpath) ⇒ Object
Works like UNIX cp -r
37 38 39 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 37 def cp(srcpath,dstpath) FileUtils.cp_r(srcpath,dstpath) end |
#entries(dirpath) ⇒ Object
Give contained files/dirs
61 62 63 64 65 66 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 61 def entries(dirpath) if type(dirpath) != "directory" return nil end Dir.entries(dirpath) end |
#exists?(path) ⇒ Boolean
Does this exist?
27 28 29 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 27 def exists?(path) File.exists?(path) end |
#mkpath(path) ⇒ Object
Make directory path if it does not (partly) exist
42 43 44 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 42 def mkpath(path) FileUtils.mkpath end |
#mv(srcpath, dstpath) ⇒ Object
Works like UNIX mv
32 33 34 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 32 def mv(srcpath,dstpath) FileUtils.mv(srcpath,dstpath) end |
#open(path, mode = "r", &blk) ⇒ Object
Open a file in this filesystem
17 18 19 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 17 def open(path,mode="r",&blk) return LocalFile.new(path,mode,&blk) end |
#rm(path) ⇒ Object
Works like rm -r
22 23 24 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 22 def rm(path) FileUtils.rm_r(path) end |
#type(path) ⇒ Object
Return file type (“dir” or “file” or “symlink”)
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/swineherd/filesystem/filesystems.rb', line 47 def type(path) if File.symlink?(path) return "symlink" end if File.directory?(path) return "directory" end if File.file?(path) return "file" end "unknown" end |