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.


98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/miga/common.rb', line 98

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