Method: PDK::Util::Filesystem.mv

Defined in:
lib/pdk/util/filesystem.rb

.mv(*args) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/pdk/util/filesystem.rb', line 117

def mv(*args)
  FileUtils.mv(*args)
rescue Errno::ENOENT
  # PDK-1169 - FileUtils.mv raises Errno::ENOENT when moving files inside
  #            VMWare shared folders on Windows. So we need to catch this
  #            case, check if the file exists to see if the exception is
  #            legit and "move" the file with cp & rm.
  src, dest, opts = args
  raise unless File.exist?(src)

  FileUtils.cp(src, dest, preserve: true)
  if (opts ||= {})[:secure]
    FileUtils.remove_entry_secure(src, opts[:force])
  else
    FileUtils.remove_entry(src, opts[:force])
  end
end