环境:OSX 10.10 / iPhoto 9.6 / Ruby 2.2
在 ruby 脚本中,我试图从“iPhoto 库”打开一个 xml 文件以获取专辑列表..但出现错误:
f = File.open(@xmlpath)
Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/myself/Pictures/iPhoto%20Library/AlbumData.xml
首先,我在用户路径中定义了“iPhoto Library”路径:
PhotoLib = File.expand_path(File.join("~","Pictures","iPhoto Library")
然后我定义了@xml 文件路径(转义嵌入的空格)
@xmlpath = URI.escape(File.join iPhotoLib, "AlbumData.xml")
最后我尝试打开xml文件
f = File.open(@xmlpath)
但它会引发“没有这样的文件或目录”错误......我错在哪里?该文件存在于“iPhoto Library”内容中...