Allow absent main.lua;

This commit is contained in:
bjorn 2016-08-16 19:11:53 -07:00
parent dad98a3f75
commit 49297ba59b
3 changed files with 6 additions and 1 deletions

View File

@ -89,7 +89,7 @@ void lovrRun(lua_State* L, char* root) {
}
// Run "main.lua" which will override/define pieces of lovr
if (luaL_dofile(L, path)) {
if (fileExists(path) && luaL_dofile(L, path)) {
error("Failed to run main.lua");
lua_pop(L, 1);
exit(EXIT_FAILURE);

View File

@ -19,6 +19,10 @@ void error(const char* format, ...) {
exit(EXIT_FAILURE);
}
int fileExists(char* filename) {
return access(filename, F_OK) != -1;
}
char* loadFile(char* filename) {
struct stat info;

View File

@ -3,6 +3,7 @@
#include <lualib.h>
void error(const char* format, ...);
int fileExists(char* filename);
char* loadFile(char* filename);
void luaRegisterModule(lua_State* L, const char* name, const luaL_Reg* module);
void luaRegisterType(lua_State* L, const char* name, const luaL_Reg* functions, lua_CFunction gc);