Ejemplo n.º 1
0
//! opens a file by file name
IReadFile* CMountPointReader::createAndOpenFile(const io::path& filename)
{
	s32 index = findFile(filename, false);
	if (index != -1)
		return createAndOpenFile(index);
	else
		return 0;
}
Ejemplo n.º 2
0
//! opens a file by file name
IReadFile* CMountPointReader::createAndOpenFile(const core::string<c16>& filename)
{
    s32 index = findFile(filename, false);
    if (index != -1)
        return createAndOpenFile(index);
    else
        return 0;
}
Ejemplo n.º 3
0
//! Adds an archive to the file system.
bool CFileSystem::registerFileArchive(const core::string<c16>& filename, bool ignoreCase, bool ignorePaths)
{
	IFileArchive* archive = 0;
	bool ret = false;
	u32 i;

	// check if the archive was already loaded
	for (i = 0; i < FileArchives.size(); ++i)
	{
		if (filename == FileArchives[i]->getArchiveName())
			return true;
	}

	// try to load archive based on file name
	for (i = 0; i < ArchiveLoader.size(); ++i)
	{
		if (ArchiveLoader[i]->isALoadableFileFormat(filename))
		{
			archive = ArchiveLoader[i]->createArchive(filename, ignoreCase, ignorePaths);
			if (archive)
				break;
		}
	}

	// try to load archive based on content
	if (0 == archive)
	{
		io::IReadFile* file = createAndOpenFile(filename);
		if (file)
		{
			for (i = 0; i < ArchiveLoader.size(); ++i)
			{
				file->seek(0);
				if (ArchiveLoader[i]->isALoadableFileFormat(file))
				{
					file->seek(0);
					archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths);
					if (archive)
						break;
				}
			}
			file->drop ();
		}
	}

	if (archive)
	{
		FileArchives.push_back(archive);
		ret = true;
	}
	else
	{
		os::Printer::log("Could not create archive for", filename, ELL_ERROR);
	}

	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
	return ret;
}
Ejemplo n.º 4
0
	//! opens a file by file name
	IReadFile* CNPKReader::createAndOpenFile(const path& filename)
	{
		SINT32 index = findFile(filename, false);

		if (index != -1)
			return createAndOpenFile(index);

		return 0;
	}
Ejemplo n.º 5
0
//! opens a file by file name
IReadFile* CTarReader::createAndOpenFile(const io::path& filename)
{
	const s32 index = findFile(filename, false);

	if (index != -1)
		return createAndOpenFile(index);

	return 0;
}
Ejemplo n.º 6
0
//! Creates a XML Reader from a file.
IXMLReaderUTF8* CFileSystem::createXMLReaderUTF8(const c8* filename)
{
	IReadFile* file = createAndOpenFile(filename);
	if (!file)
		return 0;

	IXMLReaderUTF8* reader = createIXMLReaderUTF8(file);
	file->drop();
	return reader;
}
Ejemplo n.º 7
0
//! Creates a XML Reader from a file.
IXMLReader* CFileSystem::createXMLReader(const io::path& filename)
{
	IReadFile* file = createAndOpenFile(filename);
	if (!file)
		return 0;

	IXMLReader* reader = createXMLReader(file);
	file->drop();
	return reader;
}
Ejemplo n.º 8
0
//! Creates a XML Reader from a file.
IXMLReader* CFileSystem::createXMLReader(const core::string<c16>& filename)
{
	IReadFile* file = createAndOpenFile(filename);
	if (!file)
		return 0;

	IXMLReader* reader = createXMLReader(file);
	file->drop();
	return reader;
}
Ejemplo n.º 9
0
//! adds an pak archive to the filesystem
bool CFileSystem::addPakFileArchive(const c8* filename, bool ignoreCase, bool ignorePaths)
{
	CPakReader* zr = 0;
	IReadFile* file = createAndOpenFile(filename);
	if (file)
	{
		zr = new CPakReader(file, ignoreCase, ignorePaths);
		if (zr)
			PakFileSystems.push_back(zr);

		file->drop();
	}
	#ifdef _DEBUG
	else
		os::Printer::log("Could not open file. Pakfile not added", filename, ELL_ERROR);
	#endif

	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
	return (zr != 0);
}
Ejemplo n.º 10
0
//! Adds an archive to the file system.
bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase,
									  bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType)
{
	IFileArchive* archive = 0;
	bool ret = false;
	u32 i;

	// check if the archive was already loaded
	for (i = 0; i < FileArchives.size(); ++i)
	{
		if (filename == FileArchives[i]->getFileList()->getPath())
			return true;
	}

	// do we know what type it should be?
	if (archiveType == EFAT_UNKNOWN || archiveType == EFAT_FOLDER)
	{
		// try to load archive based on file name
		for (i = 0; i < ArchiveLoader.size(); ++i)
		{
			if (ArchiveLoader[i]->isALoadableFileFormat(filename))
			{
				archive = ArchiveLoader[i]->createArchive(filename, ignoreCase, ignorePaths);
				if (archive)
					break;
			}
		}

		// try to load archive based on content
		if (!archive)
		{
			io::IReadFile* file = createAndOpenFile(filename);
			if (file)
			{
				for (i = 0; i < ArchiveLoader.size(); ++i)
				{
					file->seek(0);
					if (ArchiveLoader[i]->isALoadableFileFormat(file))
					{
						file->seek(0);
						archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths);
						if (archive)
							break;
					}
				}
				file->drop();
			}
		}
	}
	else
	{
		// try to open archive based on archive loader type

		io::IReadFile* file = 0;

		for (i = 0; i < ArchiveLoader.size(); ++i)
		{
			if (ArchiveLoader[i]->isALoadableFileFormat(archiveType))
			{
				// attempt to open file
				if (!file)
					file = createAndOpenFile(filename);

				// is the file open?
				if (file)
				{
					// attempt to open archive
					file->seek(0);
					if (ArchiveLoader[i]->isALoadableFileFormat(file))
					{
						file->seek(0);
						archive = ArchiveLoader[i]->createArchive(file, ignoreCase, ignorePaths);
						if (archive)
							break;
					}
				}
				else
				{
					// couldn't open file
					break;
				}
			}
		}

		// if open, close the file
		if (file)
			file->drop();
	}

	if (archive)
	{
		FileArchives.push_back(archive);
		ret = true;
	}
	else
	{
		os::Printer::log("Could not create archive for", filename, ELL_ERROR);
	}

	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
	return ret;
}