void deinitPhysFS() { if (PHYSFS_isInit() != 0) { PHYSFS_deinit(); } }
/** ** Exit the game. ** ** @param err Error code to pass to shell. */ void Exit(int err) { if (GameRunning) { StopGame(GameExit); return; } StopMusic(); QuitSound(); NetworkQuitGame(); ExitNetwork1(); CleanModules(); FreeBurningBuildingFrames(); FreeSounds(); FreeGraphics(); FreePlayerColors(); FreeButtonStyles(); FreeAllContainers(); freeGuichan(); DebugPrint("Frames %lu, Slow frames %d = %ld%%\n" _C_ FrameCounter _C_ SlowFrameCounter _C_ (SlowFrameCounter * 100) / (FrameCounter ? FrameCounter : 1)); lua_settop(Lua, 0); lua_close(Lua); DeInitVideo(); #ifdef USE_PHYSFS if (PHYSFS_isInit()) { PHYSFS_deinit(); } #endif fprintf(stdout, "%s", _("Thanks for playing Stratagus.\n")); exit(err); }
bool CResourceManager::CreateDirectory(const std::string& directory) { if (PHYSFS_isInit()) { return PHYSFS_mkdir(CleanPath(directory).c_str()); } return false; }
long long CResourceManager::GetLastModificationTime(const std::string& filename) { if (PHYSFS_isInit()) { return PHYSFS_getLastModTime(CleanPath(filename).c_str()); } return -1; }
vfs::Init::~Init() { if (!PHYSFS_isInit()) { LOG_W("PhysFS already shut down."); } else if (!PHYSFS_deinit()) { LOG_E("PHYSFS_deinit failed: " + std::string(PHYSFS_getLastError())); } }
bool CResourceManager::Remove(const std::string& filename) { if (PHYSFS_isInit()) { return PHYSFS_delete(filename.c_str()) != 0; } return false; }
std::string CResourceManager::GetSaveLocation() { if (PHYSFS_isInit()) { return PHYSFS_getWriteDir(); } return ""; }
static int l_filesystem_getRealDirectory(lua_State* state) { if (!PHYSFS_isInit()) return 0; const char *dir = PHYSFS_getRealDir(l_tools_toStringOrError(state,1)); lua_pushstring(state, dir); return 1; }
bool CResourceManager::DirectoryExists(const std::string& directory) { if (PHYSFS_isInit()) { return PHYSFS_exists(CleanPath(directory).c_str()) && PHYSFS_isDirectory(CleanPath(directory).c_str()); } return false; }
bool CResourceManager::Exists(const std::string &filename) { if (PHYSFS_isInit()) { return PHYSFS_exists(CleanPath(filename).c_str()); } return false; }
CResourceManager::~CResourceManager() { if (PHYSFS_isInit()) { if (!PHYSFS_deinit()) { GetLogger()->Error("Error while deinitializing physfs: %s\n", PHYSFS_getLastError()); } } }
void FileStream::close() { if(m_fileHandle && PHYSFS_isInit()) { if(!PHYSFS_close(m_fileHandle)) throwError("close failed", true); m_fileHandle = nullptr; } m_data.clear(); m_pos = 0; }
bool FileManager::deinit() { if (PHYSFS_isInit() == 0) return true; if (PHYSFS_deinit() != 0) return true; Log::write(Log::Error, fmt::format("Error: Unable to deinit PhysFS.")); return false; }
bool FileManager::init() { if (PHYSFS_isInit() != 0) return true; if (PHYSFS_init(getRoot().getArgs(0).c_str()) != 0) return true; Log::write(Log::Error, fmt::format("Unable to init PhysFS.")); return false; }
static int l_filesystem_isFile(lua_State* state) { if (!PHYSFS_isInit()) return 0; const char* name = l_tools_toStringOrError(state, 1); if(!PHYSFS_isDirectory(name) && PHYSFS_exists(name)) lua_pushboolean(state, 1); else lua_pushboolean(state, 0); return 1; }
void Filesystem::addPath(const char *s) { if (!PHYSFS_isInit()) { throw_error; } int success = PHYSFS_mount(s, NULL, 0); if (!success) { throw_error; } }
long long CResourceManager::GetFileSize(const std::string& filename) { if (PHYSFS_isInit()) { PHYSFS_File* file = PHYSFS_openRead(CleanPath(filename).c_str()); if(file == nullptr) return -1; long long size = PHYSFS_fileLength(file); PHYSFS_close(file); return size; } return -1; }
Lux::Core::FileHandler::~FileHandler() { if (PHYSFS_isInit()) { int res = PHYSFS_deinit(); if (res == 0) { String errstr("Error destroying File System class : "); errstr.append(PHYSFS_getLastError()); Utility::ThrowError(errstr); } } }
bool CResourceManager::RemoveDirectory(const std::string& directory) { if (PHYSFS_isInit()) { std::string path = CleanPath(directory); for (auto file : ListFiles(path)) { if (PHYSFS_delete((path + "/" + file).c_str()) == 0) return false; } return PHYSFS_delete(path.c_str()) != 0; } return false; }
FileSystem::FileSystem() { name.assign("file_system"); // PHYSFS must be initialized before other modules awake, // because it will be used by them. if (PHYSFS_isInit() == 0) { char *base_path = SDL_GetBasePath(); PHYSFS_init(base_path); SDL_free(base_path); addSearchPath("."); } }
void Filesystem::init(const char *argv0) { if (!PHYSFS_isInit()) { int success = PHYSFS_init(argv0); if (!success) { throw_error; } const std::string basedir(PHYSFS_getBaseDir()); if (basedir.substr(basedir.length() - 5, 5) == ".app/") { // smells like a Mac OS X application bundle std::string resource_path = basedir + "Contents/Resources"; PHYSFS_mount(resource_path.c_str(), NULL, 0); } else { // er, uh... search in the base directory? PHYSFS_mount(basedir.c_str(), NULL, 0); } // get a platform-specific sensible directory for the app #ifdef __linux__ const char * prefdir = my_pref_dir("raceintospace.org", "Race Into Space"); #else const char *prefdir = PHYSFS_getPrefDir("raceintospace.org", "Race Into Space"); #endif if (prefdir == NULL) { throw_error; } // use this for reading, *before* the expected game data directory, thereby allowing overlays success = PHYSFS_mount(prefdir, NULL, 0); if (!success) { throw_error; } // use this for writing too PHYSFS_setWriteDir(prefdir); if (!success) { throw_error; } } }
std::vector<std::string> CResourceManager::ListFiles(const std::string &directory) { std::vector<std::string> result; if (PHYSFS_isInit()) { char **files = PHYSFS_enumerateFiles(CleanPath(directory).c_str()); for (char **i = files; *i != nullptr; i++) { result.push_back(*i); } PHYSFS_freeList(files); } return result; }
bool isInit() { return PHYSFS_isInit(); }
bool isInit() { return PHYSFS_isInit() != 0; }
void COutputStreamBuffer::open(const std::string &filename) { if (PHYSFS_isInit()) m_file = PHYSFS_openWrite(CResourceManager::CleanPath(filename).c_str()); }
bool ex_fsys_initialized () { return PHYSFS_isInit(); }
bool IsLoaded() { return PHYSFS_isInit(); }
FileSystem::~FileSystem() { if (PHYSFS_isInit() != 0) PHYSFS_deinit(); }