Module: FileUtils

Defined in:
lib/ext/fileutils.rb

Class Method Summary collapse

Class Method Details

.ln_sr(from, to) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/ext/fileutils.rb', line 12

def self.ln_sr(from, to)
  from = Pathname.new(from)
  to_dir = File.dirname(to)
  to_file = File.basename(to)
  relpath = from.relative_path_from(File.dirname(to))
  Dir.chdir(to_dir) { FileUtils.ln_s(relpath, File.basename(to)) }
end

.touch_p(file) ⇒ Object



6
7
8
9
10
# File 'lib/ext/fileutils.rb', line 6

def self.touch_p(file)
  dir = File.dirname(file)
  File.exist?(dir) or FileUtils.mkdir_p(dir)
  touch(file)
end