Reputation: 737
I'm writing a lua application that will contain a relative path, where no matter where lua is installed it will copy a file to clibs folder for example
getPath = getWhereLuaInstalled (could be C:\program file(x86)\lua\5.1 or c:\lua\5.1..)
Using the package.path will return for me all the path lua will search to find the executable. Any Idea?
Thanks
Upvotes: 1
Views: 2079
Reputation: 52698
Normally you just use a dot for that ("."
). You can add relative paths to it: ./my/relative/path
Upvotes: 1
Reputation: 3611
It looks like you are designing this for a windows machine (.dll and your example paths indicate this) so this is a possible solution.
local io = require "io"
function getWhereLuaInstalled()
local handle = io.popen('where lua')
local path = handle:read('*a'):match("(.*\\)")
handle:close()
return path
end
This can easily be modified for linux systems by replacing where lua
with which lua
.
Upvotes: 2