mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +02:00
- Added missing projects "VFS" & "export" to SVN
git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@4447 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/File/vfs_buffer_file.h
|
||||
* - Buffer in RAM, implements File interface to unify usage of file and memory
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_MEMORY_FILE_H_
|
||||
#define _VFS_MEMORY_FILE_H_
|
||||
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API CBufferFile : public vfs::TFileTemplate<vfs::IReadable,vfs::IWritable>
|
||||
{
|
||||
typedef vfs::TFileTemplate<vfs::IReadable,vfs::IWritable> tBaseClass;
|
||||
public :
|
||||
CBufferFile();
|
||||
CBufferFile(vfs::Path const& filename);
|
||||
virtual ~CBufferFile();
|
||||
|
||||
virtual vfs::FileAttributes getAttributes();
|
||||
|
||||
virtual void close();
|
||||
virtual vfs::size_t getSize();
|
||||
|
||||
virtual bool isOpenRead();
|
||||
virtual bool openRead();
|
||||
virtual vfs::size_t read(vfs::Byte* data, vfs::size_t bytesToRead);
|
||||
|
||||
virtual vfs::size_t getReadPosition();
|
||||
virtual void setReadPosition(vfs::size_t positionInBytes);
|
||||
virtual void setReadPosition(vfs::offset_t offsetInBytes, vfs::IBaseFile::ESeekDir seekDir);
|
||||
|
||||
virtual bool isOpenWrite();
|
||||
virtual bool openWrite(bool bCreateWhenNotExist = false, bool bTruncate = false);
|
||||
virtual vfs::size_t write(const vfs::Byte* data, vfs::size_t bytesToWrite);
|
||||
|
||||
virtual vfs::size_t getWritePosition();
|
||||
virtual void setWritePosition(vfs::size_t positionInBytes);
|
||||
virtual void setWritePosition(vfs::offset_t offsetInBytes, vfs::IBaseFile::ESeekDir seekDir);
|
||||
|
||||
virtual bool deleteFile();
|
||||
|
||||
// convenience method
|
||||
void copyToBuffer(vfs::tReadableFile& rFile);
|
||||
protected:
|
||||
std::stringstream m_buffer;
|
||||
bool m_isOpen_read, m_isOpen_write;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_MEMORY_FILE_H_
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/File/vfs_dir_file.h
|
||||
* - read/read-write files for usage in vfs locations
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_DIR_FILE_H_
|
||||
#define _VFS_DIR_FILE_H_
|
||||
|
||||
#include <vfs/Core/File/vfs_file.h>
|
||||
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_location_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_directory_interface.h>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API CReadOnlyDirFile : public vfs::CReadOnlyFile
|
||||
{
|
||||
protected:
|
||||
typedef vfs::TDirectory<vfs::CReadOnlyDirFile::write_type> tLocation;
|
||||
public:
|
||||
CReadOnlyDirFile(vfs::Path const& filename, tLocation *directory);
|
||||
virtual ~CReadOnlyDirFile();
|
||||
|
||||
virtual vfs::FileAttributes getAttributes();
|
||||
|
||||
virtual vfs::Path getPath();
|
||||
|
||||
virtual bool openRead();
|
||||
|
||||
virtual bool _getRealPath(vfs::Path& path);
|
||||
private:
|
||||
tLocation* _location;
|
||||
};
|
||||
|
||||
class VFS_API CDirFile : public vfs::CFile
|
||||
{
|
||||
typedef vfs::TDirectory<vfs::CFile::write_type> tLocation;
|
||||
public:
|
||||
CDirFile(vfs::Path const& filename, tLocation *directory);
|
||||
virtual ~CDirFile();
|
||||
|
||||
virtual vfs::FileAttributes getAttributes();
|
||||
|
||||
virtual vfs::Path getPath();
|
||||
virtual bool deleteFile();
|
||||
|
||||
virtual bool openRead();
|
||||
virtual bool openWrite(bool createWhenNotExist = false, bool truncate = false);
|
||||
|
||||
virtual bool _getRealPath(vfs::Path& path);
|
||||
private:
|
||||
tLocation* _location;
|
||||
};
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_DIR_FILE_H_
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/File/vfs_file.h
|
||||
* - File with read/read-write access
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_FILE_H_
|
||||
#define _VFS_FILE_H_
|
||||
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <vfs/Aspects/vfs_synchronization.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include "windows.h"
|
||||
#else
|
||||
# include <fstream>
|
||||
#endif
|
||||
|
||||
typedef std::basic_fstream<wchar_t> wfstream;
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
/******************************************************************/
|
||||
/******************************************************************/
|
||||
|
||||
template<typename WriteType=vfs::IWriteType>
|
||||
class VFS_API TFile : public vfs::TFileTemplate<vfs::IReadable,WriteType>
|
||||
{
|
||||
typedef vfs::TFileTemplate<vfs::IReadable,WriteType> tBaseClass;
|
||||
public :
|
||||
TFile(vfs::Path const& filename);
|
||||
virtual ~TFile();
|
||||
|
||||
virtual vfs::FileAttributes getAttributes();
|
||||
|
||||
virtual void close();
|
||||
virtual vfs::size_t getSize();
|
||||
|
||||
virtual bool isOpenRead();
|
||||
virtual bool openRead();
|
||||
virtual vfs::size_t read(vfs::Byte* data, vfs::size_t bytesToRead);
|
||||
|
||||
virtual vfs::size_t getReadPosition();
|
||||
virtual void setReadPosition(vfs::size_t positionInBytes);
|
||||
virtual void setReadPosition(vfs::offset_t offsetInBytes, vfs::IBaseFile::ESeekDir seekDir);
|
||||
|
||||
protected:
|
||||
bool _internalOpenRead(vfs::Path const& path);
|
||||
protected:
|
||||
bool m_isOpen_read;
|
||||
#ifdef WIN32
|
||||
HANDLE m_file;
|
||||
#else
|
||||
FILE* m_file;
|
||||
#endif
|
||||
//vfs::Aspects::Mutex m_mutex;
|
||||
};
|
||||
|
||||
/******************************************************************/
|
||||
/******************************************************************/
|
||||
|
||||
// implements the IWritable interface for TFile
|
||||
class VFS_API CFile : public vfs::TFile<vfs::IWritable>
|
||||
{
|
||||
typedef vfs::TFile<vfs::IWritable> tBaseClass;
|
||||
public :
|
||||
CFile(vfs::Path const& filename);
|
||||
virtual ~CFile();
|
||||
|
||||
virtual void close();
|
||||
|
||||
virtual bool isOpenWrite();
|
||||
virtual bool openWrite(bool createWhenNotExist = false, bool truncate = false);
|
||||
virtual vfs::size_t write(const vfs::Byte* data, vfs::size_t bytesToWrite);
|
||||
|
||||
virtual vfs::size_t getWritePosition();
|
||||
virtual void setWritePosition(vfs::size_t positionInBytes);
|
||||
virtual void setWritePosition(vfs::offset_t offsetInBytes, vfs::IBaseFile::ESeekDir seekDir);
|
||||
|
||||
virtual bool deleteFile();
|
||||
protected:
|
||||
bool _internalOpenWrite(vfs::Path const& path, bool createWhenNotExist = false, bool truncate = false);
|
||||
protected:
|
||||
bool m_isOpen_write;
|
||||
};
|
||||
|
||||
/******************************************************************/
|
||||
/******************************************************************/
|
||||
|
||||
typedef vfs::TFile<vfs::IWriteType> CReadOnlyFile; // needs explicit template instantiation
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_FILE_H_
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/File/vfs_lib_file.h
|
||||
* - read/read-write files for usage in vfs locations (libraries)
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_LIB_FILE_H_
|
||||
#define _VFS_LIB_FILE_H_
|
||||
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_location_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_library_interface.h>
|
||||
#include <vfs/Tools/vfs_allocator.h>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
|
||||
class ILibrary;
|
||||
|
||||
class CLibFile : public vfs::TFileTemplate<vfs::IReadable,vfs::IWriteType>
|
||||
{
|
||||
typedef vfs::TFileTemplate<vfs::IReadable,vfs::IWriteType> tBaseClass;
|
||||
typedef vfs::TLocationTemplate<vfs::IReadable,vfs::IWriteType> tLocation;
|
||||
public:
|
||||
CLibFile();
|
||||
static CLibFile* create(vfs::Path const& filename,
|
||||
tLocation *location,
|
||||
vfs::ILibrary *library,
|
||||
vfs::ObjBlockAllocator<CLibFile>* allocator = NULL);
|
||||
|
||||
// don't delete objects that YOU have not created with 'new'
|
||||
// dtor has to remain public to be usable at all
|
||||
virtual ~CLibFile();
|
||||
|
||||
virtual vfs::FileAttributes getAttributes();
|
||||
|
||||
virtual void close();
|
||||
|
||||
virtual vfs::Path getPath();
|
||||
|
||||
virtual bool isOpenRead();
|
||||
virtual bool openRead();
|
||||
virtual vfs::size_t read(vfs::Byte* pData, vfs::size_t bytesToRead);
|
||||
|
||||
virtual vfs::size_t getReadPosition();
|
||||
virtual void setReadPosition(vfs::size_t positionInBytes);
|
||||
virtual void setReadPosition(vfs::offset_t offsetInBytes, vfs::IBaseFile::ESeekDir seekDir);
|
||||
|
||||
virtual vfs::size_t getSize();
|
||||
protected:
|
||||
bool m_isOpen_read;
|
||||
ILibrary* m_library;
|
||||
tLocation* m_location;
|
||||
private:
|
||||
static vfs::ObjBlockAllocator<CLibFile>* _lfile_pool;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_LIB_FILE_H_
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/Interface/vfs_directory_interface.h
|
||||
* - partially implements Location interface for file system directories
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_DIRECTORY_INTERFACE_H_
|
||||
#define _VFS_DIRECTORY_INTERFACE_H_
|
||||
|
||||
#include <vfs/Core/Interface/vfs_location_interface.h>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
template<class 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_
|
||||
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/Interface/vfs_file_interface.h
|
||||
* - generic interface for read/write files
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_FILE_INTERFACE_H_
|
||||
#define _VFS_FILE_INTERFACE_H_
|
||||
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/vfs_path.h>
|
||||
|
||||
#include <typeinfo>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
/**
|
||||
* FileAttributes
|
||||
*/
|
||||
class VFS_API 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 VFS_API IBaseFile
|
||||
{
|
||||
public:
|
||||
enum ESeekDir
|
||||
{
|
||||
SD_BEGIN,
|
||||
SD_CURRENT,
|
||||
SD_END,
|
||||
};
|
||||
public:
|
||||
IBaseFile(vfs::Path const& filename);
|
||||
virtual ~IBaseFile();
|
||||
|
||||
virtual vfs::FileAttributes getAttributes() = 0;
|
||||
|
||||
vfs::Path const& getName();
|
||||
virtual vfs::Path getPath();
|
||||
|
||||
virtual bool implementsWritable() = 0;
|
||||
virtual bool implementsReadable() = 0;
|
||||
|
||||
virtual void close() = 0;
|
||||
virtual vfs::size_t getSize() = 0;
|
||||
|
||||
virtual bool _getRealPath(vfs::Path& path);
|
||||
protected:
|
||||
vfs::Path m_filename;
|
||||
};
|
||||
|
||||
/**
|
||||
* IReadType , IReadable
|
||||
*/
|
||||
class IReadType{};
|
||||
class IReadable : public vfs::IReadType
|
||||
{
|
||||
public:
|
||||
virtual bool isOpenRead() = 0;
|
||||
virtual bool openRead() = 0;
|
||||
virtual vfs::size_t read(vfs::Byte* data, vfs::size_t bytesToRead) = 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 , IWritable
|
||||
*/
|
||||
class IWriteType{};
|
||||
class IWritable : public vfs::IWriteType
|
||||
{
|
||||
public:
|
||||
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 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 deleteFile() = 0;
|
||||
};
|
||||
//class NonWritable: public IWriteType{};
|
||||
|
||||
/******************************************************************/
|
||||
/******************************************************************/
|
||||
|
||||
/**
|
||||
* IFileTemplate
|
||||
*/
|
||||
template<typename ReadType=vfs::IReadType, typename WriteType=vfs::IWriteType>
|
||||
class VFS_API TFileTemplate : public vfs::IBaseFile, public ReadType, public WriteType
|
||||
{
|
||||
public:
|
||||
typedef ReadType read_type;
|
||||
typedef WriteType write_type;
|
||||
|
||||
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::IWritable);
|
||||
}
|
||||
virtual bool implementsReadable()
|
||||
{
|
||||
return typeid(read_type) == typeid(vfs::IReadable);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* TReadableFile
|
||||
*/
|
||||
template<class WriteType=vfs::IWriteType>
|
||||
class TReadableFile : public vfs::TFileTemplate<vfs::IReadable,WriteType>
|
||||
{
|
||||
typedef vfs::TFileTemplate<vfs::IReadable,WriteType> tBaseClass;
|
||||
public:
|
||||
typedef vfs::TReadableFile<WriteType> read_file_type;
|
||||
|
||||
/////////////////////////////////////////
|
||||
TReadableFile(vfs::Path const& sFilename)
|
||||
: tBaseClass(sFilename)
|
||||
{};
|
||||
virtual ~TReadableFile(){};
|
||||
|
||||
/////////////////////////////////////////
|
||||
read_file_type* operator=(vfs::IBaseFile const& t)
|
||||
{
|
||||
return read_file_type::cast(t);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
static read_file_type* cast(vfs::IBaseFile* bf)
|
||||
{
|
||||
if(bf && bf->implementsReadable())
|
||||
{
|
||||
return static_cast<read_file_type*>(bf);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
protected:
|
||||
TReadableFile();
|
||||
};
|
||||
|
||||
/**
|
||||
* TWritableFile
|
||||
*/
|
||||
template<class ReadType=vfs::IReadType>
|
||||
class TWritableFile : public vfs::TFileTemplate<ReadType,vfs::IWritable>
|
||||
{
|
||||
typedef vfs::TFileTemplate<ReadType,vfs::IWritable> tBaseClass;
|
||||
public:
|
||||
typedef vfs::TWritableFile<ReadType> write_file_type;
|
||||
|
||||
/////////////////////////////////////////
|
||||
TWritableFile(vfs::Path const& sFilename)
|
||||
: tBaseClass(sFilename)
|
||||
{};
|
||||
virtual ~TWritableFile(){};
|
||||
|
||||
/////////////////////////////////////////
|
||||
write_file_type& operator=(vfs::IBaseFile const& t)
|
||||
{
|
||||
return *write_file_type::cast(t);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
static write_file_type* cast(IBaseFile* bf)
|
||||
{
|
||||
if(bf && bf->implementsWritable())
|
||||
{
|
||||
return static_cast<write_file_type*>(bf);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
protected:
|
||||
TWritableFile();
|
||||
};
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
/******************************************************************/
|
||||
|
||||
/**
|
||||
* typedef's
|
||||
*/
|
||||
typedef vfs::TReadableFile<vfs::IWriteType> tReadableFile;
|
||||
typedef vfs::TWritableFile<vfs::IReadable> tWritableFile;
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_FILE_INTERFACE_H_
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/Interface/vfs_iterator_interface.h
|
||||
* - generic interface to iterate over files in locations
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#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_
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/Interface/vfs_library_interface.h
|
||||
* - partially implements Location interface for archive files
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_LIBRARY_INTERFACE_H_
|
||||
#define _VFS_LIBRARY_INTERFACE_H_
|
||||
|
||||
#include <vfs/Core/Interface/vfs_location_interface.h>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API ILibrary : public vfs::TLocationTemplate<vfs::IReadable,vfs::IWriteType>
|
||||
{
|
||||
typedef vfs::TLocationTemplate<vfs::IReadable,vfs::IWriteType> tBaseClass;
|
||||
public:
|
||||
ILibrary(vfs::tReadableFile *libraryFile, vfs::Path const& mountPoint, bool ownFile = false);
|
||||
virtual ~ILibrary();
|
||||
|
||||
virtual bool init() = 0;
|
||||
virtual void closeLibrary() = 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 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 vfs::size_t getSize(tFileType *pFileHandle) = 0;
|
||||
|
||||
vfs::Path const& getName();
|
||||
protected:
|
||||
bool m_ownLibFile;
|
||||
vfs::tReadableFile* m_libraryFile;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // _VFS_LIBRARY_INTERFACE_H_
|
||||
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/Interface/vfs_location_interface.h
|
||||
* - generic Location interface that allows retrieval of a file from a real location
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_LOCATION_INTERFACE_H_
|
||||
#define _VFS_LOCATION_INTERFACE_H_
|
||||
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/vfs_debug.h>
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_iterator_interface.h>
|
||||
|
||||
#include <map>
|
||||
#include <list>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API IBaseLocation
|
||||
{
|
||||
public:
|
||||
typedef TIterator<vfs::IBaseFile> Iterator;
|
||||
|
||||
virtual ~IBaseLocation()
|
||||
{};
|
||||
|
||||
virtual bool implementsWritable() = 0;
|
||||
virtual bool implementsReadable() = 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;
|
||||
};
|
||||
|
||||
/**
|
||||
* TLocation
|
||||
*/
|
||||
template<typename ReadType, typename WriteType>
|
||||
class VFS_API TLocationTemplate : public IBaseLocation
|
||||
{
|
||||
public:
|
||||
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:
|
||||
TLocationTemplate(vfs::Path const& mountPoint)
|
||||
: m_mountPoint(mountPoint)
|
||||
{};
|
||||
virtual ~TLocationTemplate()
|
||||
{};
|
||||
|
||||
// has to be virtual , or the types of the caller (not the real object) will be tested
|
||||
virtual bool implementsWritable()
|
||||
{
|
||||
return typeid(tWriteType) == typeid(vfs::IWritable);
|
||||
}
|
||||
virtual bool implementsReadable()
|
||||
{
|
||||
return typeid(tReadType) == typeid(vfs::IReadable);
|
||||
}
|
||||
|
||||
vfs::Path const& getMountPoint()
|
||||
{
|
||||
return m_mountPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* TLocationTemplate interface
|
||||
*/
|
||||
virtual vfs::Path const& getPath()
|
||||
{
|
||||
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;
|
||||
protected:
|
||||
vfs::Path m_mountPoint;
|
||||
};
|
||||
|
||||
/**************************************************************************************/
|
||||
/**************************************************************************************/
|
||||
|
||||
template<typename WriteType=vfs::IWriteType>
|
||||
class TReadLocation : public TLocationTemplate<IReadable,WriteType>
|
||||
{
|
||||
public:
|
||||
typedef TReadLocation<WriteType> tLocationType;
|
||||
|
||||
static tLocationType* cast(vfs::IBaseLocation* bl)
|
||||
{
|
||||
if(bl && bl->implementsReadable())
|
||||
{
|
||||
return static_cast<tLocationType*>(bl);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
public:
|
||||
TReadLocation(vfs::Path const& sLocalPath)
|
||||
: vfs::TLocationTemplate<IReadable,WriteType>(sLocalPath)
|
||||
{};
|
||||
virtual ~TReadLocation(){};
|
||||
};
|
||||
|
||||
template<typename ReadType=vfs::IReadType>
|
||||
class TWriteLocation : public vfs::TLocationTemplate<ReadType,vfs::IWritable>
|
||||
{
|
||||
public:
|
||||
typedef TWriteLocation<ReadType> tLocationType;
|
||||
|
||||
static tLocationType* cast(vfs::IBaseLocation* bl)
|
||||
{
|
||||
if(bl && bl->implementsWritable())
|
||||
{
|
||||
return static_cast<tLocationType*>(bl);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
public:
|
||||
TWriteLocation(vfs::Path const& sLocalPath)
|
||||
: vfs::TLocationTemplate<ReadType,vfs::IWritable>(sLocalPath)
|
||||
{};
|
||||
virtual ~TWriteLocation(){};
|
||||
};
|
||||
|
||||
/**************************************************************************************/
|
||||
/**************************************************************************************/
|
||||
|
||||
typedef TReadLocation<vfs::IWriteType> tReadLocation;
|
||||
typedef TWriteLocation<vfs::IReadType> tWriteLocation;
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_LOCATION_INTERFACE_H_
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/Location/vfs_directory_tree.h
|
||||
* - class for directories in a File System, implements Directory interface
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_DIRECTORY_H_
|
||||
#define _VFS_DIRECTORY_H_
|
||||
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_directory_interface.h>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
|
||||
/**
|
||||
* IDirectory<read,write>
|
||||
*/
|
||||
template<typename WriteType>
|
||||
class TDirectoryTree : public vfs::TDirectory<WriteType>
|
||||
{
|
||||
typedef std::map<vfs::Path, vfs::TDirectory<typename TDirectoryTree<WriteType>::tWriteType>*, vfs::Path::Less> tDirCatalogue;
|
||||
|
||||
class IterImpl;
|
||||
public:
|
||||
typedef vfs::TDirectory<WriteType> tBaseClass;
|
||||
typedef typename tBaseClass::tWriteType tWriteType;
|
||||
typedef typename tBaseClass::tFileType tFileType;
|
||||
|
||||
typedef TIterator<vfs::IBaseFile> Iterator;
|
||||
TDirectoryTree(vfs::Path const& sMountPoint, vfs::Path const& sRealPath);
|
||||
virtual ~TDirectoryTree();
|
||||
|
||||
bool init();
|
||||
|
||||
/**
|
||||
* TDirectory interface
|
||||
*/
|
||||
virtual tFileType* addFile(vfs::Path const& sFilename, bool bDeleteOldFile=false);
|
||||
virtual bool addFile(tFileType* pFile, bool bDeleteOldFile=false);
|
||||
|
||||
virtual bool createSubDirectory(vfs::Path const& sSubDirPath);
|
||||
virtual bool deleteDirectory(vfs::Path const& sDirPath);
|
||||
virtual bool deleteFileFromDirectory(vfs::Path const& sFileName);
|
||||
|
||||
/**
|
||||
* TLocation interface
|
||||
*/
|
||||
virtual bool fileExists(vfs::Path const& sFileName);
|
||||
virtual vfs::IBaseFile* getFile(vfs::Path const& sFileName);
|
||||
virtual tFileType* getFileTyped(vfs::Path const& sFileName);
|
||||
virtual void getSubDirList(std::list<vfs::Path>& rlSubDirs);
|
||||
|
||||
virtual Iterator begin();
|
||||
protected:
|
||||
tDirCatalogue m_catDirs;
|
||||
};
|
||||
|
||||
typedef TDirectoryTree<vfs::IWritable> CDirectoryTree;
|
||||
typedef TDirectoryTree<vfs::IWriteType> CReadOnlyDirectoryTree;
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_DIRECTORY_H_
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/Location/vfs_lib_dir.h
|
||||
* - class for readonly (sub)directories in archives/libraries
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_LIB_DIR_H_
|
||||
#define _VFS_LIB_DIR_H_
|
||||
|
||||
#include <vfs/Core/Interface/vfs_directory_interface.h>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
|
||||
class CLibDirectory : public vfs::TDirectory<vfs::IWriteType>
|
||||
{
|
||||
typedef vfs::TDirectory<vfs::IWriteType> tBaseClass;
|
||||
typedef std::map<vfs::Path, tFileType*, vfs::Path::Less> tFileCatalogue;
|
||||
|
||||
class IterImpl;
|
||||
public:
|
||||
CLibDirectory(vfs::Path const& sLocalPath, vfs::Path const& sRealPath);
|
||||
virtual ~CLibDirectory();
|
||||
|
||||
/**
|
||||
* TDirectory interface
|
||||
*/
|
||||
virtual tFileType* addFile(vfs::Path const& filename, bool deleteOldFile=false);
|
||||
virtual bool addFile(tFileType* file, bool deleteOldFile=false);
|
||||
virtual bool deleteFileFromDirectory(vfs::Path const& filename);
|
||||
virtual bool createSubDirectory(vfs::Path const& subDirPath);
|
||||
virtual bool deleteDirectory(vfs::Path const& dirPath);
|
||||
|
||||
/**
|
||||
* TLocation interface
|
||||
*/
|
||||
virtual bool fileExists(vfs::Path const& filename);
|
||||
virtual vfs::IBaseFile* getFile(vfs::Path const& filename);
|
||||
virtual tFileType* getFileTyped(vfs::Path const& filename);
|
||||
virtual void getSubDirList(std::list<vfs::Path>& rlSubDirs);
|
||||
|
||||
virtual Iterator begin();
|
||||
protected:
|
||||
tFileCatalogue m_files;
|
||||
};
|
||||
|
||||
} // -end- namespace
|
||||
|
||||
#endif // _VFS_LIB_DIR_H_
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/Location/vfs_uncompressed_lib_base.h
|
||||
* - partially implements library interface for uncompressed archive files
|
||||
* - initialization is done in format-specific sub-classes
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_UNCOMPRESSED_LIB_BASE_H_
|
||||
#define _VFS_UNCOMPRESSED_LIB_BASE_H_
|
||||
|
||||
#include <vfs/Core/Interface/vfs_library_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_directory_interface.h>
|
||||
#include <sstream>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
|
||||
class VFS_API CUncompressedLibraryBase : public vfs::ILibrary
|
||||
{
|
||||
protected:
|
||||
typedef std::map<vfs::Path, vfs::TDirectory<vfs::ILibrary::tWriteType>*, vfs::Path::Less> tDirCatalogue;
|
||||
struct SFileData
|
||||
{
|
||||
SFileData(vfs::size_t const& fileSize, vfs::size_t const& fileOffset)
|
||||
: _fileSize(fileSize), _fileOffset(fileOffset), _currentReadPosition(0)
|
||||
{};
|
||||
vfs::size_t _fileSize, _fileOffset, _currentReadPosition;
|
||||
};
|
||||
typedef std::map<tFileType*, SFileData> tFileData;
|
||||
|
||||
class IterImpl;
|
||||
public:
|
||||
CUncompressedLibraryBase(vfs::tReadableFile *libraryFile, vfs::Path const& mountPoint, bool ownFile = false);
|
||||
virtual ~CUncompressedLibraryBase();
|
||||
|
||||
/**
|
||||
* TLocation interface
|
||||
*/
|
||||
virtual bool fileExists(vfs::Path const& filename);
|
||||
virtual vfs::IBaseFile* getFile(vfs::Path const& filename);
|
||||
virtual tFileType* getFileTyped(vfs::Path const& filename);
|
||||
virtual void getSubDirList(std::list<vfs::Path>& rlSubDirs);
|
||||
|
||||
/**
|
||||
* ILibrary interface
|
||||
*/
|
||||
virtual bool init() = 0;
|
||||
virtual void closeLibrary();
|
||||
|
||||
virtual void close(tFileType *fileHandle);
|
||||
virtual bool openRead(tFileType *fileHandle);
|
||||
virtual vfs::size_t read(tFileType *fileHandle, vfs::Byte* data, vfs::size_t bytesToRead);
|
||||
|
||||
virtual vfs::size_t getReadPosition(tFileType *fileHandle);
|
||||
virtual void setReadPosition(tFileType *fileHandle, vfs::size_t positionInBytes);
|
||||
virtual void setReadPosition(tFileType *fileHandle, vfs::offset_t offsetInBytes, IBaseFile::ESeekDir seekDir);
|
||||
|
||||
virtual vfs::size_t getSize(tFileType *fileHandle);
|
||||
|
||||
virtual Iterator begin();
|
||||
protected:
|
||||
tDirCatalogue m_dirs;
|
||||
tFileData m_fileData;
|
||||
vfs::UInt32 m_numberOfOpenedFiles;
|
||||
private:
|
||||
SFileData& _fileDataFromHandle(tFileType* handle);
|
||||
};
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_UNCOMPRESSED_LIB_BASE_H_
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs.h
|
||||
* - primary interface for the using program, get files from the VFS internal storage
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_H_
|
||||
#define _VFS_H_
|
||||
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_location_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_iterator_interface.h>
|
||||
#include <vfs/Core/vfs_vloc.h>
|
||||
#include <vfs/Core/vfs_vfile.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class CProfileStack;
|
||||
|
||||
class VFS_API CVirtualFileSystem
|
||||
{
|
||||
typedef std::map<vfs::Path,CVirtualLocation*,vfs::Path::Less> tVFS;
|
||||
|
||||
class CRegularIterator;
|
||||
class CMatchingIterator;
|
||||
public:
|
||||
typedef TIterator<vfs::tReadableFile> Iterator;
|
||||
|
||||
~CVirtualFileSystem();
|
||||
|
||||
static CVirtualFileSystem* getVFS();
|
||||
static void shutdownVFS();
|
||||
|
||||
vfs::CProfileStack* getProfileStack();
|
||||
|
||||
vfs::CVirtualLocation* getVirtualLocation(vfs::Path const& sPath, bool bCreate = false);
|
||||
bool addLocation(vfs::IBaseLocation* pLocation, vfs::CVirtualProfile *pProfile);
|
||||
|
||||
bool fileExists(vfs::Path const& rLocalFilePath, vfs::CVirtualFile::ESearchFile eSF = vfs::CVirtualFile::SF_TOP );
|
||||
bool fileExists(vfs::Path const& rLocalFilePath, std::string const& sProfileName);
|
||||
|
||||
vfs::IBaseFile* getFile(vfs::Path const& rLocalFilePath, vfs::CVirtualFile::ESearchFile eSF = vfs::CVirtualFile::SF_TOP );
|
||||
vfs::IBaseFile* getFile(vfs::Path const& rLocalFilePath, vfs::String const& sProfileName);
|
||||
|
||||
vfs::tReadableFile* getReadFile(vfs::Path const& rLocalFilePath, vfs::CVirtualFile::ESearchFile eSF = vfs::CVirtualFile::SF_TOP );
|
||||
vfs::tReadableFile* getReadFile(vfs::Path const& rLocalFilePath, vfs::String const& sProfileName);
|
||||
|
||||
vfs::tWritableFile* getWriteFile(vfs::Path const& rLocalFilePath, vfs::CVirtualFile::ESearchFile eSF = vfs::CVirtualFile::SF_TOP );
|
||||
vfs::tWritableFile* getWriteFile(vfs::Path const& rLocalFilePath, vfs::String const& sProfileName);
|
||||
|
||||
bool removeFileFromFS(vfs::Path const& sFilePath);
|
||||
bool removeDirectoryFromFS(vfs::Path const& sDir);
|
||||
bool createNewFile(vfs::Path const& sFileName);
|
||||
|
||||
Iterator begin();
|
||||
Iterator begin(vfs::Path const& sPattern);
|
||||
private:
|
||||
vfs::CProfileStack m_oProfileStack;
|
||||
tVFS m_mapFS;
|
||||
private:
|
||||
CVirtualFileSystem();
|
||||
static CVirtualFileSystem* m_pSingleton;
|
||||
};
|
||||
|
||||
VFS_API bool canWrite();
|
||||
} // end namespace
|
||||
|
||||
VFS_API vfs::CVirtualFileSystem* getVFS();
|
||||
|
||||
|
||||
#endif // _VFS_H_
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_dfebug.h
|
||||
* - Exception class and throw macros, used to notify the using program of unexpected situations
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_DEBUG_H_
|
||||
#define _VFS_DEBUG_H_
|
||||
|
||||
#include <vfs/Aspects/vfs_logging.h>
|
||||
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/vfs_path.h>
|
||||
#include <list>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
class VFS_API std::exception;
|
||||
#endif
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API Exception : public std::exception
|
||||
{
|
||||
public:
|
||||
Exception(vfs::String const& text, vfs::String const& function, int line, const char* file);
|
||||
Exception(vfs::String const& text, vfs::String const& function, int line, const char* file, std::exception& ex);
|
||||
|
||||
virtual ~Exception() throw();
|
||||
|
||||
virtual const char* what() const throw();
|
||||
|
||||
vfs::String getLastEntryString() const;
|
||||
vfs::String getExceptionString() const;
|
||||
|
||||
struct SEntry
|
||||
{
|
||||
vfs::String time;
|
||||
vfs::String message;
|
||||
vfs::String function;
|
||||
int line;
|
||||
vfs::String file;
|
||||
};
|
||||
typedef std::list<SEntry> CALLSTACK;
|
||||
CALLSTACK m_CallStack;
|
||||
};
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
#define _FUNCTION_FORMAT_ __FUNCTION__
|
||||
#else
|
||||
//#define _FUNCTION_FORMAT_ __FUNCTION__
|
||||
#define _FUNCTION_FORMAT_ __PRETTY_FUNCTION__
|
||||
#endif
|
||||
|
||||
#define VFS_THROW(message) throw vfs::Exception((message), _FUNCTION_FORMAT_, __LINE__, __FILE__)
|
||||
#define VFS_RETHROW(message,ex) throw vfs::Exception((message), _FUNCTION_FORMAT_, __LINE__, __FILE__, (ex))
|
||||
|
||||
#define VFS_THROW_IFF(boolexpr,message) if(!(boolexpr)){VFS_THROW((message));}
|
||||
|
||||
#define VFS_TRYCATCH_RETHROW(expr,message) \
|
||||
{ \
|
||||
try { (expr); } \
|
||||
catch(std::exception &ex){ throw vfs::Exception((message),_FUNCTION_FORMAT_,__LINE__,__FILE__, ex); } \
|
||||
}
|
||||
|
||||
#define VFS_IGNOREEXCEPTION(expr, log) \
|
||||
{ \
|
||||
try{ (expr); } \
|
||||
catch(std::exception& ex){ \
|
||||
if(log) VFS_LOG_ERROR(ex.what()); } \
|
||||
}
|
||||
|
||||
#endif // _VFS_DEBUG_H_
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_file_raii.h
|
||||
* - RAII classes to open files for reading/writing
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_FILE_RAII_H_
|
||||
#define _VFS_FILE_RAII_H_
|
||||
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <vfs/Core/vfs_vfile.h>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API COpenReadFile
|
||||
{
|
||||
public:
|
||||
COpenReadFile(vfs::Path const& sPath, vfs::CVirtualFile::ESearchFile eSF = vfs::CVirtualFile::SF_TOP);
|
||||
COpenReadFile(vfs::tReadableFile *pFile);
|
||||
~COpenReadFile();
|
||||
|
||||
vfs::tReadableFile* operator->();
|
||||
vfs::tReadableFile& file();
|
||||
void release();
|
||||
private:
|
||||
vfs::tReadableFile* m_pFile;
|
||||
};
|
||||
|
||||
class VFS_API COpenWriteFile
|
||||
{
|
||||
public:
|
||||
COpenWriteFile( vfs::Path const& sPath,
|
||||
bool bCreate = false,
|
||||
bool bTruncate = false,
|
||||
vfs::CVirtualFile::ESearchFile eSF = vfs::CVirtualFile::SF_STOP_ON_WRITABLE_PROFILE);
|
||||
COpenWriteFile(vfs::tWritableFile *pFile);
|
||||
~COpenWriteFile();
|
||||
|
||||
vfs::tWritableFile* operator->();
|
||||
vfs::tWritableFile& file();
|
||||
void release();
|
||||
private:
|
||||
vfs::tWritableFile* m_pFile;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_FILE_RAII_H_
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_init.h
|
||||
* - initialization functions/classes
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_INIT_H_
|
||||
#define _VFS_INIT_H_
|
||||
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/vfs_profile.h>
|
||||
#include <vfs/Tools/vfs_property_container.h>
|
||||
|
||||
namespace vfs_init
|
||||
{
|
||||
class VFS_API Location
|
||||
{
|
||||
public:
|
||||
Location();
|
||||
|
||||
bool m_optional;
|
||||
vfs::String m_type;
|
||||
vfs::Path m_path, m_vfs_path;
|
||||
vfs::Path m_mount_point;
|
||||
};
|
||||
|
||||
class VFS_API Profile
|
||||
{
|
||||
public:
|
||||
Profile();
|
||||
~Profile();
|
||||
|
||||
void addLocation(Location* loc, bool own = false);
|
||||
|
||||
////////////////////////////////////////////////
|
||||
typedef std::list<std::pair<bool,Location*> > t_locations;
|
||||
t_locations locations;
|
||||
|
||||
vfs::String m_name;
|
||||
vfs::Path m_root;
|
||||
bool m_writable;
|
||||
};
|
||||
|
||||
class VFS_API VfsConfig
|
||||
{
|
||||
public:
|
||||
typedef std::list<std::pair<bool,Profile*> > t_profiles;
|
||||
~VfsConfig();
|
||||
|
||||
t_profiles profiles;
|
||||
void addProfile(Profile* prof, bool own = false);
|
||||
void appendConfig(VfsConfig& conf);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
VFS_API bool initWriteProfile(vfs::CVirtualProfile &rProf);
|
||||
|
||||
VFS_API bool initVirtualFileSystem(vfs::Path const& vfs_ini);
|
||||
VFS_API bool initVirtualFileSystem(std::list<vfs::Path> const& vfs_ini_list);
|
||||
VFS_API bool initVirtualFileSystem(vfs::PropertyContainer& props);
|
||||
VFS_API bool initVirtualFileSystem(vfs_init::VfsConfig const& conf);
|
||||
};
|
||||
|
||||
#endif // _VFS_INIT_H_
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/os_functions.h
|
||||
* - abstractions for OS dependant code
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_OS_FUNCTIONS_H_
|
||||
#define _VFS_OS_FUNCTIONS_H_
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/dir.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <vfs/vfs_config.h>
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/vfs_path.h>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
namespace OS
|
||||
{
|
||||
class VFS_API CIterateDirectory
|
||||
{
|
||||
public:
|
||||
enum EFileAttribute
|
||||
{
|
||||
FA_DIRECTORY,
|
||||
FA_FILE
|
||||
};
|
||||
public:
|
||||
CIterateDirectory(vfs::Path const& sPath, vfs::String const& searchPattern);
|
||||
~CIterateDirectory();
|
||||
|
||||
bool nextFile(vfs::String &fileName, CIterateDirectory::EFileAttribute &attrib);
|
||||
private:
|
||||
#ifdef WIN32
|
||||
HANDLE fSearchHandle;
|
||||
union
|
||||
{
|
||||
WIN32_FIND_DATAA fFileInfoA;
|
||||
WIN32_FIND_DATAW fFileInfoW;
|
||||
};
|
||||
#else
|
||||
struct direct **files;
|
||||
int count, current_pos;
|
||||
#endif
|
||||
bool fFirstRequest;
|
||||
};
|
||||
|
||||
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,
|
||||
};
|
||||
bool getFileAttributes(vfs::Path const& sDir, vfs::UInt32& uiAttribs);
|
||||
};
|
||||
|
||||
|
||||
VFS_API bool checkRealDirectory(vfs::Path const& sDir);
|
||||
VFS_API bool createRealDirectory(vfs::Path const& sDir);
|
||||
|
||||
VFS_API bool deleteRealFile(vfs::Path const& sDir);
|
||||
|
||||
VFS_API void getExecutablePath(vfs::Path& sDir, vfs::Path& sFile);
|
||||
VFS_API void getCurrentDirectory(vfs::Path& sDir);
|
||||
VFS_API void setCurrectDirectory(vfs::Path const& sPath);
|
||||
|
||||
VFS_API bool getEnv(vfs::String const& key, vfs::String& value);
|
||||
}; // end namespace OS
|
||||
|
||||
} // end namespace vfs
|
||||
|
||||
#endif // _VFS_OS_FUNCTIONS_H_
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_path.h
|
||||
* - Path class, stores and validates a file/directory path string, offers meaningful path operations
|
||||
* - path comparison functions (operator overloading)
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_PATH_H_
|
||||
#define _VFS_PATH_H_
|
||||
|
||||
#include <vfs/vfs_config.h>
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API Path
|
||||
{
|
||||
public:
|
||||
class VFS_API Less{
|
||||
public:
|
||||
bool operator()(vfs::Path const& s1, vfs::Path const& s2) const;
|
||||
};
|
||||
class Equal{
|
||||
public:
|
||||
bool operator()(vfs::Path const& s1, vfs::Path const& s2) const;
|
||||
};
|
||||
public:
|
||||
Path();
|
||||
Path(const char* sPath);
|
||||
Path(std::string const& sPath);
|
||||
Path(const wchar_t* sPath);
|
||||
Path(vfs::String const& sPath);
|
||||
|
||||
const vfs::String::char_t* c_str() const;
|
||||
const vfs::String::str_t& c_wcs() const;
|
||||
const vfs::String::str_t& operator()() const;
|
||||
|
||||
std::string to_string() const;
|
||||
|
||||
Path& operator+=(Path const& p);
|
||||
Path& operator+=(vfs::String const& p);
|
||||
|
||||
bool empty() const;
|
||||
|
||||
vfs::String::size_t length() const;
|
||||
|
||||
void doCheck();
|
||||
bool expandEnv();
|
||||
|
||||
void splitLast(vfs::Path &rsHead, vfs::Path &rsLast) const;
|
||||
void splitFirst(vfs::Path &rsFirst, vfs::Path &rsTail) const;
|
||||
|
||||
bool extension(vfs::String &sExt) const;
|
||||
|
||||
bool operator==(vfs::Path const& p2);
|
||||
private:
|
||||
vfs::String::str_t _path;
|
||||
struct SeparatorPosition
|
||||
{
|
||||
SeparatorPosition() : first(vfs::npos), last(vfs::npos) {}
|
||||
vfs::size_t first, last;
|
||||
} _sep;
|
||||
};
|
||||
}
|
||||
|
||||
template<>
|
||||
VFS_API BuildString& BuildString::add<vfs::Path>(vfs::Path const& value);
|
||||
template<>
|
||||
VFS_API BuildString& BuildString::operator<< <vfs::Path>(vfs::Path const& value);
|
||||
|
||||
// add only valid Path objects
|
||||
VFS_API vfs::Path operator+(vfs::Path const& p1, vfs::Path const& p2);
|
||||
|
||||
VFS_API bool operator==(vfs::Path const& p1, vfs::Path const& p2);
|
||||
// compare path with string (that can be an invalid path)
|
||||
// use with care as these strings can be different from the internal representation although they seem to be equal
|
||||
VFS_API bool operator==(vfs::Path const& p1, vfs::String const& p2);
|
||||
VFS_API bool operator==(vfs::Path const& p1, vfs::String::str_t const& p2);
|
||||
VFS_API bool operator==(vfs::Path const& p1, const vfs::String::char_t* p2);
|
||||
|
||||
#endif // _VFS_PATH_H_
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_profile.h
|
||||
* - Virtual Profile, container for real file system locations or archives
|
||||
* - Profile Stack, orders profiles in a linear fashion (top-bottom)
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_PROFILE_H_
|
||||
#define _VFS_PROFILE_H_
|
||||
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/Interface/vfs_location_interface.h>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API CVirtualProfile
|
||||
{
|
||||
typedef std::map<vfs::Path,vfs::IBaseLocation*, vfs::Path::Less> tLocations;
|
||||
typedef std::set<vfs::IBaseLocation*> tUniqueLoc;
|
||||
|
||||
class IterImpl;
|
||||
class FileIterImpl;
|
||||
public:
|
||||
typedef TIterator<vfs::IBaseLocation> Iterator;
|
||||
typedef TIterator<vfs::IBaseFile> FileIterator;
|
||||
|
||||
CVirtualProfile(vfs::String const& profile_name, vfs::Path profile_root, bool writable = false);
|
||||
~CVirtualProfile();
|
||||
|
||||
const vfs::String cName;
|
||||
const vfs::Path cRoot;
|
||||
const bool cWritable;
|
||||
|
||||
Iterator begin();
|
||||
FileIterator files(vfs::Path const& sPattern);
|
||||
|
||||
void addLocation(vfs::IBaseLocation* pLoc);
|
||||
vfs::IBaseLocation* getLocation(vfs::Path const& sPath) const;
|
||||
vfs::IBaseFile* getFile(vfs::Path const& sPath) const;
|
||||
private:
|
||||
void operator=(vfs::CVirtualProfile const& vprof);
|
||||
tLocations m_mapLocations;
|
||||
tUniqueLoc m_setLocations;
|
||||
};
|
||||
|
||||
class VFS_API CProfileStack
|
||||
{
|
||||
class IterImpl;
|
||||
public:
|
||||
typedef vfs::TIterator<CVirtualProfile> Iterator;
|
||||
|
||||
CProfileStack();
|
||||
~CProfileStack();
|
||||
|
||||
CVirtualProfile* getWriteProfile();
|
||||
CVirtualProfile* getProfile(vfs::String const& sName) const;
|
||||
|
||||
CVirtualProfile* topProfile() const;
|
||||
/**
|
||||
* All files from the top profile will be removed from the VFS and the profile object will be deleted.
|
||||
*/
|
||||
bool popProfile();
|
||||
void pushProfile(CVirtualProfile* pProfile);
|
||||
|
||||
Iterator begin();
|
||||
private:
|
||||
typedef std::list<vfs::CVirtualProfile*> t_profiles;
|
||||
t_profiles m_profiles;
|
||||
};
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_string.h
|
||||
* - string class that allows conversions to/from Unicode representation (uses wchar_t internally)
|
||||
* - comparison, concatenation, stream output class/functions
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_STRING_H_
|
||||
#define _VFS_STRING_H_
|
||||
|
||||
#include <vfs/vfs_config.h>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
// simple UTF8 wrapper, uses utf8 implementation from http://utfcpp.sourceforge.net/
|
||||
class VFS_API String
|
||||
{
|
||||
friend VFS_API bool operator<(vfs::String const& s1, vfs::String const& s2);
|
||||
public:
|
||||
typedef std::wstring str_t;
|
||||
typedef str_t::value_type char_t;
|
||||
typedef str_t::value_type* ptr_t;
|
||||
|
||||
typedef str_t::size_type size_t;
|
||||
////////////////////////////////////////////////////////////////////
|
||||
static bool less(const vfs::String::char_t* s1, const vfs::String::char_t* s2);
|
||||
static bool equal(const vfs::String::char_t* s1, const vfs::String::char_t* s2);
|
||||
// case sensitive
|
||||
static bool lessCase(const vfs::String::char_t* s1, const vfs::String::char_t* s2);
|
||||
static bool equalCase(const vfs::String::char_t* s1, const vfs::String::char_t* s2);
|
||||
|
||||
template<bool (*funName)(const vfs::String::char_t* s1, const vfs::String::char_t* s2)>
|
||||
class Op{
|
||||
public:
|
||||
bool operator()(const vfs::String& s1, const vfs::String& s2) const
|
||||
{
|
||||
return funName(s1.c_str(),s2.c_str());
|
||||
}
|
||||
};
|
||||
typedef Op<vfs::String::less> Less;
|
||||
typedef Op<vfs::String::lessCase> LessCase;
|
||||
typedef Op<vfs::String::equal> Equal;
|
||||
typedef Op<vfs::String::equalCase> EqualCase;
|
||||
public:
|
||||
String();
|
||||
String(const char* str);
|
||||
String(std::string const& str);
|
||||
String(const wchar_t* str);
|
||||
String(std::wstring const& str);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
static vfs::String::str_t as_utf16(const char* str);
|
||||
static void as_utf16(const char* str, vfs::String::str_t &str16);
|
||||
static vfs::String::str_t as_utf16(std::string const& str);
|
||||
static void as_utf16(std::string const& str, vfs::String::str_t &str16);
|
||||
// fast conversion without creating an internal copy
|
||||
static std::string as_utf8(vfs::String const& str);
|
||||
static std::string as_utf8(std::wstring const& str);
|
||||
// if 'strlen' is 0, length is determined automatically
|
||||
static std::string as_utf8(const wchar_t* str, vfs::String::size_t strlength=0);
|
||||
//
|
||||
static std::string narrow(wchar_t const* str, vfs::String::size_t length);
|
||||
static vfs::String::size_t narrow(wchar_t const* src_str, vfs::String::size_t src_len, char* dst_str, vfs::String::size_t dst_len);
|
||||
static vfs::String::size_t narrow(std::wstring const& src, std::string& dst);
|
||||
//
|
||||
static std::wstring widen(char const* str, vfs::String::size_t length);
|
||||
static vfs::String::size_t widen(char const* src_str, vfs::String::size_t src_len, wchar_t* dst_str, vfs::String::size_t dst_len);
|
||||
static vfs::String::size_t widen(std::string const& src, std::wstring& dst);
|
||||
|
||||
// convenience method, for the case it should be used in generic code (overloading)
|
||||
static std::string as_utf8(std::string const& str);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// convert string to UTF8 encoding
|
||||
inline std::string utf8() const { return as_utf8(_str); }
|
||||
|
||||
// returns const reference to copy or compare string
|
||||
inline std::wstring const& c_wcs() const { return _str; }
|
||||
|
||||
inline const wchar_t* c_str() const { return _str.c_str(); }
|
||||
|
||||
// returns reference to modify string
|
||||
inline std::wstring& r_wcs() { return _str; }
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
bool empty() const;
|
||||
vfs::String::size_t length() const;
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
vfs::String operator+(vfs::String const& str);
|
||||
vfs::String operator+=(vfs::String const& str);
|
||||
private:
|
||||
str_t _str;
|
||||
};
|
||||
|
||||
} // namespace vfs
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
VFS_API bool operator<(vfs::String const& s1, vfs::String const& s2);
|
||||
}
|
||||
|
||||
VFS_API std::wostream& operator<<(std::wostream& out, vfs::String const& str);
|
||||
VFS_API std::wostream& operator<<(std::wostream& out, vfs::String::str_t const& str);
|
||||
VFS_API std::wostream& operator<<(std::wostream& out, const vfs::String::char_t* str);
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
// explicit compare
|
||||
namespace StrCmp
|
||||
{
|
||||
// case IN-sensitive
|
||||
VFS_API bool Equal(const char* s1, const char* s2);
|
||||
VFS_API bool Equal(std::string const& s1, std::string const& s2);
|
||||
VFS_API bool Equal(std::string const& s1, const char* s2);
|
||||
VFS_API bool Equal(const char* s1, std::string const& s2);
|
||||
//
|
||||
VFS_API bool Equal(const wchar_t* s1, const wchar_t* s2);
|
||||
VFS_API bool Equal(std::wstring const& s1, std::wstring const& s2);
|
||||
VFS_API bool Equal(std::wstring const& s1, const wchar_t* s2);
|
||||
VFS_API bool Equal(const wchar_t* s1, std::wstring const& s2);
|
||||
//
|
||||
VFS_API bool Equal(vfs::String const& s1, vfs::String const& s2);
|
||||
VFS_API bool Equal(vfs::String const& s1, std::wstring const& s2);
|
||||
VFS_API bool Equal(std::wstring const& s1, vfs::String const& s2);
|
||||
VFS_API bool Equal(vfs::String const& s1, const wchar_t* s2);
|
||||
VFS_API bool Equal(const wchar_t* s1, vfs::String const& s2);
|
||||
// case Sensitive
|
||||
VFS_API bool EqualCase(const char* s1, const char* s2);
|
||||
VFS_API bool EqualCase(std::string const& s1, std::string const& s2);
|
||||
VFS_API bool EqualCase(std::string const& s1, const char* s2);
|
||||
VFS_API bool EqualCase(const char* s1, std::string const& s2);
|
||||
//
|
||||
VFS_API bool EqualCase(const wchar_t* s1, const wchar_t* s2);
|
||||
VFS_API bool EqualCase(std::wstring const& s1, std::wstring const& s2);
|
||||
VFS_API bool EqualCase(std::wstring const& s1, const wchar_t* s2);
|
||||
VFS_API bool EqualCase(const wchar_t* s1, std::wstring const& s2);
|
||||
//
|
||||
VFS_API bool EqualCase(vfs::String const& s1, vfs::String const& s2);
|
||||
VFS_API bool EqualCase(vfs::String const& s1, std::wstring const& s2);
|
||||
VFS_API bool EqualCase(std::wstring const& s1, vfs::String const& s2);
|
||||
VFS_API bool EqualCase(vfs::String const& s1, const wchar_t* s2);
|
||||
VFS_API bool EqualCase(const wchar_t* s1, vfs::String const& s2);
|
||||
}
|
||||
|
||||
} // namespace vfs
|
||||
|
||||
class VFS_API BuildString
|
||||
{
|
||||
public:
|
||||
enum _cget{cget};
|
||||
enum _wget{wget};
|
||||
BuildString()
|
||||
{}
|
||||
|
||||
std::string operator<<(_cget)
|
||||
{
|
||||
return vfs::String::as_utf8(_strstr.str());
|
||||
}
|
||||
std::wstring operator<<(_wget)
|
||||
{
|
||||
return _strstr.str();
|
||||
}
|
||||
|
||||
BuildString(BuildString const& bs)
|
||||
{
|
||||
_strstr.str(bs._strstr.str());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
BuildString(T const& t)
|
||||
{
|
||||
add(t);
|
||||
}
|
||||
template<typename T>
|
||||
BuildString& add(T const& value)
|
||||
{
|
||||
_strstr << value;
|
||||
return *this;
|
||||
}
|
||||
template<typename T>
|
||||
BuildString& operator<<(T const& value)
|
||||
{
|
||||
_strstr << value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
vfs::String::str_t get()
|
||||
{
|
||||
return _strstr.str();
|
||||
}
|
||||
private:
|
||||
std::basic_stringstream<vfs::String::char_t> _strstr;
|
||||
};
|
||||
|
||||
typedef BuildString _BS;
|
||||
|
||||
template<>
|
||||
VFS_API BuildString& BuildString::add<vfs::String>(vfs::String const& value);
|
||||
template<>
|
||||
VFS_API BuildString& BuildString::add<std::string>(std::string const& value);
|
||||
template<>
|
||||
VFS_API BuildString& BuildString::add<const char*>(const char* const& value);
|
||||
|
||||
template<>
|
||||
VFS_API BuildString& BuildString::operator<< <vfs::String>(vfs::String const& value);
|
||||
template<>
|
||||
VFS_API BuildString& BuildString::operator<< <std::string>(std::string const& value);
|
||||
template<>
|
||||
VFS_API BuildString& BuildString::operator<< <const char*>(const char* const& value);
|
||||
|
||||
|
||||
#endif // _VFS_STRING_H_
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_types.h
|
||||
* - basic integer types, "incomplete" list of useful constant strings
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_TYPES_H_
|
||||
#define _VFS_TYPES_H_
|
||||
|
||||
#include <vfs/Core/vfs_string.h>
|
||||
|
||||
#ifdef __linux__
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
#ifdef WIN32
|
||||
typedef unsigned __int64 UInt64;
|
||||
typedef unsigned __int32 UInt32;
|
||||
typedef unsigned __int16 UInt16;
|
||||
typedef unsigned __int8 UInt8;
|
||||
typedef unsigned __int8 UByte;
|
||||
|
||||
typedef __int64 Int64;
|
||||
typedef __int32 Int32;
|
||||
typedef __int16 Int16;
|
||||
typedef __int8 Int8;
|
||||
typedef __int8 Byte;
|
||||
#elif __linux__
|
||||
typedef uint64_t UInt64;
|
||||
typedef uint32_t UInt32;
|
||||
typedef uint16_t UInt16;
|
||||
typedef uint8_t UInt8;
|
||||
typedef uint8_t UByte;
|
||||
|
||||
typedef int64_t Int64;
|
||||
typedef int32_t Int32;
|
||||
typedef int16_t Int16;
|
||||
typedef int8_t Int8;
|
||||
typedef char Byte;
|
||||
#endif
|
||||
|
||||
typedef ::size_t size_t;
|
||||
typedef ::off_t offset_t;
|
||||
|
||||
extern const vfs::size_t npos;
|
||||
}
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
namespace Const
|
||||
{
|
||||
inline const vfs::String::str_t EMPTY() { return L""; };
|
||||
//inline const vfs::String::char_t EMPTY_CHAR() { return L''; };
|
||||
|
||||
inline const vfs::String::str_t DOT() { return L"."; };
|
||||
inline const vfs::String::char_t DOT_CHAR() { return L'.'; };
|
||||
|
||||
inline const vfs::String::str_t DOTDOT() { return L".."; };
|
||||
inline const vfs::String::str_t DOTSVN() { return L".svn"; };
|
||||
|
||||
inline const vfs::String::str_t STAR() { return L"*"; };
|
||||
inline const vfs::String::str_t DSTAR() { return L"**"; };
|
||||
|
||||
#ifdef WIN32
|
||||
inline const vfs::String::str_t SEPARATOR() { return L"\\"; };
|
||||
inline const vfs::String::char_t SEPARATOR_CHAR() { return L'\\'; };
|
||||
#else
|
||||
inline const vfs::String::str_t SEPARATOR() { return L"/"; };
|
||||
inline const vfs::String::char_t SEPARATOR_CHAR() { return L'/'; };
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _VFS_TYPES_H_
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_vfile.h
|
||||
* - Virtual File, handles access to files from different VFS profiles
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_VFILE_H_
|
||||
#define _VFS_VFILE_H_
|
||||
|
||||
#include <vfs/Core/vfs_profile.h>
|
||||
#include <vfs/Tools/vfs_allocator.h>
|
||||
#include <vector>
|
||||
|
||||
#define VFILE_BLOCK_CREATE
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class VFS_API CVirtualFile
|
||||
{
|
||||
public:
|
||||
enum ESearchFile
|
||||
{
|
||||
SF_TOP,
|
||||
SF_FIRST_WRITABLE,
|
||||
SF_STOP_ON_WRITABLE_PROFILE,
|
||||
};
|
||||
public:
|
||||
CVirtualFile();
|
||||
~CVirtualFile();
|
||||
void destroy();
|
||||
static CVirtualFile* create(vfs::Path const& sFilePath, vfs::CProfileStack& rPStack);
|
||||
|
||||
vfs::Path const& path();
|
||||
void add(vfs::IBaseFile *pFile, vfs::String sProfileName, bool bReplace = false);
|
||||
bool remove(vfs::IBaseFile *pFile);
|
||||
//////////////////////////////////////////////////
|
||||
vfs::IBaseFile* file(ESearchFile eSearch);
|
||||
vfs::IBaseFile* file(vfs::String const& sProfileName);
|
||||
//////////////////////////////////////////////////
|
||||
private:
|
||||
vfs::Path _path;
|
||||
vfs::String _top_pname;
|
||||
vfs::IBaseFile* _top_file;
|
||||
CProfileStack* _pstack;
|
||||
private:
|
||||
vfs::UInt32 _myID;
|
||||
#ifdef VFILE_BLOCK_CREATE
|
||||
static ObjBlockAllocator<vfs::CVirtualFile>* _vfile_pool;
|
||||
#endif
|
||||
};
|
||||
} // end namspace
|
||||
|
||||
#endif // _VFS_VFILE_H_
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* bfVFS : vfs/Core/vfs_vloc.h
|
||||
* - Virtual Location, stores Virtual Files
|
||||
*
|
||||
* Copyright (C) 2008 - 2010 (BF) john.bf.smith@googlemail.com
|
||||
*
|
||||
* This file is part of the bfVFS library
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _VFS_VLOC_H_
|
||||
#define _VFS_VLOC_H_
|
||||
|
||||
#include <vfs/Core/vfs_types.h>
|
||||
#include <vfs/Core/Interface/vfs_file_interface.h>
|
||||
#include <vfs/Core/Interface/vfs_iterator_interface.h>
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace vfs
|
||||
{
|
||||
class CVirtualFile;
|
||||
|
||||
class VFS_API CVirtualLocation
|
||||
{
|
||||
class VFileIterator;
|
||||
typedef std::map<vfs::Path, CVirtualFile*, vfs::Path::Less> tVFiles;
|
||||
public:
|
||||
typedef vfs::TIterator<CVirtualFile> Iterator;
|
||||
|
||||
CVirtualLocation(vfs::Path const& sPath);
|
||||
~CVirtualLocation();
|
||||
|
||||
const vfs::Path cPath;
|
||||
|
||||
void setIsExclusive(bool exclusive);
|
||||
bool getIsExclusive();
|
||||
|
||||
void addFile(vfs::IBaseFile* pile, vfs::String const& profileName);
|
||||
vfs::IBaseFile* getFile(vfs::Path const& filename, vfs::String const& profileName = "") const;
|
||||
vfs::CVirtualFile* getVirtualFile(vfs::Path const& filename);
|
||||
|
||||
bool removeFile(vfs::IBaseFile* file);
|
||||
|
||||
Iterator iterate();
|
||||
private:
|
||||
void operator=(vfs::CVirtualLocation const& vloc);
|
||||
|
||||
bool m_exclusive;
|
||||
tVFiles m_VFiles;
|
||||
};
|
||||
} // end namespace
|
||||
|
||||
#endif // _VFS_VLOC_H_
|
||||
Reference in New Issue
Block a user