module PlainSite::Utils
Public Class Methods
merge_folder(src,dest,override=false)
click to toggle source
Copy src folder's contents to dest folder recursively merge src - The String source directory dest - The String destination directory override - The Boolean value to indicate whether override exist file,default is false
# File lib/PlainSite/Utils.rb, line 60 def self.merge_folder(src,dest,override=false) src=File.realpath src files=Dir.glob src+'/**/*',File::FNM_DOTMATCH prefix_len=src.length+1 files.each do |src_path| rel_path=src_path[prefix_len..-1] dest_path=File.join(dest,rel_path) if File.directory? src_path FileUtils.mkdir_p dest_path else if override || !(File.exist? dest_path) FileUtils.copy_file src_path,dest_path end end end end