예제 #1
0
FileSystem::FileSystem(const char *argv0,
                       bool allowSymlinks)
{
	p = new FileSystemPrivate;

	p->havePathCache = false;

	/* Image extensions */
	p->extensions[Image].push_back("jpg");
	p->extensions[Image].push_back("png");

	/* Audio extensions */
	const Sound_DecoderInfo **di;
	for (di = Sound_AvailableDecoders(); *di; ++di)
	{
		const char **ext;
		for (ext = (*di)->extensions; *ext; ++ext)
		{
			/* All reported extensions are uppercase,
			 * so we need to hammer them down first */
			char buf[16];
			for (size_t i = 0; i < sizeof(buf); ++i)
			{
				buf[i] = tolower((*ext)[i]);

				if (!buf[i])
					break;
			}

			p->extensions[Audio].push_back(buf);
		}
	}

	if (rgssVer >= 2 && !contains(p->extensions[Audio], std::string("ogg")))
		p->extensions[Audio].push_back("ogg");

	p->extensions[Audio].push_back("mid");
	p->extensions[Audio].push_back("midi");

	/* Font extensions */
	p->extensions[Font].push_back("ttf");
	p->extensions[Font].push_back("otf");

	PHYSFS_init(argv0);

	PHYSFS_registerArchiver(&RGSS1_Archiver);
	PHYSFS_registerArchiver(&RGSS2_Archiver);
	PHYSFS_registerArchiver(&RGSS3_Archiver);

	if (allowSymlinks)
		PHYSFS_permitSymbolicLinks(1);
}
예제 #2
0
FileSystem::FileSystem(const char *argv0,
                       bool allowSymlinks)
{
	p = new FileSystemPrivate;
	p->havePathCache = false;

	PHYSFS_init(argv0);

	PHYSFS_registerArchiver(&RGSS1_Archiver);
	PHYSFS_registerArchiver(&RGSS2_Archiver);
	PHYSFS_registerArchiver(&RGSS3_Archiver);

	if (allowSymlinks)
		PHYSFS_permitSymbolicLinks(1);
}
예제 #3
0
FileSystem::FileSystem(std::vector<UString> paths)
{
	// FIXME: Is this the right thing to do that?
	LogInfo("Registering external archivers...");
	PHYSFS_registerArchiver(getCueArchiver());
	// Paths are supplied in inverse-search order (IE the last in 'paths' should be the first
	// searched)
	for (auto &p : paths)
	{
		if (!PHYSFS_mount(p.cStr(), "/", 0))
		{
			LogInfo("Failed to add resource dir \"%s\", error: %s", p,
			        PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()));
			continue;
		}
		else
			LogInfo("Resource dir \"%s\" mounted to \"%s\"", p, PHYSFS_getMountPoint(p.cStr()));
	}
	this->writeDir = PHYSFS_getPrefDir(PROGRAM_ORGANISATION, PROGRAM_NAME);
	LogInfo("Setting write directory to \"%s\"", this->writeDir);
	PHYSFS_setWriteDir(this->writeDir.cStr());
	// Finally, the write directory trumps all
	PHYSFS_mount(this->writeDir.cStr(), "/", 0);
}