**********************************************************

** Big Maps Projects code (incl. Multiplayer v1.5 **
**********************************************************
- Merged Big Maps Project code from BMP+MP trunk (Revision: 3340)
o Complete SVN Revision history: https://81.169.133.124/source/ja2/branches/Wanne/JA2%201.13%20MP
- Before THIS merge, I made a branch of the existing 1.13 source
o SVN Branch: https://81.169.133.124/source/ja2/branches/JA2_rev.3336/src
- Removed old VS 6.0 and VS 2003 project and solutions files, because compilation is broken long time ago
- I will add VS 2010 projects and solution file in the next few days

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3341 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2010-02-28 18:38:52 +00:00
parent a98c44ac78
commit 14750c6903
461 changed files with 23615 additions and 120157 deletions
+28 -9
View File
@@ -1,21 +1,40 @@
#ifndef _VFS_DIRECTORY_INTERFACE_H_
#define _VFS_DIRECTORY_INTERFACE_H_
//#include "vfs_file_interface.h"
#include "vfs_location_interface.h"
namespace vfs
{
/**
* NOTE: declaration of 'IDirectory' is in file 'vfs_location_interface' because
* of msvc and gcc incompatibilities
*
template<class WriteType>
class IDirectory : public IVFSLocation<vfs::IReadable, WriteType>
class TDirectory : public vfs::TLocationTemplate<vfs::IReadable, WriteType>
{
public:
typedef typename vfs::TLocationTemplate<vfs::IReadable, WriteType> tBaseClass;
typedef typename tBaseClass::tFileType tFileType;
typedef typename tBaseClass::tWriteType tWriteType;
*
*/
TDirectory(vfs::Path const& mountPoint, vfs::Path const& realPath)
: tBaseClass(mountPoint), m_realPath(realPath)
{};
virtual ~TDirectory()
{};
vfs::Path const& getRealPath()
{
return m_realPath;
}
virtual tFileType* addFile(vfs::Path const& sFilename, bool bDeleteOldFile=false) = 0;
virtual bool addFile(typename tBaseClass::tFileType* pFile, bool bDeleteOldFile=false) = 0;
virtual bool createSubDirectory(vfs::Path const& sSubDirPath) = 0;
virtual bool deleteDirectory(vfs::Path const& sDirPath) = 0;
virtual bool deleteFileFromDirectory(vfs::Path const& sFileName) = 0;
protected:
const vfs::Path m_realPath;
private:
void operator=(TDirectory<WriteType> const& t);
};
}
#endif // _VFS_DIRECTORY_INTERFACE_H_
+130 -122
View File
@@ -2,13 +2,58 @@
#define _VFS_FILE_INTERFACE_H_
#include "../vfs_types.h"
#include "../vfs_path.h"
#include <typeinfo>
namespace vfs
{
/**
* FileAttributes
*/
class FileAttributes
{
public:
enum Attributes {
ATTRIB_INVALID = 0,
ATTRIB_ARCHIVE = 1,
ATTRIB_DIRECTORY = 2,
ATTRIB_HIDDEN = 4,
ATTRIB_NORMAL = 8,
ATTRIB_READONLY = 16,
ATTRIB_SYSTEM = 32,
ATTRIB_TEMPORARY = 64,
ATTRIB_COMPRESSED = 128,
ATTRIB_OFFLINE = 256,
};
enum LocationType {
LT_NONE = 0,
LT_LIBRARY = 1,
LT_DIRECTORY = 2,
LT_READONLY_DIRECTORY = 4,
};
public:
FileAttributes();
FileAttributes(vfs::UInt32 attribs, LocationType location);
vfs::UInt32 getAttrib() const;
vfs::UInt32 getLocation() const;
bool isAttribSet(vfs::UInt32 attribs) const;
bool isAttribNotSet(vfs::UInt32 attribs) const;
bool isLocation(vfs::UInt32 location) const;
private:
void operator=(vfs::FileAttributes const& attr);
const vfs::UInt32 _attribs;
const vfs::UInt32 _location;
};
/**
* IBaseFile
*/
class IBaseFile
class VFS_API IBaseFile
{
public:
enum ESeekDir
@@ -18,42 +63,23 @@ namespace vfs
SD_END,
};
public:
IBaseFile(vfs::Path const& sFileName)
: m_sFileName(sFileName)
{};
virtual ~IBaseFile()
{};
IBaseFile(vfs::Path const& filename);
virtual ~IBaseFile();
vfs::Path const& GetFileName()
{
return m_sFileName;
};
virtual vfs::Path GetFullPath()
{
return GetFileName();
};
virtual vfs::FileAttributes getAttributes() = 0;
virtual bool IsWriteable() = 0;
virtual bool IsReadable() = 0;
vfs::Path const& getName();
virtual vfs::Path getPath();
virtual bool Close() = 0;
virtual bool GetFileSize(UInt32& uiFileSize) = 0;
UInt32 GetFileSize()
{
UInt32 size;
if(GetFileSize(size))
{
return size;
}
return 0;
};
virtual bool implementsWritable() = 0;
virtual bool implementsReadable() = 0;
virtual bool _getRealPath(vfs::Path& rPath)
{
return false;
}
virtual void close() = 0;
virtual vfs::size_t getSize() = 0;
virtual bool _getRealPath(vfs::Path& path);
protected:
vfs::Path m_sFileName;
vfs::Path m_filename;
};
/**
@@ -63,34 +89,34 @@ namespace vfs
class IReadable : public vfs::IReadType
{
public:
virtual bool IsOpenRead() = 0;
virtual bool OpenRead() = 0;
virtual bool Read(Byte* pData, UInt32 uiBytesToRead, UInt32& uiBytesRead) = 0;
virtual bool isOpenRead() = 0;
virtual bool openRead() = 0;
virtual vfs::size_t read(vfs::Byte* data, vfs::size_t bytesToRead) = 0;
virtual UInt32 GetReadLocation() = 0;
virtual bool SetReadLocation(UInt32 uiPositionInBytes) = 0;
virtual bool SetReadLocation(Int32 uiOffsetInBytes, IBaseFile::ESeekDir eSeekDir) = 0;
virtual vfs::size_t getReadPosition() = 0;
virtual void setReadPosition(vfs::size_t positionInBytes) = 0;
virtual void setReadPosition(vfs::offset_t offsetInBytes, vfs::IBaseFile::ESeekDir seekDir) = 0;
};
//class NonReadable : public IReadType{};
/**
* IWriteType , IWriteable
* IWriteType , IWritable
*/
class IWriteType{};
class IWriteable : public vfs::IWriteType
class IWritable : public vfs::IWriteType
{
public:
virtual bool IsOpenWrite() = 0;
virtual bool OpenWrite(bool bCreateWhenNotExist = false, bool bTruncate = false) = 0;
virtual bool Write(const Byte* pData, UInt32 uiBytesToWrite, UInt32& uiBytesWritten) = 0;
virtual bool isOpenWrite() = 0;
virtual bool openWrite(bool createWhenNotExist = false, bool truncate = false) = 0;
virtual vfs::size_t write(const vfs::Byte* data, vfs::size_t bytesToWrite) = 0;
virtual UInt32 GetWriteLocation() = 0;
virtual bool SetWriteLocation(Int32 uiPositionInBytes) = 0;
virtual bool SetWriteLocation(Int32 uiOffsetInBytes, IBaseFile::ESeekDir eSeekDir) = 0;
virtual vfs::size_t getWritePosition() = 0;
virtual void setWritePosition(vfs::size_t positionInBytes) = 0;
virtual void setWritePosition(vfs::offset_t offsetInBytes, vfs::IBaseFile::ESeekDir seekDir) = 0;
virtual bool Delete() = 0;
virtual bool deleteFile() = 0;
};
//class NonWriteable: public IWriteType{};
//class NonWritable: public IWriteType{};
/******************************************************************/
/******************************************************************/
@@ -99,127 +125,109 @@ namespace vfs
* IFileTemplate
*/
template<typename ReadType=vfs::IReadType, typename WriteType=vfs::IWriteType>
class IFileTemplate : public vfs::IBaseFile, public ReadType, public WriteType
class VFS_API TFileTemplate : public vfs::IBaseFile, public ReadType, public WriteType
{
public:
typedef ReadType read_type;
typedef WriteType write_type;
public:
IFileTemplate(vfs::Path const& sFileName)
: vfs::IBaseFile(sFileName), ReadType(), WriteType()
{};
virtual ~IFileTemplate()
{};
virtual bool IsWriteable()
typedef vfs::TFileTemplate<read_type,vfs::IWritable> write_file_type;
typedef vfs::TFileTemplate<vfs::IReadable,write_type> read_file_type;
public:
TFileTemplate(vfs::Path const& fileName)
: vfs::IBaseFile(fileName), ReadType(), WriteType()
{};
virtual ~TFileTemplate()
{};
virtual bool implementsWritable()
{
return typeid(write_type) == typeid(vfs::IWriteable);
return typeid(write_type) == typeid(vfs::IWritable);
}
virtual bool IsReadable()
virtual bool implementsReadable()
{
return typeid(read_type) == typeid(vfs::IReadable);
}
virtual vfs::IFileTemplate<read_type,vfs::IWriteable>* GetWriteable()
{
//if(IsWriteable()) TODO: test how this affects compatibility
{
return reinterpret_cast<vfs::IFileTemplate<read_type,vfs::IWriteable>*>(this);
}
return NULL;
}
virtual vfs::IFileTemplate<vfs::IReadable,write_type>* GetReadable()
{
if(IsReadable())
{
return reinterpret_cast<vfs::IFileTemplate<vfs::IReadable,write_type>*>(this);
}
return NULL;
}
};
/**
* IReadableFile
* TReadableFile
*/
template<class WriteType=vfs::IWriteType>
class IReadableFile : public vfs::IFileTemplate<IReadable,WriteType>
class TReadableFile : public vfs::TFileTemplate<vfs::IReadable,WriteType>
{
typedef vfs::TFileTemplate<vfs::IReadable,WriteType> tBaseClass;
public:
template<typename T>
static IReadableFile* Cast(T* t)
typedef vfs::TReadableFile<WriteType> read_file_type;
/////////////////////////////////////////
TReadableFile(vfs::Path const& sFilename)
: tBaseClass(sFilename)
{};
virtual ~TReadableFile(){};
/////////////////////////////////////////
read_file_type* operator=(vfs::IBaseFile const& t)
{
vfs::IBaseFile* bf = t;
return Cast<IBaseFile>(bf);
return read_file_type::cast(t);
}
template<>
static IReadableFile* Cast<IBaseFile>(IBaseFile* bf)
/////////////////////////////////////////
static read_file_type* cast(vfs::IBaseFile* bf)
{
if(bf && bf->IsReadable())
if(bf && bf->implementsReadable())
{
return static_cast<IReadableFile*>(bf);
return static_cast<read_file_type*>(bf);
}
return NULL;
}
template<class T>
IReadableFile* operator=(T const& t)
{
return IReadableFile::Cast(t);
}
public:
IReadableFile(vfs::Path const& sFileName)
: vfs::IFileTemplate<vfs::IReadable,WriteType>(sFileName)
{};
virtual ~IReadableFile(){};
protected:
IReadableFile();
TReadableFile();
};
/**
* IWriteableFile
* TWritableFile
*/
template<class ReadType=IReadType>
class IWriteableFile : public vfs::IFileTemplate<ReadType,vfs::IWriteable>
template<class ReadType=vfs::IReadType>
class TWritableFile : public vfs::TFileTemplate<ReadType,vfs::IWritable>
{
typedef vfs::TFileTemplate<ReadType,vfs::IWritable> tBaseClass;
public:
template<class T>
static IWriteableFile* Cast(T* t)
typedef vfs::TWritableFile<ReadType> write_file_type;
/////////////////////////////////////////
TWritableFile(vfs::Path const& sFilename)
: tBaseClass(sFilename)
{};
virtual ~TWritableFile(){};
/////////////////////////////////////////
write_file_type& operator=(vfs::IBaseFile const& t)
{
vfs::IBaseFile* bf = t;
return Cast<IBaseFile>(bf);
return *write_file_type::cast(t);
}
template<>
static IWriteableFile* Cast<IBaseFile>(IBaseFile* bf)
/////////////////////////////////////////
static write_file_type* cast(IBaseFile* bf)
{
if(bf && bf->IsWriteable())
if(bf && bf->implementsWritable())
{
return static_cast<IWriteableFile*>(bf);
return static_cast<write_file_type*>(bf);
}
return NULL;
}
template<class T>
IWriteableFile& operator=(T const& t)
{
return *IWriteableFile::Cast(t);
}
public:
IWriteableFile(vfs::Path const& sFileName)
: vfs::IFileTemplate<ReadType,vfs::IWriteable>(sFileName)
{};
virtual ~IWriteableFile(){};
protected:
IWriteableFile();
TWritableFile();
};
/******************************************************************/
/******************************************************************/
/**
* typedef's
*/
typedef vfs::IReadableFile<vfs::IWriteType> tReadableFile;
typedef vfs::IWriteableFile<vfs::IReadable> tWriteableFile;
//typedef vfs::IWriteableFile<vfs::IReadType> tWriteableFile;
typedef vfs::TReadableFile<vfs::IWriteType> tReadableFile;
typedef vfs::TWritableFile<vfs::IReadable> tWritableFile;
} // end namespace
+93
View File
@@ -0,0 +1,93 @@
#include "vfs_file_interface.h"
#include "vfs_library_interface.h"
/**********************************************************************
* vfs::FileAttributes
*/
vfs::FileAttributes::FileAttributes()
: _attribs(ATTRIB_NORMAL), _location(LT_NONE)
{
};
vfs::FileAttributes::FileAttributes(vfs::UInt32 attribs, LocationType location)
: _attribs(attribs), _location(location)
{
};
vfs::UInt32 vfs::FileAttributes::getAttrib() const
{
return _attribs;
};
vfs::UInt32 vfs::FileAttributes::getLocation() const
{
return _location;
};
bool vfs::FileAttributes::isAttribSet(vfs::UInt32 attribs) const
{
return attribs == (attribs & _attribs);
};
bool vfs::FileAttributes::isAttribNotSet(vfs::UInt32 attribs) const
{
return 0 == (attribs & _attribs);
};
bool vfs::FileAttributes::isLocation(vfs::UInt32 location) const
{
return location == (location & _location);
};
/**********************************************************************
* vfs::IBaseFile
*/
vfs::IBaseFile::IBaseFile(vfs::Path const& filename)
: m_filename(filename)
{};
vfs::IBaseFile::~IBaseFile()
{};
vfs::Path const& vfs::IBaseFile::getName()
{
return m_filename;
};
vfs::Path vfs::IBaseFile::getPath()
{
return this->getName();
};
bool vfs::IBaseFile::_getRealPath(vfs::Path& path)
{
return false;
}
/**********************************************************************
* vfs::ILibrary
*/
vfs::ILibrary::ILibrary(vfs::tReadableFile *libraryFile, vfs::Path const& mountPoint, bool ownFile)
: tBaseClass(mountPoint), m_ownLibFile(ownFile), m_libraryFile(libraryFile)
{
}
vfs::ILibrary::~ILibrary()
{
if(m_libraryFile && m_ownLibFile)
{
m_libraryFile->close();
delete m_libraryFile;
m_libraryFile = NULL;
}
}
vfs::Path const& vfs::ILibrary::getName()
{
return m_libraryFile->getName();
}
/**********************************************************************/
+65
View File
@@ -0,0 +1,65 @@
#ifndef _VFS_ITERATOR_INTERFACE_H_
#define _VFS_ITERATOR_INTERFACE_H_
namespace vfs
{
template<typename T>
class VFS_API TIterator
{
public:
class IImplementation
{
friend class TIterator<T>;
public:
virtual ~IImplementation() {};
virtual T* value() = 0;
virtual void next() = 0;
protected:
virtual IImplementation* clone() = 0;
};
public:
TIterator() : _obj(NULL), _iter_impl(NULL) {};
TIterator(IImplementation* impl) : _obj(NULL), _iter_impl(impl)
{
if(_iter_impl)
{
_obj = _iter_impl->value();
}
}
~TIterator()
{
if(_iter_impl) delete _iter_impl;
};
TIterator& operator=(TIterator const& t)
{
_obj = t._obj;
_iter_impl = NULL;
if(t._iter_impl)
{
_iter_impl = t._iter_impl->clone();
}
return *this;
}
//////////////////////////////
T* value() { return _obj; };
bool end() { return _obj == NULL; };
void next()
{
if(_iter_impl)
{
_iter_impl->next();
_obj = _iter_impl->value();
if(!_obj)
{
delete _iter_impl;
_iter_impl = NULL;
}
}
}
private:
T* _obj;
IImplementation* _iter_impl;
};
}
#endif // _VFS_ITERATOR_INTERFACE_H_
+16 -30
View File
@@ -3,46 +3,32 @@
#include "vfs_location_interface.h"
namespace vfs
{
class ILibrary : public vfs::IVFSLocation<vfs::IReadable,vfs::IWriteType>
class VFS_API ILibrary : public vfs::TLocationTemplate<vfs::IReadable,vfs::IWriteType>
{
typedef vfs::TLocationTemplate<vfs::IReadable,vfs::IWriteType> tBaseClass;
public:
ILibrary(tReadableFile *pLibraryFile, vfs::Path const& sMountPoint, bool bOwnFile = false)
: vfs::IVFSLocation<vfs::IReadable,vfs::IWriteType>(sMountPoint), m_pLibraryFile(pLibraryFile), m_bOwnLibFile(bOwnFile)
{};
virtual ~ILibrary()
{
if(m_pLibraryFile && m_bOwnLibFile)
{
m_pLibraryFile->Close();
delete m_pLibraryFile;
m_pLibraryFile = NULL;
}
};
ILibrary(vfs::tReadableFile *libraryFile, vfs::Path const& mountPoint, bool ownFile = false);
virtual ~ILibrary();
virtual bool Init() = 0;
virtual bool CloseLibrary() = 0;
virtual bool init() = 0;
virtual void closeLibrary() = 0;
virtual bool Close(tFileType *pFileHandle) = 0;
virtual bool OpenRead(tFileType *pFileHandle) = 0;
virtual bool Read(tFileType *pFileHandle, Byte* pData, UInt32 uiBytesToRead, UInt32& uiBytesRead) = 0;
virtual void close(tFileType *fileHandle) = 0;
virtual bool openRead(tFileType *fileHandle) = 0;
virtual vfs::size_t read(tFileType *fileHandle, vfs::Byte* data, vfs::size_t bytesToRead) = 0;
virtual UInt32 GetReadLocation(tFileType *pFileHandle) = 0;
virtual bool SetReadLocation(tFileType *pFileHandle, UInt32 uiPositionInBytes) = 0;
virtual bool SetReadLocation(tFileType *pFileHandle, Int32 uiOffsetInBytes, IBaseFile::ESeekDir eSeekDir) = 0;
virtual vfs::size_t getReadPosition(tFileType *fileHandle) = 0;
virtual void setReadPosition(tFileType *fileHandle, vfs::size_t positionInBytes) = 0;
virtual void setReadPosition(tFileType *fileHandle, vfs::offset_t offsetInBytes, IBaseFile::ESeekDir seekDir) = 0;
virtual bool GetFileSize(tFileType *pFileHandle, UInt32& uiFileSize) = 0;
virtual vfs::size_t getSize(tFileType *pFileHandle) = 0;
vfs::Path const& GetLibName()
{
return m_pLibraryFile->GetFileName();
}
vfs::Path const& getName();
protected:
vfs::tReadableFile* m_pLibraryFile;
bool m_bOwnLibFile;
bool m_ownLibFile;
vfs::tReadableFile* m_libraryFile;
};
}
@@ -17,20 +17,20 @@ namespace vfs
/**
* ILocationAware
*/
template<typename ReadType, typename WriteType>
class ILocationAware
{
public:
typedef vfs::IVFSLocation<ReadType,WriteType> tLocationType;
public:
ILocationAware(vfs::IVFSLocation<ReadType,WriteType> *pLocation)
: _pLoc_(pLocation)
{};
virtual ~ILocationAware()
{};
protected:
tLocationType* _pLoc_;
};
//template<typename ReadType, typename WriteType>
//class ILocationAware
//{
//public:
// typedef vfs::IVFSLocation<ReadType,WriteType> tLocationType;
//public:
// ILocationAware(vfs::IVFSLocation<ReadType,WriteType> *pLocation)
// : _pLoc_(pLocation)
// {};
// virtual ~ILocationAware()
// {};
//protected:
// tLocationType* _pLoc_;
//};
/******************************************************************/
/******************************************************************/
+62 -161
View File
@@ -4,231 +4,132 @@
#include "../vfs_types.h"
#include "../vfs_debug.h"
#include "vfs_file_interface.h"
#include "vfs_iterator_interface.h"
#include <map>
#include <list>
#include <typeinfo>
namespace vfs
{
class IBaseLocation
class VFS_API IBaseLocation
{
public:
class Iterator
{
public:
class IImplemetation
{
public:
virtual ~IImplemetation() {};
virtual vfs::IBaseFile* value() = 0;
virtual void next() = 0;
};
public:
Iterator() : _iter_impl(NULL), _file(NULL) {};
Iterator(IImplemetation* impl) : _iter_impl(impl), _file(NULL)
{
THROWIFFALSE(_iter_impl, L"EXCEPTION");
_file = _iter_impl->value();
}
~Iterator()
{
}
//////////////////////////////
vfs::IBaseFile* value()
{
return _file;
};
void next()
{
if(_iter_impl)
{
_iter_impl->next();
_file = _iter_impl->value();
if(!_file)
{
delete _iter_impl;
_iter_impl = NULL;
}
}
}
bool end()
{
return _file == NULL;
}
//////////////////////////////
private:
IImplemetation* _iter_impl;
vfs::IBaseFile* _file;
};
public:
typedef TIterator<vfs::IBaseFile> Iterator;
virtual ~IBaseLocation()
{};
template<typename T>
T* Cast()
{
return dynamic_cast<T*>(this);
}
virtual bool IsWriteable() = 0;
virtual bool IsReadable() = 0;
virtual bool implementsWritable() = 0;
virtual bool implementsReadable() = 0;
virtual vfs::Path const& GetFullPath() = 0;
virtual bool FileExists(vfs::Path const& sFileName) = 0;
virtual vfs::IBaseFile* GetFile(vfs::Path const& sFileName) = 0;
virtual vfs::Path const& getPath() = 0;
virtual bool fileExists(vfs::Path const& sFileName) = 0;
virtual vfs::IBaseFile* getFile(vfs::Path const& sFileName) = 0;
virtual Iterator begin() = 0;
virtual void GetSubDirList(std::list<vfs::Path>& rlSubDirs) = 0;
virtual Iterator begin() = 0;
virtual void getSubDirList(std::list<vfs::Path>& rlSubDirs) = 0;
};
/**
* IVFSLocation
* TVFSLocation
*/
//template<typename ReadType=vfs::IReadType, typename WriteType=vfs::IWriteType>
template<typename ReadType, typename WriteType>
class IVFSLocation : public IBaseLocation
class VFS_API TLocationTemplate : public IBaseLocation
{
public:
typedef vfs::IVFSLocation<ReadType,WriteType> tClassType;
typedef vfs::IFileTemplate<ReadType,WriteType> tFileType;
typedef vfs::TLocationTemplate<ReadType,WriteType> tLocationType;
typedef vfs::TFileTemplate<ReadType,WriteType> tFileType;
typedef ReadType tReadType;
typedef WriteType tWriteType;
typedef std::list<std::pair<tFileType*,vfs::Path> > tListFilesWithPath;
public:
IVFSLocation(vfs::Path const& sMountPoint)
: m_sMountPoint(sMountPoint)
TLocationTemplate(vfs::Path const& mountPoint)
: m_mountPoint(mountPoint)
{};
virtual ~IVFSLocation()
virtual ~TLocationTemplate()
{};
// has to be virtual , or the types of the caller (not the real object) will be tested
virtual bool IsWriteable()
virtual bool implementsWritable()
{
return typeid(tWriteType) == typeid(vfs::IWriteable);
return typeid(tWriteType) == typeid(vfs::IWritable);
}
virtual bool IsReadable()
virtual bool implementsReadable()
{
return typeid(tReadType) == typeid(vfs::IReadable);
}
virtual IVFSLocation<IReadType,IWriteable>* GetWriteable()
vfs::Path const& getMountPoint()
{
//if(IsWriteable()) TODO: test how this affects compatibility
{
return reinterpret_cast<IVFSLocation<vfs::IReadType,vfs::IWriteable>*>(this);
}
return NULL;
return m_mountPoint;
}
vfs::Path const& GetMountPoint()
{
return m_sMountPoint;
};
/**
* IVFSLocation interface
* TLocationTemplate interface
*/
virtual vfs::Path const& GetFullPath()
virtual vfs::Path const& getPath()
{
return m_sMountPoint;
return m_mountPoint;
}
virtual bool FileExists(vfs::Path const& sFileName) = 0;
virtual vfs::IBaseFile* GetFile(vfs::Path const& sFileName) = 0;
virtual tFileType* GetFileTyped(vfs::Path const& rFileName) = 0;
virtual bool fileExists(vfs::Path const& sFileName) = 0;
virtual vfs::IBaseFile* getFile(vfs::Path const& sFileName) = 0;
virtual tFileType* getFileTyped(vfs::Path const& rFileName) = 0;
protected:
vfs::Path m_sMountPoint;
vfs::Path m_mountPoint;
};
/**************************************************************************************/
/**************************************************************************************/
template<typename WriteType=vfs::IWriteType>
class IReadLocation : public IVFSLocation<IReadable,WriteType>
class TReadLocation : public TLocationTemplate<IReadable,WriteType>
{
public:
template<typename T>
static IReadLocation* Cast(T* t)
typedef TReadLocation<WriteType> tLocationType;
static tLocationType* cast(vfs::IBaseLocation* bl)
{
// which file type does the to tested location contain
typename T::tFileType* _F=NULL;
// is it readable?
vfs::IReadable *rf = _F;
// is the write type compatible (probably redundant)
WriteType *wf = _F;
// it is readable and the write type fits
return reinterpret_cast<IReadLocation*>(t);
}
template<>
static IReadLocation* Cast<IBaseLocation>(IBaseLocation* bl)
{
return dynamic_cast<IReadLocation*>(bl);
if(bl && bl->implementsReadable())
{
return static_cast<tLocationType*>(bl);
}
return NULL;
}
public:
IReadLocation(vfs::Path const& sLocalPath)
: vfs::IVFSLocation<IReadable,WriteType>(sLocalPath)
TReadLocation(vfs::Path const& sLocalPath)
: vfs::TLocationTemplate<IReadable,WriteType>(sLocalPath)
{};
virtual ~IReadLocation(){};
virtual ~TReadLocation(){};
};
typedef IReadLocation<vfs::IWriteType> tReadLocation;
template<typename ReadType=vfs::IReadType>
class IWriteLocation : public vfs::IVFSLocation<ReadType,vfs::IWriteable>
class TWriteLocation : public vfs::TLocationTemplate<ReadType,vfs::IWritable>
{
public:
template<class T>
static IWriteLocation* Cast(T* t)
typedef TWriteLocation<ReadType> tLocationType;
static tLocationType* cast(vfs::IBaseLocation* bl)
{
// which file type does the to tested location contain
typename T::tFileType* _F=NULL;
// is it writeable?
vfs::IWriteable *wf = _F;
// is the read type compatible (probably redundant)
ReadType *rf = _F;
// is writeable and the read type fits
return reinterpret_cast<IWriteLocation*>(t);
}
template<>
static IWriteLocation* Cast<IBaseLocation>(IBaseLocation* bl)
{
return dynamic_cast<IWriteLocation*>(bl);
if(bl && bl->implementsWritable())
{
return static_cast<tLocationType*>(bl);
}
return NULL;
}
public:
IWriteLocation(vfs::Path const& sLocalPath)
: vfs::IVFSLocation<ReadType,vfs::IWriteable>(sLocalPath)
TWriteLocation(vfs::Path const& sLocalPath)
: vfs::TLocationTemplate<ReadType,vfs::IWritable>(sLocalPath)
{};
virtual ~IWriteLocation(){};
virtual ~TWriteLocation(){};
};
typedef IWriteLocation<vfs::IReadType> tWriteLocation;
/**************************************************************************************/
/**************************************************************************************/
template<class WriteType>
class IDirectory : public vfs::IVFSLocation<vfs::IReadable, WriteType>
{
typedef typename vfs::IVFSLocation<vfs::IReadable, WriteType> tBaseType;
public:
IDirectory(vfs::Path const& sMountPoint, vfs::Path const& sRealPath)
: vfs::IVFSLocation<vfs::IReadable, WriteType>(sMountPoint), m_sRealPath(sRealPath)
{};
virtual ~IDirectory()
{};
vfs::Path const& GetRealPath()
{
return m_sRealPath;
}
virtual tBaseType::tFileType* AddFile(vfs::Path const& sFilename, bool bDeleteOldFile=false) = 0;
virtual bool AddFile( typename vfs::IVFSLocation<vfs::IReadable, WriteType>::tFileType* pFile, bool bDeleteOldFile=false) = 0;
virtual bool CreateSubDirectory(vfs::Path const& sSubDirPath) = 0;
virtual bool DeleteDirectory(vfs::Path const& sDirPath) = 0;
virtual bool DeleteFileFromDirectory(vfs::Path const& sFileName) = 0;
protected:
const vfs::Path m_sRealPath;
};
/**************************************************************************************/
/**************************************************************************************/
typedef TReadLocation<vfs::IWriteType> tReadLocation;
typedef TWriteLocation<vfs::IReadType> tWriteLocation;
} // end namespace