aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-07-09 00:33:13 +0200
committerEinar Johan Trøan Sømåen2012-07-09 00:33:13 +0200
commit11d3bbceb0748229f4b4839ca7f89348953aa680 (patch)
tree17d0fe07ed81f2399960b7190ed54cecac11edba
parent9c4b8f88f9360217617ab7960d79d5eaf60f7d25 (diff)
downloadscummvm-rg350-11d3bbceb0748229f4b4839ca7f89348953aa680.tar.gz
scummvm-rg350-11d3bbceb0748229f4b4839ca7f89348953aa680.tar.bz2
scummvm-rg350-11d3bbceb0748229f4b4839ca7f89348953aa680.zip
WINTERMUTE: Rename FuncName/VarName->funcName/varName in SXFile
-rw-r--r--engines/wintermute/Base/scriptables/SXFile.cpp227
-rw-r--r--engines/wintermute/Base/scriptables/SXFile.h8
2 files changed, 122 insertions, 113 deletions
diff --git a/engines/wintermute/Base/scriptables/SXFile.cpp b/engines/wintermute/Base/scriptables/SXFile.cpp
index 34d133e330..b29c82853b 100644
--- a/engines/wintermute/Base/scriptables/SXFile.cpp
+++ b/engines/wintermute/Base/scriptables/SXFile.cpp
@@ -79,12 +79,12 @@ CSXFile::~CSXFile() {
void CSXFile::cleanup() {
delete[] _filename;
_filename = NULL;
- Close();
+ close();
}
//////////////////////////////////////////////////////////////////////////
-void CSXFile::Close() {
+void CSXFile::close() {
if (_readFile) {
Game->_fileManager->closeFile(_readFile);
_readFile = NULL;
@@ -123,7 +123,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) {
stack->correctParams(1);
- Close();
+ close();
_mode = stack->pop()->getInt(1);
if (_mode < 1 || _mode > 3) {
script->runtimeError("File.%s: invalid access mode. Setting read mode.", name);
@@ -133,7 +133,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
_readFile = Game->_fileManager->openFile(_filename);
if (!_readFile) {
//script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename);
- Close();
+ close();
} else _textMode = strcmp(name, "OpenAsText") == 0;
} else {
if (strcmp(name, "OpenAsText") == 0) {
@@ -146,7 +146,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
if (!_writeFile) {
//script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename);
- Close();
+ close();
} else _textMode = strcmp(name, "OpenAsText") == 0;
}
@@ -161,7 +161,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Close") == 0) {
stack->correctParams(0);
- Close();
+ close();
stack->pushNULL();
return S_OK;
}
@@ -176,7 +176,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushBool(false);
} else {
int Pos = stack->pop()->getInt();
- stack->pushBool(SetPos(Pos));
+ stack->pushBool(setPos(Pos));
}
return S_OK;
}
@@ -186,7 +186,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Delete") == 0) {
stack->correctParams(0);
- Close();
+ close();
stack->pushBool(CBPlatform::DeleteFile(_filename) != false);
return S_OK;
}
@@ -199,7 +199,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
const char *Dest = stack->pop()->getString();
bool Overwrite = stack->pop()->getBool(true);
- Close();
+ close();
stack->pushBool(CBPlatform::CopyFile(_filename, Dest, !Overwrite) != false);
return S_OK;
}
@@ -214,41 +214,41 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushNULL();
return S_OK;
}
- uint32 BufSize = FILE_BUFFER_SIZE;
- byte *Buf = (byte *)malloc(BufSize);
- uint32 Counter = 0;
+ uint32 bufSize = FILE_BUFFER_SIZE;
+ byte *buf = (byte *)malloc(bufSize);
+ uint32 counter = 0;
byte b;
- bool FoundNewLine = false;
- HRESULT Ret = E_FAIL;
+ bool foundNewLine = false;
+ HRESULT ret = E_FAIL;
do {
- Ret = _readFile->read(&b, 1);
- if (Ret != 1) break;
+ ret = _readFile->read(&b, 1);
+ if (ret != 1) break;
- if (Counter > BufSize) {
- Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE);
- BufSize += FILE_BUFFER_SIZE;
+ if (counter > bufSize) {
+ buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE);
+ bufSize += FILE_BUFFER_SIZE;
}
if (b == '\n') {
- Buf[Counter] = '\0';
- FoundNewLine = true;
+ buf[counter] = '\0';
+ foundNewLine = true;
break;
} else if (b == 0x0D) continue;
else {
- Buf[Counter] = b;
- Counter++;
+ buf[counter] = b;
+ counter++;
}
- } while (SUCCEEDED(Ret));
+ } while (SUCCEEDED(ret));
- if (Counter > BufSize) {
- Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE);
- BufSize += FILE_BUFFER_SIZE;
+ if (counter > bufSize) {
+ buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE);
+ bufSize += FILE_BUFFER_SIZE;
}
- Buf[Counter] = '\0';
+ buf[counter] = '\0';
- if (!FoundNewLine && Counter == 0) stack->pushNULL();
- else stack->pushString((char *)Buf);
+ if (!foundNewLine && counter == 0) stack->pushNULL();
+ else stack->pushString((char *)buf);
- free(Buf);
+ free(buf);
return S_OK;
}
@@ -258,44 +258,44 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "ReadText") == 0) {
stack->correctParams(1);
- int TextLen = stack->pop()->getInt();
+ int textLen = stack->pop()->getInt();
if (!_textMode || !_readFile) {
script->runtimeError("File.%s: File must be open in text mode.", name);
stack->pushNULL();
return S_OK;
}
- uint32 BufSize = FILE_BUFFER_SIZE;
- byte *Buf = (byte *)malloc(BufSize);
- uint32 Counter = 0;
+ uint32 bufSize = FILE_BUFFER_SIZE;
+ byte *buf = (byte *)malloc(bufSize);
+ uint32 counter = 0;
byte b;
- HRESULT Ret = E_FAIL;
- while (Counter < TextLen) {
- Ret = _readFile->read(&b, 1);
- if (Ret != 1) break;
+ HRESULT ret = E_FAIL;
+ while (counter < textLen) {
+ ret = _readFile->read(&b, 1);
+ if (ret != 1) break;
- if (Counter > BufSize) {
- Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE);
- BufSize += FILE_BUFFER_SIZE;
+ if (counter > bufSize) {
+ buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE);
+ bufSize += FILE_BUFFER_SIZE;
}
if (b == 0x0D) continue;
else {
- Buf[Counter] = b;
- Counter++;
+ buf[counter] = b;
+ counter++;
}
}
- if (Counter > BufSize) {
- Buf = (byte *)realloc(Buf, BufSize + FILE_BUFFER_SIZE);
- BufSize += FILE_BUFFER_SIZE;
+ if (counter > bufSize) {
+ buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE);
+ bufSize += FILE_BUFFER_SIZE;
}
- Buf[Counter] = '\0';
+ buf[counter] = '\0';
- if (TextLen > 0 && Counter == 0) stack->pushNULL();
- else stack->pushString((char *)Buf);
+ if (textLen > 0 && counter == 0) stack->pushNULL();
+ else stack->pushString((char *)buf);
- free(Buf);
+ free(buf);
return S_OK;
}
@@ -305,16 +305,16 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) {
stack->correctParams(1);
- const char *Line = stack->pop()->getString();
+ const char *line = stack->pop()->getString();
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((FILE *)_writeFile, "%s\n", Line);
+ fprintf((FILE *)_writeFile, "%s\n", line);
else
- fprintf((FILE *)_writeFile, "%s", Line);
+ fprintf((FILE *)_writeFile, "%s", line);
stack->pushBool(true);
@@ -332,8 +332,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushNULL();
return S_OK;
}
- bool Val;
- if (_readFile->read(&Val, sizeof(bool)) == sizeof(bool)) stack->pushBool(Val);
+ bool val;
+ if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val);
else stack->pushNULL();
return S_OK;
@@ -349,8 +349,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushNULL();
return S_OK;
}
- byte Val;
- if (_readFile->read(&Val, sizeof(byte)) == sizeof(byte)) stack->pushInt(Val);
+ byte val;
+ if (_readFile->read(&val, sizeof(byte)) == sizeof(byte)) stack->pushInt(val);
else stack->pushNULL();
return S_OK;
@@ -366,8 +366,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushNULL();
return S_OK;
}
- short Val;
- if (_readFile->read(&Val, sizeof(short)) == sizeof(short)) stack->pushInt(65536 + Val);
+ short val;
+ if (_readFile->read(&val, sizeof(short)) == sizeof(short)) stack->pushInt(65536 + val);
else stack->pushNULL();
return S_OK;
@@ -383,8 +383,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushNULL();
return S_OK;
}
- int Val;
- if (_readFile->read(&Val, sizeof(int)) == sizeof(int)) stack->pushInt(Val);
+ int val;
+ if (_readFile->read(&val, sizeof(int)) == sizeof(int)) stack->pushInt(val);
else stack->pushNULL();
return S_OK;
@@ -400,8 +400,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushNULL();
return S_OK;
}
- float Val;
- if (_readFile->read(&Val, sizeof(float)) == sizeof(float)) stack->pushFloat(Val);
+ float val;
+ if (_readFile->read(&val, sizeof(float)) == sizeof(float)) stack->pushFloat(val);
else stack->pushNULL();
return S_OK;
@@ -417,8 +417,8 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushNULL();
return S_OK;
}
- double Val;
- if (_readFile->read(&Val, sizeof(double)) == sizeof(double)) stack->pushFloat(Val);
+ double val;
+ if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val);
else stack->pushNULL();
return S_OK;
@@ -434,15 +434,15 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
stack->pushNULL();
return S_OK;
}
- uint32 Size;
- if (_readFile->read(&Size, sizeof(uint32)) == sizeof(uint32)) {
- byte *Str = new byte[Size + 1];
- if (Str) {
- if (_readFile->read(Str, Size) == Size) {
- Str[Size] = '\0';
- stack->pushString((char *)Str);
+ uint32 size;
+ if (_readFile->read(&size, sizeof(uint32)) == sizeof(uint32)) {
+ byte *str = new byte[size + 1];
+ if (str) {
+ if (_readFile->read(str, size) == size) {
+ str[size] = '\0';
+ stack->pushString((char *)str);
}
- delete [] Str;
+ delete [] str;
} else stack->pushNULL();
} else stack->pushNULL();
@@ -454,14 +454,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WriteBool") == 0) {
stack->correctParams(1);
- bool Val = stack->pop()->getBool();
+ bool val = stack->pop()->getBool();
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, (FILE *)_writeFile);
+ fwrite(&val, sizeof(val), 1, (FILE *)_writeFile);
stack->pushBool(true);
return S_OK;
@@ -472,14 +472,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WriteByte") == 0) {
stack->correctParams(1);
- byte Val = stack->pop()->getInt();
+ byte val = stack->pop()->getInt();
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, (FILE *)_writeFile);
+ fwrite(&val, sizeof(val), 1, (FILE *)_writeFile);
stack->pushBool(true);
return S_OK;
@@ -490,14 +490,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WriteShort") == 0) {
stack->correctParams(1);
- short Val = stack->pop()->getInt();
+ short val = stack->pop()->getInt();
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, (FILE *)_writeFile);
+ fwrite(&val, sizeof(val), 1, (FILE *)_writeFile);
stack->pushBool(true);
return S_OK;
@@ -508,14 +508,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) {
stack->correctParams(1);
- int Val = stack->pop()->getInt();
+ int val = stack->pop()->getInt();
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, (FILE *)_writeFile);
+ fwrite(&val, sizeof(val), 1, (FILE *)_writeFile);
stack->pushBool(true);
return S_OK;
@@ -526,14 +526,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WriteFloat") == 0) {
stack->correctParams(1);
- float Val = stack->pop()->getFloat();
+ float val = stack->pop()->getFloat();
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, (FILE *)_writeFile);
+ fwrite(&val, sizeof(val), 1, (FILE *)_writeFile);
stack->pushBool(true);
return S_OK;
@@ -544,14 +544,14 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WriteDouble") == 0) {
stack->correctParams(1);
- double Val = stack->pop()->getFloat();
+ double val = stack->pop()->getFloat();
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, (FILE *)_writeFile);
+ fwrite(&val, sizeof(val), 1, (FILE *)_writeFile);
stack->pushBool(true);
return S_OK;
@@ -562,7 +562,7 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "WriteString") == 0) {
stack->correctParams(1);
- const char *Val = stack->pop()->getString();
+ const char *val = stack->pop()->getString();
if (_textMode || !_writeFile) {
script->runtimeError("File.%s: File must be open for writing in binary mode.", name);
@@ -570,9 +570,9 @@ HRESULT CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *this
return S_OK;
}
- uint32 Size = strlen(Val);
- fwrite(&Size, sizeof(Size), 1, (FILE *)_writeFile);
- fwrite(Val, Size, 1, (FILE *)_writeFile);
+ uint32 size = strlen(val);
+ fwrite(&size, sizeof(size), 1, (FILE *)_writeFile);
+ fwrite(val, size, 1, (FILE *)_writeFile);
stack->pushBool(true);
@@ -608,7 +608,7 @@ CScValue *CSXFile::scGetProperty(const char *name) {
// Position (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Position") == 0) {
- _scValue->setInt(GetPos());
+ _scValue->setInt(getPos());
return _scValue;
}
@@ -616,7 +616,7 @@ CScValue *CSXFile::scGetProperty(const char *name) {
// Length (RO)
//////////////////////////////////////////////////////////////////////////
else if (strcmp(name, "Length") == 0) {
- _scValue->setInt(GetLength());
+ _scValue->setInt(getLength());
return _scValue;
}
@@ -663,22 +663,25 @@ HRESULT CSXFile::scSetProperty(const char *name, CScValue *value) {
}
//////////////////////////////////////////////////////////////////////////
-uint32 CSXFile::GetPos() {
- if (_mode == 1 && _readFile) return _readFile->pos();
+uint32 CSXFile::getPos() {
+ if (_mode == 1 && _readFile)
+ return _readFile->pos();
else if ((_mode == 2 || _mode == 3) && _writeFile) return ftell((FILE *)_writeFile);
else return 0;
}
//////////////////////////////////////////////////////////////////////////
-bool CSXFile::SetPos(uint32 pos, TSeek origin) {
- if (_mode == 1 && _readFile) return _readFile->seek(pos, origin);
+bool CSXFile::setPos(uint32 pos, TSeek origin) {
+ if (_mode == 1 && _readFile)
+ return _readFile->seek(pos, origin);
else if ((_mode == 2 || _mode == 3) && _writeFile) return fseek((FILE *)_writeFile, pos, (int)origin) == 0;
else return false;
}
//////////////////////////////////////////////////////////////////////////
-uint32 CSXFile::GetLength() {
- if (_mode == 1 && _readFile) return _readFile->size();
+uint32 CSXFile::getLength() {
+ if (_mode == 1 && _readFile)
+ return _readFile->size();
else if ((_mode == 2 || _mode == 3) && _writeFile) {
uint32 CurrentPos = ftell((FILE *)_writeFile);
fseek((FILE *)_writeFile, 0, SEEK_END);
@@ -697,12 +700,12 @@ HRESULT CSXFile::persist(CBPersistMgr *persistMgr) {
persistMgr->transfer(TMEMBER(_mode));
persistMgr->transfer(TMEMBER(_textMode));
- uint32 Pos = 0;
+ uint32 pos = 0;
if (persistMgr->_saving) {
- Pos = GetPos();
- persistMgr->transfer(TMEMBER(Pos));
+ pos = getPos();
+ persistMgr->transfer(TMEMBER(pos));
} else {
- persistMgr->transfer(TMEMBER(Pos));
+ persistMgr->transfer(TMEMBER(pos));
// try to re-open file if needed
_writeFile = NULL;
@@ -712,20 +715,26 @@ HRESULT CSXFile::persist(CBPersistMgr *persistMgr) {
// open for reading
if (_mode == 1) {
_readFile = Game->_fileManager->openFile(_filename);
- if (!_readFile) Close();
+ if (!_readFile)
+ close();
}
// open for writing / appending
else {
if (_textMode) {
- if (_mode == 2) _writeFile = fopen(_filename, "w+");
- else _writeFile = fopen(_filename, "a+");
+ if (_mode == 2)
+ _writeFile = fopen(_filename, "w+");
+ else
+ _writeFile = fopen(_filename, "a+");
} else {
- if (_mode == 2) _writeFile = fopen(_filename, "wb+");
- else _writeFile = fopen(_filename, "ab+");
+ if (_mode == 2)
+ _writeFile = fopen(_filename, "wb+");
+ else
+ _writeFile = fopen(_filename, "ab+");
}
- if (_writeFile) Close();
+ if (_writeFile)
+ close();
}
- SetPos(Pos);
+ setPos(pos);
}
}
diff --git a/engines/wintermute/Base/scriptables/SXFile.h b/engines/wintermute/Base/scriptables/SXFile.h
index b28fca019e..efa06b7023 100644
--- a/engines/wintermute/Base/scriptables/SXFile.h
+++ b/engines/wintermute/Base/scriptables/SXFile.h
@@ -51,11 +51,11 @@ private:
void *_writeFile;
int _mode; // 0..none, 1..read, 2..write, 3..append
bool _textMode;
- void Close();
+ void close();
void cleanup();
- uint32 GetPos();
- uint32 GetLength();
- bool SetPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN);
+ uint32 getPos();
+ uint32 getLength();
+ bool setPos(uint32 Pos, TSeek Origin = SEEK_TO_BEGIN);
char *_filename;
};