我正在尝试编写一个简单的文件传输脚本:
def copy_vscode_files(in_or_out)
vsc_path = Paths.base_path[@year] + Paths.vscode_path
Paths.vscode_files.each do |file|
path = vsc_path + "/#{file}"
case in_or_out
when "in" then FileUtils.cp_r(path, transfer_path)
when "out" then FileUtils.cp_r(transfer_path, path)
end
end
end
复制可以正常工作,但是当我尝试复制时会得到
Errno::EEXIST: File exists @ dir_s_mkdir - /Users/TuzsNewMacBook/Library/Application Support/Code/User/keybindings.json
,这让我感到困惑,因为我从来没有在此方法或它所调用的任何方法中调用mkdir
。
这也令人困惑,因为虽然是的,但它提到的文件确实存在,“复制”还涉及覆盖现有文件。