我正在尝试提出一种机制,该机制将在系统上创建已知目录列表之前检查它们是否存在。
为此,我写了以下内容;但它并没有真正起作用。我相信每个循环肯定有问题,但我无法自己修复它。
我想确保在创建之前数组中的目录都不存在。
非常感谢您的帮助!
method_options path: :string
def create_folders
if profile_folders_exist?
puts "Profile folders exist already"
else
copy_profile_folders
puts "Profile folders created successfully"
end
end
private
def profile_folders_exist?
profile_folders.each do |f|
File.directory?(File.join(install_path, f))
end
end
def profile_folders
return ["Pictures", "Notes", "Signatures"]
end
def install_path
Pathname.new(options[:path].to_s)
end