All pastes #634753 Raw Edit

Untitled

public cpp v1 · immutable
#634753 ·published 2007-07-26 17:11 UTC
rendered paste body
// Copyright 2005-2007 by Lightfeather-Team// Written by Yiannis Mandravellos// This file is part of the Lightfeather 3D-Engine.// The license under which this code is distributed can be found in the file COPYING#ifndef I_FILESYSTEM_EXTENSION_H#define I_FILESYSTEM_EXTENSION_H#include <lf/LfConfig.h>#include <lf/core/lftypes.h>#include <lf/core/stringc.h>#include <lf/core/CRefCounted.h>namespace lf{namespace os{class CFile;class CFileSystem;//! Abstract interface for filesystem extensions.//!//! Allows the real filesystem handling in LF to access other types//! of virtual filesystems. Examples include zip-filesystems,//! database-filesystems, ftp-filesystems, etc. Just create a class//! (implementing this interface) to handle these unknown-to-LF//! filesystems.//!//! \see CZipFileSystem as an example.class IFileSystemExtension : public CRefCounted{	public:		IFileSystemExtension(){}		virtual ~IFileSystemExtension(){}				//! Sets the owning filesystem.		//! This is automatically called by the owning filesystem and the user		//! should never need to call this.		virtual void setOwningFileSystem(CFileSystem* fs) = 0;				//! Each filesystem extension must have a unique identifier so that		//! the filesystem can distinguish between filesystem extension types.		//! So, for example, a 7-zip based filesystem extension would have		//! a "7z" identifier. Then you could use this identifier like so:		//! CFileSystem::addVirtualFileSystem("7z:some_archive.pak");		//! LF would see the "7z:" prefix and pass the rest of the argument to the		//! correct filesystem extension for handling.		//! Notice that the actual archive's extension doesn't matter at all.		//!		//! \return The filesystem's identifier.		virtual const c8* getFileSystemIdentifier() const = 0;				//! Determine if a file exists and would be able to be opened.		//!		//! \param filename Is the string identifying the file which should be tested for existance.		//! \param path Should either be NULL or a stringc pointer to receive path information for the file		//! \return True if file exists, and false if it does not exist or an error occured.		virtual bool existFile(const c8* filename, core::stringc *path) = 0;		//! Opens a file for read access.		//!		//! \param filename: Name of file to open.		//! \return Returns a pointer to the created file interface.		//! The returned pointer should be dropped when no longer needed.		//! See CRefCounted::drop() for more information.		virtual CFile* createAndOpenFile(const c8* filename) = 0;		//! Opens a file for write access.		//!		//! \param filename: Name of file to open.		//! \param append: If the file already exist, all write operations are		//! appended to the file.		//! \return Returns a pointer to the created file interface. 0 is returned, if the		//! file could not created or opened for writing.		//! The returned pointer should be dropped when no longer needed.		//! See CRefCounted::drop() for more information.		//! \note Most virtual filesystems do not support writing, so returning NULL		//! is pretty common.		virtual CFile* createAndWriteFile(const c8* filename, bool append=false) = 0;				//! Adds a virtual filesystem path to this extension.		//!		//! Imagine this extension handles a 7-zip based filesystem. Using this		//! function the actual 7-zip archive is added (e.g. addPath("some_archive.pak")).		//! User code should call CFileSystem::addVirtualFileSystem (which in turn calls		//! addPath() on the correct filesystem extension).		//! \param filename the actual filename to open.		//! \param ignoreCase: If set to true, files should be accessed without		//! writing all letters in the right case (if supported by the extension).		//! \param ignorePaths: If set to true, files should be accessed		//! without their complete path (if supported by the extension).		//! \return True on success, false on failure.		//! \note The filename argument is the same as the one in CFileSystem::addVirtualFileSystem,		//! but with the filesystem extension identifier stripped ("7z:"). The actual		//! contents of this parameter depend on the type of the virtual filesystem.		//! For archive-based filesystems it could be as simple as the actual archive filename.		//! For encrypted archives though, the extension might expect something like		//! "some_archive.pak:password". It's really up to the specific extension		//! and how it was written...		virtual bool addPath(const c8* filename, bool ignoreCase = false, bool ignorePaths = false) = 0;				//! Remove a previously added path.		//! \param filename The filename to remove.		//! \return True on success, false on failure.		virtual bool removePath(const c8* filename) = 0;};} // namespace os} // namespace lf#endif // I_FILESYSTEM_EXTENSION_H