diff options
| author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-01 17:01:22 +0000 |
|---|---|---|
| committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-01 17:01:22 +0000 |
| commit | 9bff845b49e277af46d6b7a09bb111472f3d3f49 (patch) | |
| tree | 8277c6a4b2ac95c231ad249b63bf30ab11869a37 /apps/plugins/lua/loadlib.c | |
| parent | d5180f7870643e19c37b62909d0e0c545cc23337 (diff) | |
| download | rockbox-9bff845b49e277af46d6b7a09bb111472f3d3f49.zip rockbox-9bff845b49e277af46d6b7a09bb111472f3d3f49.tar.gz rockbox-9bff845b49e277af46d6b7a09bb111472f3d3f49.tar.bz2 rockbox-9bff845b49e277af46d6b7a09bb111472f3d3f49.tar.xz | |
Lua: because Rockbox doesn't support any current working directory functionality, 'hack' loadlib so it replace '$' in LUA_PATH_DEFAULT with the directory wherein the current script is.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21595 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lua/loadlib.c')
| -rw-r--r-- | apps/plugins/lua/loadlib.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/apps/plugins/lua/loadlib.c b/apps/plugins/lua/loadlib.c index 035116d..1cc7ebd 100644 --- a/apps/plugins/lua/loadlib.c +++ b/apps/plugins/lua/loadlib.c @@ -20,6 +20,7 @@ #include "lauxlib.h" #include "lualib.h" +#include "rocklib.h" #define setprogdir(L) ((void)0) @@ -53,7 +54,7 @@ static const char *pushnexttemplate (lua_State *L, const char *path) { static const char *findfile (lua_State *L, const char *name, const char *pname) { - const char *path; + const char *path, *current_path = get_current_path(L, 2); name = luaL_gsub(L, name, ".", LUA_DIRSEP); lua_getfield(L, LUA_ENVIRONINDEX, pname); path = lua_tostring(L, -1); @@ -63,6 +64,7 @@ static const char *findfile (lua_State *L, const char *name, while ((path = pushnexttemplate(L, path)) != NULL) { const char *filename; filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + if(current_path != NULL) filename = luaL_gsub(L, filename, "$", current_path); lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ |