mirror of
https://github.com/1dot13/source.git
synced 2026-09-09 14:46:05 +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
This commit is contained in:
+38
-38
@@ -7,11 +7,17 @@
|
||||
|
||||
vfs::COpenReadFile::COpenReadFile(vfs::Path const& sPath, vfs::CVirtualFile::ESearchFile eSF)
|
||||
{
|
||||
vfs::IBaseFile *pFile = GetVFS()->GetFile(sPath,eSF);
|
||||
THROWIFFALSE(pFile, (L"file \"" + sPath().c_wcs() + L"\" does not exist").c_str());
|
||||
m_pFile = vfs::tReadableFile::Cast(pFile);
|
||||
THROWIFFALSE(m_pFile, L"not readable");
|
||||
THROWIFFALSE(m_pFile->OpenRead(), L"open read failed");
|
||||
vfs::IBaseFile *pFile = getVFS()->getFile(sPath,eSF);
|
||||
THROWIFFALSE(pFile,
|
||||
BuildString().add(L"file \"").add(sPath).add(L"\" does not exist").get());
|
||||
|
||||
m_pFile = vfs::tReadableFile::cast(pFile);
|
||||
|
||||
THROWIFFALSE(m_pFile,
|
||||
BuildString().add(L"File \"").add(sPath).add(L"\" is not readable").get());
|
||||
|
||||
THROWIFFALSE(m_pFile->openRead(),
|
||||
BuildString().add(L"Could not open file : ").add(m_pFile->getPath()).get());
|
||||
}
|
||||
|
||||
vfs::COpenReadFile::COpenReadFile(vfs::tReadableFile *pFile)
|
||||
@@ -19,8 +25,11 @@ vfs::COpenReadFile::COpenReadFile(vfs::tReadableFile *pFile)
|
||||
try
|
||||
{
|
||||
m_pFile = pFile;
|
||||
THROWIFFALSE(m_pFile, L"no file");
|
||||
THROWIFFALSE(m_pFile->OpenRead(), L"not open");
|
||||
THROWIFFALSE(m_pFile,
|
||||
BuildString().add(L"Invalid file object").get());
|
||||
|
||||
THROWIFFALSE(m_pFile->openRead(),
|
||||
BuildString().add(L"Could not open file : ").add(pFile->getPath()).get());
|
||||
}
|
||||
catch(CBasicException &ex)
|
||||
{
|
||||
@@ -31,7 +40,7 @@ vfs::COpenReadFile::~COpenReadFile()
|
||||
{
|
||||
if(m_pFile)
|
||||
{
|
||||
m_pFile->Close();
|
||||
m_pFile->close();
|
||||
m_pFile = NULL;
|
||||
}
|
||||
}
|
||||
@@ -53,47 +62,38 @@ vfs::COpenWriteFile::COpenWriteFile(vfs::Path const& sPath,
|
||||
bool bTruncate,
|
||||
vfs::CVirtualFile::ESearchFile eSF)
|
||||
{
|
||||
vfs::IBaseFile *pFile = GetVFS()->GetFile(sPath,eSF);
|
||||
vfs::IBaseFile *pFile = getVFS()->getFile(sPath,eSF);
|
||||
if(!pFile && bCreate)
|
||||
{
|
||||
if(GetVFS()->CreateNewFile(sPath))
|
||||
if(getVFS()->createNewFile(sPath))
|
||||
{
|
||||
pFile = GetVFS()->GetFile(sPath,eSF);
|
||||
pFile = getVFS()->getFile(sPath,eSF);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstringstream wss;
|
||||
wss << L"Could not create VFS file \"" << sPath().c_wcs() << L"\"";
|
||||
THROWEXCEPTION(wss.str().c_str());
|
||||
THROWEXCEPTION(BuildString().add(L"Could not create VFS file \"").add(sPath).add(L"\"").get());
|
||||
}
|
||||
}
|
||||
if(!pFile)
|
||||
{
|
||||
std::wstringstream wss;
|
||||
wss << L"File \"" << sPath().c_wcs() << L"\" not found";
|
||||
THROWEXCEPTION(wss.str().c_str());
|
||||
}
|
||||
m_pFile = vfs::tWriteableFile::Cast(pFile);
|
||||
if(!m_pFile)
|
||||
{
|
||||
std::wstringstream wss;
|
||||
wss << L"File \"" << sPath().c_wcs() << L"\" exists, but is not writeable";
|
||||
THROWEXCEPTION(wss.str().c_str());
|
||||
}
|
||||
if(!m_pFile->OpenWrite(bCreate,bTruncate))
|
||||
{
|
||||
std::wstringstream wss;
|
||||
wss << L"File \"" << sPath().c_wcs() << L"\" could not be opened for writing";
|
||||
THROWEXCEPTION(wss.str().c_str());
|
||||
}
|
||||
THROWIFFALSE(pFile,
|
||||
BuildString().add(L"File \"").add(sPath).add(L"\" not found").get());
|
||||
|
||||
m_pFile = vfs::tWritableFile::cast(pFile);
|
||||
|
||||
THROWIFFALSE(m_pFile,
|
||||
BuildString().add(L"File \"").add(sPath).add(L"\" exists, but is not writable").get());
|
||||
|
||||
THROWIFFALSE(m_pFile->openWrite(bCreate,bTruncate),
|
||||
BuildString().add(L"File \"").add(sPath).add(L"\" could not be opened for writing").get());
|
||||
}
|
||||
vfs::COpenWriteFile::COpenWriteFile(vfs::tWriteableFile *pFile)
|
||||
vfs::COpenWriteFile::COpenWriteFile(vfs::tWritableFile *pFile)
|
||||
{
|
||||
try
|
||||
{
|
||||
m_pFile = pFile;
|
||||
THROWIFFALSE(m_pFile, L"no file");
|
||||
THROWIFFALSE(m_pFile->OpenWrite(true,false), (L"File not open : " + m_pFile->GetFullPath()().c_wcs()).c_str());
|
||||
THROWIFFALSE(m_pFile,
|
||||
BuildString().add(L"Invalid file object").get());
|
||||
THROWIFFALSE(m_pFile->openWrite(true,false),
|
||||
BuildString().add(L"Could not open file : ").add(m_pFile->getPath()).get());
|
||||
}
|
||||
catch(CBasicException& ex)
|
||||
{
|
||||
@@ -104,12 +104,12 @@ vfs::COpenWriteFile::~COpenWriteFile()
|
||||
{
|
||||
if(m_pFile)
|
||||
{
|
||||
m_pFile->Close();
|
||||
m_pFile->close();
|
||||
m_pFile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
vfs::tWriteableFile& vfs::COpenWriteFile::file()
|
||||
vfs::tWritableFile& vfs::COpenWriteFile::file()
|
||||
{
|
||||
return *m_pFile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user