From: Daniel Kolesa Date: Thu, 22 May 2014 13:07:02 +0000 (+0100) Subject: elua: file search function X-Git-Tag: upstream/1.10.0+1149+ga3a15b1~644^2~72 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f4fd784c202574bb356b18fc6754d0148d7db50;p=platform%2Fupstream%2Fefl.git elua: file search function --- diff --git a/src/bin/elua/apps/xgettext.lua b/src/bin/elua/apps/xgettext.lua index efd037f..5953fef 100644 --- a/src/bin/elua/apps/xgettext.lua +++ b/src/bin/elua/apps/xgettext.lua @@ -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", diff --git a/src/bin/elua/core/util.lua b/src/bin/elua/core/util.lua index 45267fc..a76c6d2 100644 --- a/src/bin/elua/core/util.lua +++ b/src/bin/elua/core/util.lua @@ -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 \ No newline at end of file