Class: File

Inherits:
Object
  • Object
show all
Defined in:
lib/miga/common.rb

Overview

MiGA extensions to the File class.

Class Method Summary collapse

Class Method Details

.generic_transfer(old_name, new_name, method) ⇒ Object

Method to transfer a file from old_name to new_name, using a method that can be one of :symlink for File#symlink, :hardlink for File#link, or :copy for FileUtils#cp_r.


201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/miga/common.rb', line 201

def self.generic_transfer(old_name, new_name, method)
  return nil if exist? new_name
  case method
  when :symlink
    File.symlink(old_name, new_name)
  when :hardlink
    File.link(old_name, new_name)
  when :copy
    FileUtils.cp_r(old_name, new_name)
  else
    raise "Unknown transfer method: #{method}."
  end
end