From 9b7df91797c90dfea34267d0afe519eb85aee490 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sun, 28 Nov 2010 11:39:55 +0100 Subject: [PATCH] Added ?/init.lua to the love loader (issue #116) --- .../filesystem/physfs/wrap_Filesystem.cpp | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/modules/filesystem/physfs/wrap_Filesystem.cpp b/src/modules/filesystem/physfs/wrap_Filesystem.cpp index a04882663..d2e4bbcba 100644 --- a/src/modules/filesystem/physfs/wrap_Filesystem.cpp +++ b/src/modules/filesystem/physfs/wrap_Filesystem.cpp @@ -244,17 +244,37 @@ namespace physfs } // Check whether file exists. - if(!instance->exists(tmp.c_str())) + if(instance->exists(tmp.c_str())) { - lua_pushfstring(L, "\n\tno file \"%s\" in LOVE game directories.\n", tmp.c_str()); - return 1; + lua_pop(L, 1); + lua_pushstring(L, tmp.c_str()); + // Ok, load it. + return instance->load(L); } - lua_pop(L, 1); - lua_pushstring(L, tmp.c_str()); + tmp = filename; + size = tmp.size(); + for(int i=0;iload(L); + if (instance->isDirectory(tmp.c_str())) + { + tmp += "/init.lua"; + if (instance->exists(tmp.c_str())) { + lua_pop(L, 1); + lua_pushstring(L, tmp.c_str()); + // Ok, load it. + return instance->load(L); + } + } + + lua_pushfstring(L, "\n\tno file \"%s\" in LOVE game directories.\n", tmp.c_str()); + return 1; } // List of functions to wrap.