Module: FileUtils
Instance Method Summary collapse
- #chmod(mode, file_list) ⇒ Object
- #cp(source, target) ⇒ Object
- #mkdir_p(path) ⇒ Object (also: #mkpath, #makedirs)
- #mv(source, target) ⇒ Object
- #rm(path) ⇒ Object
Instance Method Details
#chmod(mode, file_list) ⇒ Object
| 5 6 7 8 9 10 | # File 'opal/stdlib/nodejs/fileutils.rb', line 5 def chmod(mode, file_list) raise NotImplementedError, 'symbolic mode is not supported, use numeric mode' if String === mode Array(file_list).each do |file| `__fs__.chmodSync(mode, file)` end end | 
#cp(source, target) ⇒ Object
| 12 13 14 15 | # File 'opal/stdlib/nodejs/fileutils.rb', line 12 def cp(source, target) target = File.join(target, File.basename(source)) if File.directory? target `__fs__.writeFileSync(target, __fs__.readFileSync(source))` end | 
#mkdir_p(path) ⇒ Object Also known as: mkpath, makedirs
| 21 22 23 24 | # File 'opal/stdlib/nodejs/fileutils.rb', line 21 def mkdir_p(path) return true if File.directory? path `__fs__.mkdirSync(#{path})` end | 
#mv(source, target) ⇒ Object
| 26 27 28 29 | # File 'opal/stdlib/nodejs/fileutils.rb', line 26 def mv(source, target) target = File.join(target, File.basename(source)) if File.directory? target `__fs__.renameSync(source, target)` end | 
#rm(path) ⇒ Object
| 17 18 19 | # File 'opal/stdlib/nodejs/fileutils.rb', line 17 def rm(path) `__fs__.unlinkSync(path)` end |