forked from enlightenment/efl
elua: file search function
This commit is contained in:
parent
7c449a14e1
commit
3f4fd784c2
|
@ -2,6 +2,7 @@
|
|||
-- provides a drop-in replacement of xgettext that supports Lua (but not any
|
||||
-- other language)
|
||||
|
||||
local util = require("util")
|
||||
local cutil = require("cutil")
|
||||
local getopt = require("getopt")
|
||||
|
||||
|
@ -267,6 +268,7 @@ for i, fname in ipairs(input_files) do
|
|||
if not excluded_files[fname] then
|
||||
if onlylua or (not neverlua and fname:lower():match("^.+%.lua$")) then
|
||||
-- parse lua files here
|
||||
local fpath = util.find_file(fname, search_dirs)
|
||||
else
|
||||
args_nolua[#args_nolua] = fname
|
||||
local f = assert(cutil.popenv(hasxgettext, "r",
|
||||
|
|
|
@ -348,4 +348,22 @@ getmetatable("").__mod = function(fmts, params)
|
|||
return ret
|
||||
end
|
||||
|
||||
-- file utils
|
||||
|
||||
M.find_file = function(fname, paths)
|
||||
for i, path in ipairs(paths) do
|
||||
local actual_path
|
||||
if path:match(".*/") then
|
||||
actual_path = path .. fname
|
||||
else
|
||||
actual_path = path .. "/" .. fname
|
||||
end
|
||||
local f = io.open(actual_path)
|
||||
if f then
|
||||
f:close()
|
||||
return actual_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
Loading…
Reference in New Issue