I'm writing a basic scripting system using lua in C++. One of my glue functions is called from this:
lua_register(luaVM, "openFile", l_dial.l_specifyF);
And is coded as follows:
static int l_specifyF(lua_State* luaVM) {
const char* c = lua_tostring(luaVM, -1);
cDialogManager::getSingletonPtr()->clearVector();
try{
luaL_dofile(luaVM, c);
}
catch(...) {
cout << "Unable to open file" << endl;
luaL_dofile(luaVM, "startup.lua");
}
return 1;
}
When I call it in my application, it works 100% if I call a file from a local directory like openFile("somefile.lua")
or openFile("someotherfile.lua")
, but crashes when calling files located in external folders such as openFile("scripts/ohdear.lua")
.
Note that this does actually wor开发者_如何学运维k on some occasions, which only adds to the confusion. Are there any reasons for this? How can I remedy my application to use files from external directories?
From your description I seriously doubt that it has something to do with folder struction. My guess is, that you are observing an late reaction from an earlier error...
精彩评论