Class: Files::FileUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/file_utils.rb

Class Method Summary collapse

Class Method Details

.cd(_dir, _options) ⇒ Object



3
4
5
# File 'lib/files.com/models/file_utils.rb', line 3

def self.cd(_dir, _options)
  raise NotImplementedError
end

.chmod(_mode, _list, _options = {}) ⇒ Object



7
8
9
# File 'lib/files.com/models/file_utils.rb', line 7

def self.chmod(_mode, _list, _options = {})
  raise NotImplementedError
end

.chmod_R(_mode, _list, _options = {}) ⇒ Object

rubocop:disable Naming/MethodName



11
12
13
# File 'lib/files.com/models/file_utils.rb', line 11

def self.chmod_R(_mode, _list, _options = {}) # rubocop:disable Naming/MethodName
  raise NotImplementedError
end

.chown(_user, _group, _list, _options = {}) ⇒ Object



15
16
17
# File 'lib/files.com/models/file_utils.rb', line 15

def self.chown(_user, _group, _list, _options = {})
  raise NotImplementedError
end

.chown_R(_user, _group, _list, _options = {}) ⇒ Object

rubocop:disable Naming/MethodName



19
20
21
# File 'lib/files.com/models/file_utils.rb', line 19

def self.chown_R(_user, _group, _list, _options = {}) # rubocop:disable Naming/MethodName
  raise NotImplementedError
end

.cp(src, dest, options = {}) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/files.com/models/file_utils.rb', line 23

def self.cp(src, dest, options = {})
  src = [ src ] if src.is_a? String
  src.each do |path|
    return false if File.directory?(path, options)
  end
  cp_r(src, dest, options)
end

.cp_r(src, dest, options = {}) ⇒ Object



31
32
33
34
35
36
# File 'lib/files.com/models/file_utils.rb', line 31

def self.cp_r(src, dest, options = {})
  src = [ src ] if src.is_a? String
  src.each do |path|
    FileAction.copy(path, { destination: dest }, options)
  end
end

.install(src, dest, options = {}) ⇒ Object



38
39
40
# File 'lib/files.com/models/file_utils.rb', line 38

def self.install(src, dest, options = {})
  cp_r(src, dest, options)
end

.ln(_target, _link, _options = {}) ⇒ Object



42
43
44
# File 'lib/files.com/models/file_utils.rb', line 42

def self.ln(_target, _link, _options = {})
  raise NotImplementedError
end

.ln_s(_targets, _dir, _options = {}) ⇒ Object



46
47
48
# File 'lib/files.com/models/file_utils.rb', line 46

def self.ln_s(_targets, _dir, _options = {})
  raise NotImplementedError
end

.ln_sf(_target, _link, _options = {}) ⇒ Object



50
51
52
# File 'lib/files.com/models/file_utils.rb', line 50

def self.ln_sf(_target, _link, _options = {})
  raise NotImplementedError
end

.mkdir(list, params = {}, options = {}) ⇒ Object



54
55
56
57
58
59
# File 'lib/files.com/models/file_utils.rb', line 54

def self.mkdir(list, params = {}, options = {})
  list = [ list ] if list.is_a? String
  list.each do |path|
    Folder.mkdir(path, params, options) unless File.exist?(path, options)
  end
end

.mkdir_p(list, options = {}) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/files.com/models/file_utils.rb', line 61

def self.mkdir_p(list, options = {})
  list = [ list ] if list.is_a? String

  to_create = list.map do |fname|
    split = fname.split("/")
    accum = ""
    split.map do |piece|
      accum = [ accum, piece ].join("/")
    end
  end.flatten

  mkdir(to_create, options)
end

.mv(list, dir, options = {}) ⇒ Object



75
76
77
78
79
80
# File 'lib/files.com/models/file_utils.rb', line 75

def self.mv(list, dir, options = {})
  list = [ list ] if list.is_a? String
  list.each do |path|
    FileAction.move(path, { destination: dir }, options)
  end
end

.pwdObject



82
83
84
# File 'lib/files.com/models/file_utils.rb', line 82

def self.pwd
  raise NotImplementedError
end

.rm(list, options = {}) ⇒ Object



86
87
88
89
90
91
92
93
94
# File 'lib/files.com/models/file_utils.rb', line 86

def self.rm(list, options = {})
  list = [ list ] if list.is_a? String
  list.each do |fname|
    raise Errno::EPERM.new(fname) if File.directory?(fname, options)
  end
  list.each do |fname|
    File.delete(fname, {}, options)
  end
end

.rm_r(list, options = {}) ⇒ Object



96
97
98
99
100
101
# File 'lib/files.com/models/file_utils.rb', line 96

def self.rm_r(list, options = {})
  list = [ list ] if list.is_a? String
  list.each do |path|
    File.delete(path, { recursive: true }, options)
  end
end

.rm_rf(list, options = {}) ⇒ Object



103
104
105
# File 'lib/files.com/models/file_utils.rb', line 103

def self.rm_rf(list, options = {})
  rm_r(list, options)
end

.rmdir(list, options = {}) ⇒ Object



107
108
109
110
111
112
# File 'lib/files.com/models/file_utils.rb', line 107

def self.rmdir(list, options = {})
  list = [ list ] if list.is_a? String
  list.each do |path|
    File.delete(path, {}, options) if File.directory?(path, options)
  end
end

.touch(_list, _options = {}) ⇒ Object



114
115
116
# File 'lib/files.com/models/file_utils.rb', line 114

def self.touch(_list, _options = {})
  raise NotImplementedError
end