コード例 #1
0
ファイル: FileUtils.cpp プロジェクト: dgengin/DGEngine
	void deinitPhysFS()
	{
		if (PHYSFS_isInit() != 0)
		{
			PHYSFS_deinit();
		}
	}
コード例 #2
0
ファイル: stratagus.cpp プロジェクト: KroArtem/Wyrmgus
/**
**  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);
}
コード例 #3
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
bool CResourceManager::CreateDirectory(const std::string& directory)
{
    if (PHYSFS_isInit())
    {
        return PHYSFS_mkdir(CleanPath(directory).c_str());
    }
    return false;
}
コード例 #4
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
long long CResourceManager::GetLastModificationTime(const std::string& filename)
{
    if (PHYSFS_isInit())
    {
        return PHYSFS_getLastModTime(CleanPath(filename).c_str());
    }
    return -1;
}
コード例 #5
0
ファイル: FileSystem.cpp プロジェクト: Oberon00/jd
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()));
    }
}
コード例 #6
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
bool CResourceManager::Remove(const std::string& filename)
{
    if (PHYSFS_isInit())
    {
        return PHYSFS_delete(filename.c_str()) != 0;
    }
    return false;
}
コード例 #7
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
std::string CResourceManager::GetSaveLocation()
{
    if (PHYSFS_isInit())
    {
        return PHYSFS_getWriteDir();
    }
    return "";
}
コード例 #8
0
ファイル: filesystem.c プロジェクト: Murii/CLove
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;
}
コード例 #9
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
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;
}
コード例 #10
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
bool CResourceManager::Exists(const std::string &filename)
{
    if (PHYSFS_isInit())
    {
        return PHYSFS_exists(CleanPath(filename).c_str());
    }
    return false;
}
コード例 #11
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
CResourceManager::~CResourceManager()
{
    if (PHYSFS_isInit())
    {
        if (!PHYSFS_deinit())
        {
            GetLogger()->Error("Error while deinitializing physfs: %s\n", PHYSFS_getLastError());
        }
    }
}
コード例 #12
0
ファイル: filestream.cpp プロジェクト: Anastaciaa/otclient-1
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;
}
コード例 #13
0
ファイル: fileManager.cpp プロジェクト: Wezthal/DerpEngine
	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;
	}
コード例 #14
0
ファイル: fileManager.cpp プロジェクト: Wezthal/DerpEngine
	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;
	}
コード例 #15
0
ファイル: filesystem.c プロジェクト: Murii/CLove
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;
}
コード例 #16
0
ファイル: filesystem.cpp プロジェクト: joequant/raceintospace
void Filesystem::addPath(const char *s)
{
    if (!PHYSFS_isInit()) {
        throw_error;
    }

    int success = PHYSFS_mount(s, NULL, 0);

    if (!success) {
        throw_error;
    }
}
コード例 #17
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
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;
}
コード例 #18
0
ファイル: LuxFileHandler.cpp プロジェクト: lotsopa/Lux
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);
        }
    }
}
コード例 #19
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
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;
}
コード例 #20
0
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(".");
	}	
}
コード例 #21
0
ファイル: filesystem.cpp プロジェクト: joequant/raceintospace
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;
        }
    }
}
コード例 #22
0
ファイル: resourcemanager.cpp プロジェクト: 2asoft/colobot
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;
}
コード例 #23
0
ファイル: physfs.cpp プロジェクト: dekimsey/physfs-cpp
bool isInit() {
	return PHYSFS_isInit();
}
コード例 #24
0
 bool isInit()
 {
   return PHYSFS_isInit() != 0;
 }
コード例 #25
0
void COutputStreamBuffer::open(const std::string &filename)
{
    if (PHYSFS_isInit())
        m_file = PHYSFS_openWrite(CResourceManager::CleanPath(filename).c_str());
}
コード例 #26
0
ファイル: fsys.c プロジェクト: exdev/exsdk
bool ex_fsys_initialized () {
    return PHYSFS_isInit();
}
コード例 #27
0
ファイル: Filesystem.cpp プロジェクト: Vbitz/Engine2D
		bool IsLoaded() {
			return PHYSFS_isInit();
		}
コード例 #28
0
FileSystem::~FileSystem()
{
	if (PHYSFS_isInit() != 0)
		PHYSFS_deinit();
}