1
0

Anvil storage writing (Basic storage is working, NO entities except for chests are working! Don't use for real servers)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@475 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com
2012-04-23 21:20:32 +00:00
parent 60b5f4b66b
commit 9cb8872851
11 changed files with 431 additions and 35 deletions

View File

@@ -69,7 +69,7 @@ bool cFile::Open(const AString & iFileName, EMode iMode)
{
case fmRead: Mode = "rb"; break;
case fmWrite: Mode = "wb"; break;
case fmReadWrite: Mode = "ab+"; break;
case fmReadWrite: Mode = "rb+"; break;
default:
{
ASSERT(!"Unhandled file mode");
@@ -77,6 +77,14 @@ bool cFile::Open(const AString & iFileName, EMode iMode)
}
}
m_File = fopen(iFileName.c_str(), Mode);
if ((m_File == NULL) && (iMode == fmReadWrite))
{
// Fix for MS not following C spec, opening "a" mode files for writing at the end only
// The file open operation has been tried with "read update", fails if file not found
// So now we know either the file doesn't exist or we don't have rights, no need to worry about file contents.
// Simply re-open for read-writing, erasing existing contents:
m_File = fopen(iFileName.c_str(), "wb+");
}
return (m_File != NULL);
}
@@ -251,3 +259,13 @@ int cFile::ReadRestOfFile(AString & a_Contents)
bool cFile::Exists(const AString & a_FileName)
{
cFile test(a_FileName, fmRead);
return test.IsOpen();
}