summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-08-13 08:05:47 +0200
committerNicolas "Pixel" Noble <pixel@nobis-crew.org>2010-08-13 08:05:47 +0200
commitb8430b9ada1cfa2e330a3f25a761dcf751f64d06 (patch)
treed93888d2228c2dc132ff433f618d3cb32bb8af6e
parent9df3e20a9f82e965ba8c0add8ba3bd772c132da6 (diff)
Using searchpath under linux.
-rw-r--r--src/lua-interface.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/lua-interface.cpp b/src/lua-interface.cpp
index 8b31f59..5cb47fe 100644
--- a/src/lua-interface.cpp
+++ b/src/lua-interface.cpp
@@ -242,6 +242,8 @@ static int StartTaskLoop(void * foo) {
}
#endif
+static String searchpath;
+
class Luabaselua_interface : public LuaObject {
public:
static void pushstatics(Lua *) throw (GeneralException);
@@ -368,7 +370,7 @@ int sLua_baselua_interface::baselua_interface_proceed_statics(Lua * L, int n, in
#endif
#endif
} else {
- LuaLoadPlugin(filename, L);
+ LuaLoadPlugin(filename, searchpath, L);
}
break;
case BASELUA_INTERFACE_UNLINK:
@@ -860,6 +862,20 @@ virtual int startup() throw (GeneralException) {
showbanner();
+ bool passthru = true;
+ try {
+ new Archive(argv[0], ARCHIVE_EXECUTABLE);
+ }
+ catch (...) {
+ passthru = false;
+ }
+
+#ifndef _WIN32
+ ssize_t slashpos = argv[0].strrchr('/');
+ if (slashpos >= 0)
+ searchpath = argv[0].extract(0, slashpos);
+#endif
+
/* Let's start parsing options */
while ((c = getopt_long(argc, argv, "Hhva:ile:bg:m::s::t::f:z", long_options, NULL)) != EOF) {
@@ -998,13 +1014,6 @@ virtual int startup() throw (GeneralException) {
built.write(lua_interface_light_lua, size_lua_interface_light_lua);
try {
- bool passthru = true;
- try {
- new Archive(argv[0], ARCHIVE_EXECUTABLE);
- }
- catch (...) {
- passthru = false;
- }
L->load(&built);
L->push("lua_interface_light_main");
L->gettable(LUA_GLOBALSINDEX);