Sha256: e4912055f40485befbe8087d7122b38c8b4c63b7c428bd5cd704c9b4656ae787
Contents?: true
Size: 939 Bytes
Versions: 2
Compression:
Stored size: 939 Bytes
Contents
require 'fileutils' module FileUtils class << self alias_method :old_mv, :mv # Override mv to ensure {safe_mv} is run if we are on the Windows platform. # # @see {FileUtils::mv} # @see {safe_mv} def mv(src, dest, options = {}) if windows? safe_mv(src, dest, options) else old_mv(src, dest, options) end end # If we encounter Errno::EACCES, which seems to happen occasionally on Windows, # try to copy and delete the file instead of moving it. # # @see https://github.com/RiotGames/berkshelf/issues/140 # @see http://www.ruby-forum.com/topic/1044813 # # @param [String] src # @param [String] dest # @param [Hash] options # @see {FileUtils::mv} def safe_mv(src, dest, options = {}) FileUtils.old_mv(src, dest, options) rescue Errno::EACCES FileUtils.cp_r(src, dest) FileUtils.rm_rf(src) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
berkshelf-1.0.0.rc1 | lib/berkshelf/core_ext/file_utils.rb |
berkshelf-0.6.0.beta4 | lib/berkshelf/core_ext/file_utils.rb |