Module: FileUtils

Extended by:
FileUtils
Included in:
FileUtils
Defined in:
opal/stdlib/nodejs/fileutils.rb

Overview

backtick_javascript: true

Instance Method Summary collapse

Instance Method Details

#chmod(mode, file_list) ⇒ Object

Raises:

  • (NotImplementedError)


7
8
9
10
11
12
# File 'opal/stdlib/nodejs/fileutils.rb', line 7

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



14
15
16
17
# File 'opal/stdlib/nodejs/fileutils.rb', line 14

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



23
24
25
26
# File 'opal/stdlib/nodejs/fileutils.rb', line 23

def mkdir_p(path)
  return true if File.directory? path
  `__fs__.mkdirSync(#{path})`
end

#mv(source, target) ⇒ Object



28
29
30
31
# File 'opal/stdlib/nodejs/fileutils.rb', line 28

def mv(source, target)
  target = File.join(target, File.basename(source)) if File.directory? target
  `__fs__.renameSync(source, target)`
end

#rm(path) ⇒ Object



19
20
21
# File 'opal/stdlib/nodejs/fileutils.rb', line 19

def rm(path)
  `__fs__.unlinkSync(path)`
end