Class: Swineherd::LocalFileSystem

Inherits:
Object
  • Object
show all
Includes:
BaseFileSystem
Defined in:
lib/swineherd/filesystem/localfilesystem.rb

Defined Under Namespace

Classes: LocalFile

Instance Method Summary collapse

Methods included from BaseFileSystem

#check_paths, #close

Constructor Details

#initialize(*args) ⇒ LocalFileSystem

Returns a new instance of LocalFileSystem.



9
10
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 9

def initialize *args
end

Instance Method Details

#cp(srcpath, dstpath) ⇒ Object



34
35
36
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 34

def cp srcpath, dstpath
  FileUtils.cp_r(srcpath,dstpath)
end

#entries(dirpath) ⇒ Object



54
55
56
57
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 54

def entries dirpath
  return unless (type(dirpath) == "directory")
  Dir.entries(dirpath)
end

#exists?(path) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 26

def exists? path
  File.exists?(path)
end

#mkpath(path) ⇒ Object



38
39
40
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 38

def mkpath path
  FileUtils.mkpath path
end

#mv(srcpath, dstpath) ⇒ Object



30
31
32
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 30

def mv srcpath, dstpath
  FileUtils.mv(srcpath,dstpath)
end

#open(path, mode = "r", &blk) ⇒ Object



12
13
14
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 12

def open path, mode="r", &blk
  return LocalFile.new path, mode, &blk
end

#rm(path) ⇒ Object



22
23
24
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 22

def rm path
  FileUtils.rm_r path
end

#size(path) ⇒ Object



16
17
18
19
20
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 16

def size path
  sz = 0
  Find.find(path){|f| sz += File.size(f)}
  sz
end

#type(path) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/swineherd/filesystem/localfilesystem.rb', line 42

def type path
  case
  when File.symlink?(path) then
    return "symlink"
  when File.directory?(path) then
    return "directory"
  when File.file?(path) then
      return "file"
  end
  "unknown"
end