// enumerations
//! Enumeration for different types of external folders (for example archives).
enum E_ARCHIVE_TYPE
{
//! Automatically get the filesystem type from the file name/url
EARC_AUTOMATIC = MAKE_IRR_ID('a','u','t','o'),
//! Zip file system
EARC_ZIP = MAKE_IRR_ID('z','i','p','\0'),
//! Pak file system
EARC_PAK = MAKE_IRR_ID('p','a','k','\0'),
//! A folder added to the filesystem
EARC_FOLDER = MAKE_IRR_ID('f','l','d','r')
};
// Flags for loading archives.
enum E_ARCHIVE_FLAGS
{
//! If this flag is set, then the contents of the archive can only be accessed
//! by providing the name of the archive as if it was a folder.
//! For example, you would have to use getMesh("file.zip/mesh.x") rather than
//! just getMesh("mesh.x")
EARCF_ARCHIVE_AS_FOLDER = 0x1,
//! If this flag is set, then the contents of the archive will be case insensitive.
//! For example, with this flag enabled getMesh("Mesh.X") and getMesh("mesh.x") would
//! return the same file.
EARCF_IGNORE_CASE = 0x2,
//! If this flag is set then you can access files without giving their complete path.
//! For example, with this flag enabled you can use getMesh("mesh.x") instead of
//! getMesh("meshes/mesh.x")
EARCF_IGNORE_PATH = 0x4,
//! These are the default flags for creating archives, it enables both EARCF_IGNORE_CASE
//! and EARCF_IGNORE_PATH
EARCF_DEFAULT = EARCF_IGNORE_CASE | EARCF_IGNORE_PATH
};
// classes
class IArchive : public IUnknown
{
public:
//! Opens a file for read access.
virtual IReadFile* createAndOpenFile(const c8* filename) = 0;
//! Returns true if this archive is able to create or write to files, false if not
virtual bool isWritable() { return false; }
//! creates a new file within the archive
virtual IWriteFile* createAndWriteFile(const c8* filename, bool append=false) { return 0; }
};
class IArchiveLoader : public IUnknown
{
//! returns true if this archive loader thinks it can open the file type based on the file name.
virtual bool isALoadableArchiveType(const c8* filename) const =0;
//! returns true if this archive loader thinks it can open the given archive type
virtual bool isALoadableArchiveType(E_ARCHIVE_TYPE type) const =0;
//! attempts to create an archive
//! \return Returns the archive on success, 0 on failure
virtual IArchive* createArchive(const c8* filename, u32 flags) = 0;
//! returns the default priority of archives added by this loader.
virtual s32 getDefaultPriority() const { return 40; }
};
// IFileSystem:
virtual IArchive* addArchive(const c8* resource, E_ARCHIVE_FLAGS flags,
E_ARCHIVE_TYPE type=EARC_AUTOMATIC, s32 priority=-1) = 0;
virtual void registerArchiveLoader(IArchiveLoader* loader, s32 priority = 40) = 0;