Sha256: c38d776113c85aee33e7c87c410255f2b21a78b34496237a5021803a064ef935
Contents?: true
Size: 938 Bytes
Versions: 3
Compression:
Stored size: 938 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
berkshelf-1.0.0 | lib/berkshelf/core_ext/file_utils.rb |
berkshelf-1.0.0.rc3 | lib/berkshelf/core_ext/file_utils.rb |
berkshelf-1.0.0.rc2 | lib/berkshelf/core_ext/file_utils.rb |