mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
** 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
179 lines
4.0 KiB
C++
179 lines
4.0 KiB
C++
#include "vfs_lib_dir.h"
|
|
#include "../Tools/Log.h"
|
|
|
|
class vfs::CLibDirectory::IterImpl : public vfs::IBaseLocation::Iterator::IImplementation
|
|
{
|
|
typedef vfs::IBaseLocation::Iterator::IImplementation tBaseClass;
|
|
public:
|
|
IterImpl(CLibDirectory& lib);
|
|
virtual ~IterImpl();
|
|
virtual vfs::CLibDirectory::tFileType* value();
|
|
virtual void next();
|
|
protected:
|
|
virtual tBaseClass* clone();
|
|
private:
|
|
void operator=(vfs::CLibDirectory::IterImpl const& iter);
|
|
|
|
vfs::CLibDirectory& _lib;
|
|
vfs::CLibDirectory::tFileCatalogue::iterator _iter;
|
|
};
|
|
|
|
vfs::CLibDirectory::IterImpl::IterImpl(CLibDirectory& lib)
|
|
: tBaseClass(), _lib(lib)
|
|
{
|
|
_iter = _lib.m_files.begin();
|
|
}
|
|
|
|
vfs::CLibDirectory::IterImpl::~IterImpl()
|
|
{
|
|
}
|
|
|
|
vfs::CLibDirectory::tFileType* vfs::CLibDirectory::IterImpl::value()
|
|
{
|
|
if(_iter != _lib.m_files.end())
|
|
{
|
|
return _iter->second;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void vfs::CLibDirectory::IterImpl::next()
|
|
{
|
|
if(_iter != _lib.m_files.end())
|
|
{
|
|
_iter++;
|
|
}
|
|
}
|
|
|
|
vfs::CLibDirectory::IterImpl::tBaseClass* vfs::CLibDirectory::IterImpl::clone()
|
|
{
|
|
IterImpl* iter = new IterImpl(_lib);
|
|
iter->_iter = _iter;
|
|
return iter;
|
|
}
|
|
|
|
/***************************************************************************/
|
|
/***************************************************************************/
|
|
|
|
vfs::CLibDirectory::CLibDirectory(vfs::Path const& sLocalPath, vfs::Path const& sRealPath)
|
|
: tBaseClass(sLocalPath,sRealPath)
|
|
{
|
|
}
|
|
|
|
vfs::CLibDirectory::~CLibDirectory()
|
|
{
|
|
tFileCatalogue::iterator it = m_files.begin();
|
|
for(; it != m_files.end(); ++it)
|
|
{
|
|
// don't delete objects here
|
|
//delete it->second;
|
|
}
|
|
m_files.clear();
|
|
}
|
|
|
|
vfs::CLibDirectory::tFileType* vfs::CLibDirectory::addFile(vfs::Path const& filename, bool deleteOldFile)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
bool vfs::CLibDirectory::addFile(tFileType* file, bool deleteOldFile)
|
|
{
|
|
if(!file)
|
|
{
|
|
return false;
|
|
}
|
|
vfs::Path const& name = file->getName();
|
|
tFileType* oldFile = m_files[name];
|
|
if(oldFile && (oldFile != file) )
|
|
{
|
|
if(deleteOldFile)
|
|
{
|
|
delete oldFile;
|
|
m_files[name] = file;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
m_files[name] = file;
|
|
return true;
|
|
}
|
|
|
|
bool vfs::CLibDirectory::deleteDirectory(vfs::Path const& dirPath)
|
|
{
|
|
//if( !(m_mountPoint == dirPath) )
|
|
//{
|
|
// return false;
|
|
//}
|
|
//if(implementsWritable())
|
|
//{
|
|
// tFileCatalogue::iterator it = m_files.begin();
|
|
// for(; it != m_files.end(); ++it)
|
|
// {
|
|
// //delete it->second;
|
|
// }
|
|
// m_files.clear();
|
|
// return true;
|
|
//}
|
|
CLog log(L"errors.log");
|
|
log << "called 'vfs::CLibDirectory::deleteDirectory' which doesn't implement the IWritable interface" << CLog::ENDL;
|
|
return false;
|
|
}
|
|
|
|
bool vfs::CLibDirectory::deleteFileFromDirectory(vfs::Path const& filename)
|
|
{
|
|
//if(implementsWritable())
|
|
//{
|
|
// tFileCatalogue::iterator it = m_files.find(filename);
|
|
// if(it != m_files.end())
|
|
// {
|
|
// delete it->second;
|
|
// m_files.erase(it);
|
|
// return true;
|
|
// }
|
|
//}
|
|
CLog log(L"errors.log");
|
|
log << "called 'vfs::CLibDirectory::deleteFileFromDirectory' which doesn't implement the IWritable interface" << CLog::ENDL;
|
|
return false;
|
|
}
|
|
|
|
bool vfs::CLibDirectory::fileExists(vfs::Path const& filename)
|
|
{
|
|
return (m_files[filename] != NULL);
|
|
}
|
|
|
|
vfs::IBaseFile* vfs::CLibDirectory::getFile(vfs::Path const& filename)
|
|
{
|
|
return getFileTyped(filename);
|
|
}
|
|
|
|
vfs::CLibDirectory::tFileType* vfs::CLibDirectory::getFileTyped(vfs::Path const& filename)
|
|
{
|
|
tFileCatalogue::iterator it = m_files.find(filename);
|
|
if(it != m_files.end())
|
|
{
|
|
return it->second;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
bool vfs::CLibDirectory::createSubDirectory(vfs::Path const& subDirPath)
|
|
{
|
|
// libraries are readonly
|
|
return false;
|
|
}
|
|
|
|
void vfs::CLibDirectory::getSubDirList(std::list<vfs::Path>& rlSubDirs)
|
|
{
|
|
// nothing
|
|
}
|
|
|
|
vfs::CLibDirectory::Iterator vfs::CLibDirectory::begin()
|
|
{
|
|
return Iterator(new IterImpl(*this));
|
|
}
|
|
|
|
/***************************************************************************/
|
|
/***************************************************************************/
|