Class: Files::FileUtils
- Inherits:
-
Object
- Object
- Files::FileUtils
- Defined in:
- lib/files.com/models/file_utils.rb
Class Method Summary collapse
- .cd(_dir, _options) ⇒ Object
- .chmod(_mode, _list, _options = {}) ⇒ Object
-
.chmod_R(_mode, _list, _options = {}) ⇒ Object
rubocop:disable Naming/MethodName.
- .chown(_user, _group, _list, _options = {}) ⇒ Object
-
.chown_R(_user, _group, _list, _options = {}) ⇒ Object
rubocop:disable Naming/MethodName.
- .cp(src, dest, options = {}) ⇒ Object
- .cp_r(src, dest, options = {}) ⇒ Object
- .install(src, dest, options = {}) ⇒ Object
- .ln(_target, _link, _options = {}) ⇒ Object
- .ln_s(_targets, _dir, _options = {}) ⇒ Object
- .ln_sf(_target, _link, _options = {}) ⇒ Object
- .mkdir(list, params = {}, options = {}) ⇒ Object
- .mkdir_p(list, options = {}) ⇒ Object
- .mv(list, dir, options = {}) ⇒ Object
- .pwd ⇒ Object
- .rm(list, options = {}) ⇒ Object
- .rm_r(list, options = {}) ⇒ Object
- .rm_rf(list, options = {}) ⇒ Object
- .rmdir(list, options = {}) ⇒ Object
- .touch(_list, _options = {}) ⇒ Object
Class Method Details
.cd(_dir, _options) ⇒ Object
3 4 5 |
# File 'lib/files.com/models/file_utils.rb', line 3 def self.cd(_dir, ) 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, = {}) 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, = {}) # 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, = {}) 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, = {}) # 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, = {}) src = [ src ] if src.is_a? String src.each do |path| return false if File.directory?(path, ) end cp_r(src, dest, ) 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, = {}) src = [ src ] if src.is_a? String src.each do |path| FileAction.copy(path, { destination: dest }, ) 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, = {}) cp_r(src, dest, ) end |
.ln(_target, _link, _options = {}) ⇒ Object
42 43 44 |
# File 'lib/files.com/models/file_utils.rb', line 42 def self.ln(_target, _link, = {}) 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, = {}) 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, = {}) 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 = {}, = {}) list = [ list ] if list.is_a? String list.each do |path| Folder.mkdir(path, params, ) unless File.exist?(path, ) 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, = {}) 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, ) 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, = {}) list = [ list ] if list.is_a? String list.each do |path| FileAction.move(path, { destination: dir }, ) end end |
.pwd ⇒ Object
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, = {}) list = [ list ] if list.is_a? String list.each do |fname| raise Errno::EPERM.new(fname) if File.directory?(fname, ) end list.each do |fname| File.delete(fname, {}, ) 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, = {}) list = [ list ] if list.is_a? String list.each do |path| File.delete(path, { recursive: true }, ) 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, = {}) rm_r(list, ) 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, = {}) list = [ list ] if list.is_a? String list.each do |path| File.delete(path, {}, ) if File.directory?(path, ) end end |
.touch(_list, _options = {}) ⇒ Object
114 115 116 |
# File 'lib/files.com/models/file_utils.rb', line 114 def self.touch(_list, = {}) raise NotImplementedError end |