bool Lua::Load( const string& filename ) { File pathTranslator; // use this to determine the physfs-resolved path, e.g. absolute/full path if( ! luaInitialized ) { if( Init() == false ) { LogMsg(WARN, "Could not load Lua script. Unable to initialize Lua." ); return( false ); } } if( pathTranslator.OpenRead( filename ) == false ) { LogMsg(ERR,"Error loading '%s' from filesystem", filename.c_str()); return false; } // Load the lua script if( 0 != luaL_loadfile(L, pathTranslator.GetAbsolutePath().c_str()) ) { LogMsg(ERR,"Error loading '%s': %s", pathTranslator.GetAbsolutePath().c_str(), lua_tostring(L, -1)); return false; } // Execute the lua script if( 0 != lua_pcall(L, 0, 0, 0) ) { LogMsg(ERR,"Error Executing '%s': %s", filename.c_str(), lua_tostring(L, -1)); return false; } LogMsg(INFO,"Loaded Lua Script '%s'",filename.c_str()); return( true ); }
/**\brief Loads the font (uses FTGL Texture Fonts). * \param filename Path to font file. */ bool Font::Load( string filename ) { File fontFile; if( fontFile.OpenRead( filename.c_str() ) == false) { LogMsg(ERR, "Font '%s' could not be loaded.", fontname.c_str() ); return( false ); } if( this->font != NULL) { LogMsg(ERR, "Deleting the old font '%s'.\n", fontname.c_str() ); delete this->font; } fontname = fontFile.GetAbsolutePath(); this->font = new FTTextureFont( fontname.c_str() ); if( font == NULL ) { LogMsg(ERR, "Failed to load font '%s'.\n", fontname.c_str() ); return( false ); } font->FaceSize(12); LogMsg(INFO, "Font '%s' loaded.\n", fontname.c_str() ); return( true ); }
// recursively write the files and dirs void MakeImage::WriteFiles(Directory *root, ofstream &out) { char *sector = 0; sector = new char[SECTOR_SIZE]; ZeroMemory(sector, SECTOR_SIZE); root->CreatePathDescriptor(sector, false); WriteSector(out, root->GetBlock(), sector); delete [] sector; for(UINT i=0; i < root->mChildren.size(); ++i) { WriteFiles(root->mChildren[i], out); } for(UINT i=0; i < root->mFiles.size(); ++i) { File *curFile = root->mFiles[i]; int writeSector = curFile->GetBlock(); char filePath[MAX_PATH]; strcpy_s(filePath, MAX_PATH, "cd_root"); strcat_s(filePath, MAX_PATH, curFile->GetAbsolutePath()); ifstream in; in.open(filePath, ios_base::binary); do { sector = new char[SECTOR_SIZE]; ZeroMemory(sector, SECTOR_SIZE); in.read(sector, SECTOR_SIZE); WriteSector(out, writeSector, sector); delete [] sector; ++writeSector; } while(!in.eof()); in.close(); } }