aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/scriptables/SXFile.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2012-04-28 01:00:14 +0300
committerEinar Johan Trøan Sømåen2012-06-02 12:42:08 +0200
commit28c78b956dac6ee59d066f7ff2499569fe9877c7 (patch)
tree07e37e79e5610d3f21d22a8243083b78e09f8542 /engines/wintermute/scriptables/SXFile.cpp
parent84fd9d0daca1846829b077aa18a7634df5e5ef9e (diff)
downloadscummvm-rg350-28c78b956dac6ee59d066f7ff2499569fe9877c7.tar.gz
scummvm-rg350-28c78b956dac6ee59d066f7ff2499569fe9877c7.tar.bz2
scummvm-rg350-28c78b956dac6ee59d066f7ff2499569fe9877c7.zip
WINTERMUTE: Mass rename m_FooBar -> _fooBar
Diffstat (limited to 'engines/wintermute/scriptables/SXFile.cpp')
-rw-r--r--engines/wintermute/scriptables/SXFile.cpp236
1 files changed, 118 insertions, 118 deletions
diff --git a/engines/wintermute/scriptables/SXFile.cpp b/engines/wintermute/scriptables/SXFile.cpp
index 8e38e2608a..19b60043da 100644
--- a/engines/wintermute/scriptables/SXFile.cpp
+++ b/engines/wintermute/scriptables/SXFile.cpp
@@ -44,14 +44,14 @@ CSXFile::CSXFile(CBGame *inGame, CScStack *Stack): CBScriptable(inGame) {
Stack->CorrectParams(1);
CScValue *Val = Stack->Pop();
- m_Filename = NULL;
- if (!Val->IsNULL()) CBUtils::SetString(&m_Filename, Val->GetString());
+ _filename = NULL;
+ if (!Val->IsNULL()) CBUtils::SetString(&_filename, Val->GetString());
- m_ReadFile = NULL;
- m_WriteFile = NULL;
+ _readFile = NULL;
+ _writeFile = NULL;
- m_Mode = 0;
- m_TextMode = false;
+ _mode = 0;
+ _textMode = false;
}
@@ -62,29 +62,29 @@ CSXFile::~CSXFile() {
//////////////////////////////////////////////////////////////////////////
void CSXFile::Cleanup() {
- delete[] m_Filename;
- m_Filename = NULL;
+ delete[] _filename;
+ _filename = NULL;
Close();
}
//////////////////////////////////////////////////////////////////////////
void CSXFile::Close() {
- if (m_ReadFile) {
- Game->m_FileManager->CloseFile(m_ReadFile);
- m_ReadFile = NULL;
+ if (_readFile) {
+ Game->_fileManager->CloseFile(_readFile);
+ _readFile = NULL;
}
- if (m_WriteFile) {
- fclose(m_WriteFile);
- m_WriteFile = NULL;
+ if (_writeFile) {
+ fclose(_writeFile);
+ _writeFile = NULL;
}
- m_Mode = 0;
- m_TextMode = false;
+ _mode = 0;
+ _textMode = false;
}
//////////////////////////////////////////////////////////////////////////
char *CSXFile::ScToString() {
- if (m_Filename) return m_Filename;
+ if (_filename) return _filename;
else return "[file object]";
}
@@ -98,7 +98,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
char *Filename = Stack->Pop()->GetString();
Cleanup();
- CBUtils::SetString(&m_Filename, Filename);
+ CBUtils::SetString(&_filename, Filename);
Stack->PushNULL();
return S_OK;
}
@@ -109,33 +109,33 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
else if (strcmp(Name, "OpenAsText") == 0 || strcmp(Name, "OpenAsBinary") == 0) {
Stack->CorrectParams(1);
Close();
- m_Mode = Stack->Pop()->GetInt(1);
- if (m_Mode < 1 || m_Mode > 3) {
+ _mode = Stack->Pop()->GetInt(1);
+ if (_mode < 1 || _mode > 3) {
Script->RuntimeError("File.%s: invalid access mode. Setting read mode.", Name);
- m_Mode = 1;
+ _mode = 1;
}
- if (m_Mode == 1) {
- m_ReadFile = Game->m_FileManager->OpenFile(m_Filename);
- if (!m_ReadFile) {
- //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, m_Filename);
+ if (_mode == 1) {
+ _readFile = Game->_fileManager->OpenFile(_filename);
+ if (!_readFile) {
+ //Script->RuntimeError("File.%s: Error opening file '%s' for reading.", Name, _filename);
Close();
- } else m_TextMode = strcmp(Name, "OpenAsText") == 0;
+ } else _textMode = strcmp(Name, "OpenAsText") == 0;
} else {
if (strcmp(Name, "OpenAsText") == 0) {
- if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "w+");
- else m_WriteFile = fopen(m_Filename, "a+");
+ if (_mode == 2) _writeFile = fopen(_filename, "w+");
+ else _writeFile = fopen(_filename, "a+");
} else {
- if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "wb+");
- else m_WriteFile = fopen(m_Filename, "ab+");
+ if (_mode == 2) _writeFile = fopen(_filename, "wb+");
+ else _writeFile = fopen(_filename, "ab+");
}
- if (!m_WriteFile) {
- //Script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, m_Filename);
+ if (!_writeFile) {
+ //Script->RuntimeError("File.%s: Error opening file '%s' for writing.", Name, _filename);
Close();
- } else m_TextMode = strcmp(Name, "OpenAsText") == 0;
+ } else _textMode = strcmp(Name, "OpenAsText") == 0;
}
- if (m_ReadFile || m_WriteFile) Stack->PushBool(true);
+ if (_readFile || _writeFile) Stack->PushBool(true);
else Stack->PushBool(false);
return S_OK;
@@ -156,7 +156,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "SetPosition") == 0) {
Stack->CorrectParams(1);
- if (m_Mode == 0) {
+ if (_mode == 0) {
Script->RuntimeError("File.%s: File is not open", Name);
Stack->PushBool(false);
} else {
@@ -172,7 +172,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
else if (strcmp(Name, "Delete") == 0) {
Stack->CorrectParams(0);
Close();
- Stack->PushBool(CBPlatform::DeleteFile(m_Filename) != FALSE);
+ Stack->PushBool(CBPlatform::DeleteFile(_filename) != FALSE);
return S_OK;
}
@@ -185,7 +185,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
bool Overwrite = Stack->Pop()->GetBool(true);
Close();
- Stack->PushBool(CBPlatform::CopyFile(m_Filename, Dest, !Overwrite) != FALSE);
+ Stack->PushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != FALSE);
return S_OK;
}
@@ -194,7 +194,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "ReadLine") == 0) {
Stack->CorrectParams(0);
- if (!m_TextMode || !m_ReadFile) {
+ if (!_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open in text mode.", Name);
Stack->PushNULL();
return S_OK;
@@ -206,7 +206,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
bool FoundNewLine = false;
HRESULT Ret = E_FAIL;
do {
- Ret = m_ReadFile->Read(&b, 1);
+ Ret = _readFile->Read(&b, 1);
if (FAILED(Ret)) break;
if (Counter > BufSize) {
@@ -245,7 +245,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
int TextLen = Stack->Pop()->GetInt();
- if (!m_TextMode || !m_ReadFile) {
+ if (!_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open in text mode.", Name);
Stack->PushNULL();
return S_OK;
@@ -257,7 +257,7 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
HRESULT Ret = E_FAIL;
while (Counter < TextLen) {
- Ret = m_ReadFile->Read(&b, 1);
+ Ret = _readFile->Read(&b, 1);
if (FAILED(Ret)) break;
if (Counter > BufSize) {
@@ -291,15 +291,15 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
else if (strcmp(Name, "WriteLine") == 0 || strcmp(Name, "WriteText") == 0) {
Stack->CorrectParams(1);
char *Line = Stack->Pop()->GetString();
- if (!m_TextMode || !m_WriteFile) {
+ if (!_textMode || !_writeFile) {
Script->RuntimeError("File.%s: File must be open for writing in text mode.", Name);
Stack->PushBool(false);
return S_OK;
}
if (strcmp(Name, "WriteLine") == 0)
- fprintf(m_WriteFile, "%s\n", Line);
+ fprintf(_writeFile, "%s\n", Line);
else
- fprintf(m_WriteFile, "%s", Line);
+ fprintf(_writeFile, "%s", Line);
Stack->PushBool(true);
@@ -312,13 +312,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "ReadBool") == 0) {
Stack->CorrectParams(0);
- if (m_TextMode || !m_ReadFile) {
+ if (_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name);
Stack->PushNULL();
return S_OK;
}
bool Val;
- if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(bool)))) Stack->PushBool(Val);
+ if (SUCCEEDED(_readFile->Read(&Val, sizeof(bool)))) Stack->PushBool(Val);
else Stack->PushNULL();
return S_OK;
@@ -329,13 +329,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "ReadByte") == 0) {
Stack->CorrectParams(0);
- if (m_TextMode || !m_ReadFile) {
+ if (_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name);
Stack->PushNULL();
return S_OK;
}
byte Val;
- if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(byte )))) Stack->PushInt(Val);
+ if (SUCCEEDED(_readFile->Read(&Val, sizeof(byte )))) Stack->PushInt(Val);
else Stack->PushNULL();
return S_OK;
@@ -346,13 +346,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "ReadShort") == 0) {
Stack->CorrectParams(0);
- if (m_TextMode || !m_ReadFile) {
+ if (_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name);
Stack->PushNULL();
return S_OK;
}
short Val;
- if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(short)))) Stack->PushInt(65536 + Val);
+ if (SUCCEEDED(_readFile->Read(&Val, sizeof(short)))) Stack->PushInt(65536 + Val);
else Stack->PushNULL();
return S_OK;
@@ -363,13 +363,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "ReadInt") == 0 || strcmp(Name, "ReadLong") == 0) {
Stack->CorrectParams(0);
- if (m_TextMode || !m_ReadFile) {
+ if (_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name);
Stack->PushNULL();
return S_OK;
}
int Val;
- if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(int)))) Stack->PushInt(Val);
+ if (SUCCEEDED(_readFile->Read(&Val, sizeof(int)))) Stack->PushInt(Val);
else Stack->PushNULL();
return S_OK;
@@ -380,13 +380,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "ReadFloat") == 0) {
Stack->CorrectParams(0);
- if (m_TextMode || !m_ReadFile) {
+ if (_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name);
Stack->PushNULL();
return S_OK;
}
float Val;
- if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(float)))) Stack->PushFloat(Val);
+ if (SUCCEEDED(_readFile->Read(&Val, sizeof(float)))) Stack->PushFloat(Val);
else Stack->PushNULL();
return S_OK;
@@ -397,13 +397,13 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "ReadDouble") == 0) {
Stack->CorrectParams(0);
- if (m_TextMode || !m_ReadFile) {
+ if (_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name);
Stack->PushNULL();
return S_OK;
}
double Val;
- if (SUCCEEDED(m_ReadFile->Read(&Val, sizeof(double)))) Stack->PushFloat(Val);
+ if (SUCCEEDED(_readFile->Read(&Val, sizeof(double)))) Stack->PushFloat(Val);
else Stack->PushNULL();
return S_OK;
@@ -414,16 +414,16 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "ReadString") == 0) {
Stack->CorrectParams(0);
- if (m_TextMode || !m_ReadFile) {
+ if (_textMode || !_readFile) {
Script->RuntimeError("File.%s: File must be open for reading in binary mode.", Name);
Stack->PushNULL();
return S_OK;
}
uint32 Size;
- if (SUCCEEDED(m_ReadFile->Read(&Size, sizeof(uint32)))) {
+ if (SUCCEEDED(_readFile->Read(&Size, sizeof(uint32)))) {
byte *Str = new byte[Size + 1];
if (Str) {
- if (SUCCEEDED(m_ReadFile->Read(Str, Size))) {
+ if (SUCCEEDED(_readFile->Read(Str, Size))) {
Str[Size] = '\0';
Stack->PushString((char *)Str);
}
@@ -441,12 +441,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
bool Val = Stack->Pop()->GetBool();
- if (m_TextMode || !m_WriteFile) {
+ if (_textMode || !_writeFile) {
Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name);
Stack->PushBool(false);
return S_OK;
}
- fwrite(&Val, sizeof(Val), 1, m_WriteFile);
+ fwrite(&Val, sizeof(Val), 1, _writeFile);
Stack->PushBool(true);
return S_OK;
@@ -459,12 +459,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
byte Val = Stack->Pop()->GetInt();
- if (m_TextMode || !m_WriteFile) {
+ if (_textMode || !_writeFile) {
Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name);
Stack->PushBool(false);
return S_OK;
}
- fwrite(&Val, sizeof(Val), 1, m_WriteFile);
+ fwrite(&Val, sizeof(Val), 1, _writeFile);
Stack->PushBool(true);
return S_OK;
@@ -477,12 +477,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
short Val = Stack->Pop()->GetInt();
- if (m_TextMode || !m_WriteFile) {
+ if (_textMode || !_writeFile) {
Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name);
Stack->PushBool(false);
return S_OK;
}
- fwrite(&Val, sizeof(Val), 1, m_WriteFile);
+ fwrite(&Val, sizeof(Val), 1, _writeFile);
Stack->PushBool(true);
return S_OK;
@@ -495,12 +495,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
int Val = Stack->Pop()->GetInt();
- if (m_TextMode || !m_WriteFile) {
+ if (_textMode || !_writeFile) {
Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name);
Stack->PushBool(false);
return S_OK;
}
- fwrite(&Val, sizeof(Val), 1, m_WriteFile);
+ fwrite(&Val, sizeof(Val), 1, _writeFile);
Stack->PushBool(true);
return S_OK;
@@ -513,12 +513,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
float Val = Stack->Pop()->GetFloat();
- if (m_TextMode || !m_WriteFile) {
+ if (_textMode || !_writeFile) {
Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name);
Stack->PushBool(false);
return S_OK;
}
- fwrite(&Val, sizeof(Val), 1, m_WriteFile);
+ fwrite(&Val, sizeof(Val), 1, _writeFile);
Stack->PushBool(true);
return S_OK;
@@ -531,12 +531,12 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
double Val = Stack->Pop()->GetFloat();
- if (m_TextMode || !m_WriteFile) {
+ if (_textMode || !_writeFile) {
Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name);
Stack->PushBool(false);
return S_OK;
}
- fwrite(&Val, sizeof(Val), 1, m_WriteFile);
+ fwrite(&Val, sizeof(Val), 1, _writeFile);
Stack->PushBool(true);
return S_OK;
@@ -549,15 +549,15 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
Stack->CorrectParams(1);
char *Val = Stack->Pop()->GetString();
- if (m_TextMode || !m_WriteFile) {
+ if (_textMode || !_writeFile) {
Script->RuntimeError("File.%s: File must be open for writing in binary mode.", Name);
Stack->PushBool(false);
return S_OK;
}
uint32 Size = strlen(Val);
- fwrite(&Size, sizeof(Size), 1, m_WriteFile);
- fwrite(Val, Size, 1, m_WriteFile);
+ fwrite(&Size, sizeof(Size), 1, _writeFile);
+ fwrite(Val, Size, 1, _writeFile);
Stack->PushBool(true);
@@ -571,54 +571,54 @@ HRESULT CSXFile::ScCallMethod(CScScript *Script, CScStack *Stack, CScStack *This
//////////////////////////////////////////////////////////////////////////
CScValue *CSXFile::ScGetProperty(char *Name) {
- m_ScValue->SetNULL();
+ _scValue->SetNULL();
//////////////////////////////////////////////////////////////////////////
// Type (RO)
//////////////////////////////////////////////////////////////////////////
if (strcmp(Name, "Type") == 0) {
- m_ScValue->SetString("file");
- return m_ScValue;
+ _scValue->SetString("file");
+ return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// Filename (RO)
//////////////////////////////////////////////////////////////////////////
if (strcmp(Name, "Filename") == 0) {
- m_ScValue->SetString(m_Filename);
- return m_ScValue;
+ _scValue->SetString(_filename);
+ return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// Position (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "Position") == 0) {
- m_ScValue->SetInt(GetPos());
- return m_ScValue;
+ _scValue->SetInt(GetPos());
+ return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// Length (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "Length") == 0) {
- m_ScValue->SetInt(GetLength());
- return m_ScValue;
+ _scValue->SetInt(GetLength());
+ return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// TextMode (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "TextMode") == 0) {
- m_ScValue->SetBool(m_TextMode);
- return m_ScValue;
+ _scValue->SetBool(_textMode);
+ return _scValue;
}
//////////////////////////////////////////////////////////////////////////
// AccessMode (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(Name, "AccessMode") == 0) {
- m_ScValue->SetInt(m_Mode);
- return m_ScValue;
+ _scValue->SetInt(_mode);
+ return _scValue;
}
else return CBScriptable::ScGetProperty(Name);
@@ -632,14 +632,14 @@ HRESULT CSXFile::ScSetProperty(char *Name, CScValue *Value) {
// Length
//////////////////////////////////////////////////////////////////////////
if(strcmp(Name, "Length")==0){
- int OrigLength = m_Length;
- m_Length = max(Value->GetInt(0), 0);
+ int OrigLength = _length;
+ _length = max(Value->GetInt(0), 0);
char PropName[20];
- if(m_Length < OrigLength){
- for(int i=m_Length; i<OrigLength; i++){
+ if(_length < OrigLength){
+ for(int i=_length; i<OrigLength; i++){
sprintf(PropName, "%d", i);
- m_Values->DeleteProp(PropName);
+ _values->DeleteProp(PropName);
}
}
return S_OK;
@@ -649,26 +649,26 @@ HRESULT CSXFile::ScSetProperty(char *Name, CScValue *Value) {
//////////////////////////////////////////////////////////////////////////
uint32 CSXFile::GetPos() {
- if (m_Mode == 1 && m_ReadFile) return m_ReadFile->GetPos();
- else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) return ftell(m_WriteFile);
+ if (_mode == 1 && _readFile) return _readFile->GetPos();
+ else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell(_writeFile);
else return 0;
}
//////////////////////////////////////////////////////////////////////////
bool CSXFile::SetPos(uint32 Pos, TSeek Origin) {
- if (m_Mode == 1 && m_ReadFile) return SUCCEEDED(m_ReadFile->Seek(Pos, Origin));
- else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) return fseek(m_WriteFile, Pos, (int)Origin) == 0;
+ if (_mode == 1 && _readFile) return SUCCEEDED(_readFile->Seek(Pos, Origin));
+ else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek(_writeFile, Pos, (int)Origin) == 0;
else return false;
}
//////////////////////////////////////////////////////////////////////////
uint32 CSXFile::GetLength() {
- if (m_Mode == 1 && m_ReadFile) return m_ReadFile->GetSize();
- else if ((m_Mode == 2 || m_Mode == 3) && m_WriteFile) {
- uint32 CurrentPos = ftell(m_WriteFile);
- fseek(m_WriteFile, 0, SEEK_END);
- int Ret = ftell(m_WriteFile);
- fseek(m_WriteFile, CurrentPos, SEEK_SET);
+ if (_mode == 1 && _readFile) return _readFile->GetSize();
+ else if ((_mode == 2 || _mode == 3) && _writeFile) {
+ uint32 CurrentPos = ftell(_writeFile);
+ fseek(_writeFile, 0, SEEK_END);
+ int Ret = ftell(_writeFile);
+ fseek(_writeFile, CurrentPos, SEEK_SET);
return Ret;
} else return 0;
}
@@ -678,37 +678,37 @@ HRESULT CSXFile::Persist(CBPersistMgr *PersistMgr) {
CBScriptable::Persist(PersistMgr);
- PersistMgr->Transfer(TMEMBER(m_Filename));
- PersistMgr->Transfer(TMEMBER(m_Mode));
- PersistMgr->Transfer(TMEMBER(m_TextMode));
+ PersistMgr->Transfer(TMEMBER(_filename));
+ PersistMgr->Transfer(TMEMBER(_mode));
+ PersistMgr->Transfer(TMEMBER(_textMode));
uint32 Pos = 0;
- if (PersistMgr->m_Saving) {
+ if (PersistMgr->_saving) {
Pos = GetPos();
PersistMgr->Transfer(TMEMBER(Pos));
} else {
PersistMgr->Transfer(TMEMBER(Pos));
// try to re-open file if needed
- m_WriteFile = NULL;
- m_ReadFile = NULL;
+ _writeFile = NULL;
+ _readFile = NULL;
- if (m_Mode != 0) {
+ if (_mode != 0) {
// open for reading
- if (m_Mode == 1) {
- m_ReadFile = Game->m_FileManager->OpenFile(m_Filename);
- if (!m_ReadFile) Close();
+ if (_mode == 1) {
+ _readFile = Game->_fileManager->OpenFile(_filename);
+ if (!_readFile) Close();
}
// open for writing / appending
else {
- if (m_TextMode) {
- if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "w+");
- else m_WriteFile = fopen(m_Filename, "a+");
+ if (_textMode) {
+ if (_mode == 2) _writeFile = fopen(_filename, "w+");
+ else _writeFile = fopen(_filename, "a+");
} else {
- if (m_Mode == 2) m_WriteFile = fopen(m_Filename, "wb+");
- else m_WriteFile = fopen(m_Filename, "ab+");
+ if (_mode == 2) _writeFile = fopen(_filename, "wb+");
+ else _writeFile = fopen(_filename, "ab+");
}
- if (m_WriteFile) Close();
+ if (_writeFile) Close();
}
SetPos(Pos);
}