我正在尝试确定 lua 脚本中是否存在多个目录之一。它适用于 OSX,但不适用于 Windows(Linux 目前未经测试,但我希望它能够工作)。当下面的代码运行时,我得到一个错误:
此 C:\Program Files (x86)\VideoLAN\VLC\lua\playlist\ 失败:没有这样的文件或目录
我可以确认该目录存在。我已经逃脱了斜线,我不确定还有什么问题。
local oses = { "/Applications/VLC.app/Contents/MacOS/share/lua/playlist/"; "C:\\Program Files\\VideoLAN\\VLC\\lua\\playlist\\"; "C:\\Program Files (x86)\\VideoLAN\\VLC\\lua\\playlist\\"; "/usr/lib/vlc/lua/playlist" }
-- Determine which OS this is (and where to find share/lua).
local f,err = io.open( oses[1], "r")
if not err then
opsys = "OSX"
scriptpath = oses[1] .. script
f:close()
else
f,err = io.open( oses[2], "r")
if not err then
opsys = "Win32"
scriptpath = oses[2] .. script
f:close()
else
f,err = io.open( oses[3], "r")
vlc.msg.dbg( dhead .. 'failed with this ' .. err .. dtail )
if not err then
opsys = "Win64"
scriptpath = oses[3] .. script
f:close()
else
f,err = io.open( oses[4], "r")
if not err then
opsys = "Linux/Unix"
scriptpath = oses[4] .. script
f:close()
else
return false
end
end
end
end