lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Friday 02 June 2006 11:03 am, Mildred wrote:
> Maybe a function could be added to the template package that do this
> path searching. It would take the file you search, the path and return
> the filename if any ...
> Maybe in lua 5.2 ?

lifted from compat-5.1:

-- looks for a file `name' in given path
local function findfile (name, pname)
        name = gsub (name, "%.", LUA_DIRSEP)
        local path = _PACKAGE[pname]
        assert (type(path) == "string", format ("package.%s must be a string", 
        for c in gfind (path, "[^;]+") do
                c = gsub (c, "%"..LUA_PATH_MARK, name)
                local f = (c)
                if f then
                        f:close ()
                        return c
        return nil -- not found


Attachment: pgp7WbjYZVTno.pgp
Description: PGP signature