mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 01:07:22 +00:00
BAGEL: Renames in boflib/[cd]*.h
This commit is contained in:
parent
ce5561b046
commit
8af060fee5
@ -97,17 +97,17 @@ ErrorCode CBagel::setOption(const char *section, const char *option, int intValu
|
||||
|
||||
ErrorCode CBagel::getOption(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 size) {
|
||||
Assert(IsValidObject(this));
|
||||
return ReadSetting(section, option, stringValue, defaultValue, size);
|
||||
return readSetting(section, option, stringValue, defaultValue, size);
|
||||
}
|
||||
|
||||
ErrorCode CBagel::getOption(const char *section, const char *option, int *intValue, int defaultValue) {
|
||||
Assert(IsValidObject(this));
|
||||
return ReadSetting(section, option, intValue, defaultValue);
|
||||
return readSetting(section, option, intValue, defaultValue);
|
||||
}
|
||||
|
||||
ErrorCode CBagel::getOption(const char *section, const char *option, bool *boolValue, int defaultValue) {
|
||||
Assert(IsValidObject(this));
|
||||
return ReadSetting(section, option, boolValue, defaultValue);
|
||||
return readSetting(section, option, boolValue, defaultValue);
|
||||
}
|
||||
|
||||
ErrorCode CBagel::initialize() {
|
||||
|
@ -104,7 +104,7 @@ ErrorCode CBagCharacterObject::attach() {
|
||||
_binBufLen = cInputFile.GetLength();
|
||||
|
||||
if ((_binBuf = (char *)BofAlloc(_binBufLen + 1)) != nullptr) {
|
||||
cInputFile.Read(_binBuf, _binBufLen);
|
||||
cInputFile.read(_binBuf, _binBufLen);
|
||||
|
||||
} else {
|
||||
ReportError(ERR_MEMORY);
|
||||
|
@ -137,7 +137,7 @@ ErrorCode CBagHelp::attach() {
|
||||
uint32 size = file.GetLength();
|
||||
char *buffer = (char *)BofCAlloc(size + 1, 1);
|
||||
if (buffer != nullptr) {
|
||||
file.Read(buffer, size);
|
||||
file.read(buffer, size);
|
||||
|
||||
CBofRect cRect;
|
||||
cRect.SetRect(120, 100, 550, 348);
|
||||
|
@ -454,7 +454,7 @@ ErrorCode CBagMasterWin::loadFile(const CBofString &wldName, const CBofString &s
|
||||
|
||||
CBofFile cFile;
|
||||
cFile.open(sWldFileName);
|
||||
cFile.Read(pBuf, nLength);
|
||||
cFile.read(pBuf, nLength);
|
||||
cFile.close();
|
||||
|
||||
CBagMasterWin::loadFileFromStream(fpInput, startWldName);
|
||||
@ -601,7 +601,7 @@ ErrorCode CBagMasterWin::loadGlobalVars(const CBofString &wldName) {
|
||||
|
||||
CBofFile cFile;
|
||||
cFile.open(sWldFileName);
|
||||
cFile.Read(pBuf, nLength);
|
||||
cFile.read(pBuf, nLength);
|
||||
cFile.close();
|
||||
|
||||
while (!fpInput.eof()) {
|
||||
|
@ -74,7 +74,7 @@ ErrorCode CBagMoo::SetPDAMovie(CBofString &s) {
|
||||
Assert(m_pMovie != nullptr);
|
||||
|
||||
if (m_pMovie) {
|
||||
m_pMovie->SetFileName(s);
|
||||
m_pMovie->setFileName(s);
|
||||
|
||||
// Attach this bad baby...
|
||||
ec = m_pMovie->attach();
|
||||
|
@ -179,7 +179,7 @@ PARSE_CODES CBagObject::setInfo(CBagIfstream &istr) {
|
||||
CBofString s(szLocalBuff, 256);
|
||||
GetAlphaNumFromStream(istr, s);
|
||||
MACROREPLACE(s);
|
||||
SetFileName(s);
|
||||
setFileName(s);
|
||||
break;
|
||||
}
|
||||
//
|
||||
|
@ -352,7 +352,7 @@ public:
|
||||
virtual const CBofString &GetRefName();
|
||||
virtual void SetRefName(const CBofString &s);
|
||||
|
||||
virtual void SetFileName(const CBofString &s) {
|
||||
virtual void setFileName(const CBofString &s) {
|
||||
m_sFileName = s;
|
||||
}
|
||||
virtual void setSize(const CBofSize &) {}
|
||||
|
@ -141,7 +141,7 @@ void ST_BAGEL_SAVE::clear() {
|
||||
|
||||
|
||||
CBagSaveGameFile::CBagSaveGameFile(bool isSaving) {
|
||||
SetFile("spacebar.sav",
|
||||
setFile("spacebar.sav",
|
||||
isSaving ?
|
||||
(CDF_MEMORY | CDF_ENCRYPT | CDF_KEEPOPEN | CDF_CREATE | CDF_SAVEFILE) :
|
||||
(CDF_MEMORY | CDF_ENCRYPT | CDF_KEEPOPEN | CDF_SAVEFILE)
|
||||
@ -174,24 +174,24 @@ ErrorCode CBagSaveGameFile::WriteSavedGame() {
|
||||
saveData.synchronize(s);
|
||||
|
||||
// Add the record
|
||||
AddRecord(stream.getData(), stream.size(), true, 0);
|
||||
addRecord(stream.getData(), stream.size(), true, 0);
|
||||
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBagSaveGameFile::ReadSavedGame(int32 slotNum) {
|
||||
ErrorCode CBagSaveGameFile::readSavedGame(int32 slotNum) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
int32 lRecNum = FindRecord(slotNum);
|
||||
int32 lRecNum = findRecord(slotNum);
|
||||
if (lRecNum != -1) {
|
||||
int32 lSize = GetRecSize(lRecNum);
|
||||
int32 lSize = getRecSize(lRecNum);
|
||||
|
||||
if (lSize == ST_SAVEDGAME_HEADER::size()) {
|
||||
_errCode = ERR_FREAD;
|
||||
} else {
|
||||
byte *pBuf = (byte *)BofAlloc(lSize);
|
||||
assert(pBuf);
|
||||
ReadRecord(lRecNum, pBuf);
|
||||
readRecord(lRecNum, pBuf);
|
||||
|
||||
// Load in the savegame
|
||||
Common::MemoryReadStream stream(pBuf, lSize);
|
||||
@ -220,21 +220,21 @@ ErrorCode CBagSaveGameFile::ReadSavedGame(int32 slotNum) {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBagSaveGameFile::ReadTitle(int32 lSlot, ST_SAVEDGAME_HEADER *pSavedGame) {
|
||||
ErrorCode CBagSaveGameFile::readTitle(int32 lSlot, ST_SAVEDGAME_HEADER *pSavedGame) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// validate input
|
||||
Assert(lSlot >= 0 && lSlot < MAX_SAVEDGAMES);
|
||||
Assert(pSavedGame != nullptr);
|
||||
|
||||
int32 lRecNum = FindRecord(lSlot);
|
||||
int32 lRecNum = findRecord(lSlot);
|
||||
|
||||
if (lRecNum != -1) {
|
||||
int32 lSize = GetRecSize(lRecNum);
|
||||
int32 lSize = getRecSize(lRecNum);
|
||||
|
||||
byte *pBuf = (byte *)BofAlloc(lSize);
|
||||
if (pBuf != nullptr) {
|
||||
ReadRecord(lRecNum, pBuf);
|
||||
readRecord(lRecNum, pBuf);
|
||||
|
||||
// Fill ST_SAVEDGAME_HEADER structure with this game's saved info
|
||||
BofMemCopy(pSavedGame, pBuf, sizeof(ST_SAVEDGAME_HEADER));
|
||||
@ -245,13 +245,13 @@ ErrorCode CBagSaveGameFile::ReadTitle(int32 lSlot, ST_SAVEDGAME_HEADER *pSavedGa
|
||||
}
|
||||
|
||||
} else {
|
||||
ReportError(ERR_UNKNOWN, "Unable to find saved game #%ld in %s", lSlot, m_szFileName);
|
||||
ReportError(ERR_UNKNOWN, "Unable to find saved game #%ld in %s", lSlot, _szFileName);
|
||||
}
|
||||
|
||||
return(_errCode);
|
||||
}
|
||||
|
||||
ErrorCode CBagSaveGameFile::ReadTitleOnly(int32 lSlot, char *pGameTitle) {
|
||||
ErrorCode CBagSaveGameFile::readTitleOnly(int32 lSlot, char *pGameTitle) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Validate input
|
||||
@ -259,16 +259,16 @@ ErrorCode CBagSaveGameFile::ReadTitleOnly(int32 lSlot, char *pGameTitle) {
|
||||
Assert(pGameTitle != nullptr);
|
||||
|
||||
byte pBuf[MAX_SAVETITLE + 1];
|
||||
int32 lRecNum = FindRecord(lSlot);
|
||||
int32 lRecNum = findRecord(lSlot);
|
||||
if (lRecNum != -1) {
|
||||
int32 lSize = MAX_SAVETITLE;
|
||||
ReadFromFile(lRecNum, pBuf, lSize);
|
||||
readFromFile(lRecNum, pBuf, lSize);
|
||||
|
||||
// Fill with current game title
|
||||
BofMemCopy(pGameTitle, pBuf, lSize);
|
||||
|
||||
} else {
|
||||
ReportError(ERR_UNKNOWN, "Unable to find saved game #%ld in %s", lSlot, m_szFileName);
|
||||
ReportError(ERR_UNKNOWN, "Unable to find saved game #%ld in %s", lSlot, _szFileName);
|
||||
}
|
||||
|
||||
return _errCode;
|
||||
@ -282,7 +282,7 @@ int32 CBagSaveGameFile::GetActualNumSaves() {
|
||||
int32 lNumRecs = GetNumSavedGames();
|
||||
for (int32 i = 0; i < lNumRecs; i++) {
|
||||
ST_SAVEDGAME_HEADER stGameInfo;
|
||||
if (ReadTitle(i, &stGameInfo) == ERR_NONE) {
|
||||
if (readTitle(i, &stGameInfo) == ERR_NONE) {
|
||||
if (stGameInfo.m_bUsed) {
|
||||
lNumSaves++;
|
||||
}
|
||||
@ -300,7 +300,7 @@ bool CBagSaveGameFile::AnySavedGames() {
|
||||
int32 lNumRecs = GetNumSavedGames();
|
||||
for (int32 i = 0; i < lNumRecs; i++) {
|
||||
ST_SAVEDGAME_HEADER stGameInfo;
|
||||
if (ReadTitle(i, &stGameInfo) == ERR_NONE) {
|
||||
if (readTitle(i, &stGameInfo) == ERR_NONE) {
|
||||
|
||||
if (stGameInfo.m_bUsed) {
|
||||
return true;
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
CBagSaveGameFile(bool isSaving);
|
||||
|
||||
int32 GetNumSavedGames() const {
|
||||
return GetNumberOfRecs();
|
||||
return getNumberOfRecs();
|
||||
}
|
||||
int32 GetActualNumSaves();
|
||||
bool AnySavedGames();
|
||||
@ -142,14 +142,14 @@ public:
|
||||
/**
|
||||
* Restore a BAGEL saved game
|
||||
*/
|
||||
ErrorCode ReadSavedGame(int32 slotNum);
|
||||
ErrorCode readSavedGame(int32 slotNum);
|
||||
|
||||
/**
|
||||
* Reads a BAGEL saved game title
|
||||
*/
|
||||
ErrorCode ReadTitle(int32 lSlot, ST_SAVEDGAME_HEADER *pSavedGame);
|
||||
ErrorCode readTitle(int32 lSlot, ST_SAVEDGAME_HEADER *pSavedGame);
|
||||
|
||||
ErrorCode ReadTitleOnly(int32 lSlot, char *pGameTitle);
|
||||
ErrorCode readTitleOnly(int32 lSlot, char *pGameTitle);
|
||||
};
|
||||
|
||||
} // namespace Bagel
|
||||
|
@ -93,7 +93,7 @@ ErrorCode CBagStorageDevBmp::KillWorkBmp() {
|
||||
}
|
||||
|
||||
ErrorCode CBagStorageDevBmp::loadFileFromStream(CBagIfstream &fpInput, const CBofString &sWldName, bool bAttach) {
|
||||
SetFileName(sWldName);
|
||||
setFileName(sWldName);
|
||||
SetRefName(sWldName);
|
||||
|
||||
return CBagStorageDev::loadFileFromStream(fpInput, sWldName, bAttach);
|
||||
|
@ -580,7 +580,7 @@ ErrorCode CBagStorageDev::loadFile(const CBofString &sWldName) {
|
||||
|
||||
CBofFile cFile;
|
||||
cFile.open(sWldFileName);
|
||||
cFile.Read(pBuf, nLength);
|
||||
cFile.read(pBuf, nLength);
|
||||
cFile.close();
|
||||
|
||||
CBagStorageDev::loadFileFromStream(fpInput, sWldFileName);
|
||||
@ -1447,7 +1447,7 @@ ErrorCode CBagStorageDevWnd::loadFile(const CBofString &sFile) {
|
||||
|
||||
CBofFile cFile;
|
||||
cFile.open(sWldFile);
|
||||
cFile.Read(pBuf, nLength);
|
||||
cFile.read(pBuf, nLength);
|
||||
cFile.close();
|
||||
|
||||
CBagStorageDev::loadFileFromStream(fpInput, sWldFile);
|
||||
@ -1723,7 +1723,7 @@ ErrorCode CBagStorageDevDlg::loadFile(const CBofString &sFile) {
|
||||
|
||||
CBofFile cFile;
|
||||
cFile.open(sWldFile);
|
||||
cFile.Read(pBuf, nLength);
|
||||
cFile.read(pBuf, nLength);
|
||||
cFile.close();
|
||||
|
||||
CBagStorageDev::loadFileFromStream(fpInput, sWldFile);
|
||||
|
@ -151,7 +151,7 @@ ErrorCode CBagTextObject::attach() {
|
||||
char *pTextBuff = (char *)BofCAlloc(nFileLen + 1, 1);
|
||||
if (pTextBuff != nullptr) {
|
||||
// Read the text file into buffers
|
||||
fpTextFile.Read(pTextBuff, nFileLen);
|
||||
fpTextFile.read(pTextBuff, nFileLen);
|
||||
fpTextFile.close();
|
||||
|
||||
*m_psText += pTextBuff;
|
||||
@ -235,7 +235,7 @@ void CBagTextObject::setText(const CBofString &s) {
|
||||
if (m_psText) {
|
||||
*m_psText = s;
|
||||
} else {
|
||||
SetFileName(s);
|
||||
setFileName(s);
|
||||
}
|
||||
|
||||
RecalcTextRect(!getFileName().Right(4).Find(".TXT") || !getFileName().Right(4).Find(".txt"));
|
||||
|
@ -67,7 +67,7 @@ void CBofApp::StartupCode() {
|
||||
// Open the Boffo debug options file (BOFFO.INI)
|
||||
g_pDebugOptions = new CBofDebugOptions(DEBUG_INI);
|
||||
if (g_pDebugOptions != nullptr) {
|
||||
g_pDebugOptions->ReadSetting("DebugOptions", "MainLoops", &_nIterations, DEFAULT_MAINLOOPS);
|
||||
g_pDebugOptions->readSetting("DebugOptions", "MainLoops", &_nIterations, DEFAULT_MAINLOOPS);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -94,7 +94,7 @@ static const uint16 crc32tabHi[256] = {
|
||||
0xb366, 0xc461, 0x5d68, 0x2a6f, 0xb40b, 0xc30c, 0x5a05, 0x2d02
|
||||
};
|
||||
|
||||
uint32 CalculateCRC(const void *pBuffer, int32 lBufLen, uint32 lCrcValue) {
|
||||
uint32 calculateCRC(const void *pBuffer, int32 lBufLen, uint32 lCrcValue) {
|
||||
Assert(pBuffer != nullptr);
|
||||
Assert(lBufLen > 0);
|
||||
|
||||
@ -111,7 +111,7 @@ uint32 CalculateCRC(const void *pBuffer, int32 lBufLen, uint32 lCrcValue) {
|
||||
return lCrcValue;
|
||||
}
|
||||
|
||||
uint32 CalculateCRC(const int32 *pBuffer, int32 lBufLen, uint32 lCrcValue) {
|
||||
uint32 calculateCRC(const int32 *pBuffer, int32 lBufLen, uint32 lCrcValue) {
|
||||
Assert(pBuffer != nullptr);
|
||||
Assert(lBufLen > 0);
|
||||
|
||||
|
@ -34,8 +34,8 @@ namespace Bagel {
|
||||
* @param lCrcValue Previous CRC value (if running CRC)
|
||||
* @return New CRC value
|
||||
*/
|
||||
extern uint32 CalculateCRC(const void *pBuffer, int32 lBufLen, uint32 lCrcValue = 0);
|
||||
extern uint32 CalculateCRC(const int32 *pBuffer, int32 lBufLen, uint32 lCrcValue = 0);
|
||||
extern uint32 calculateCRC(const void *pBuffer, int32 lBufLen, uint32 lCrcValue = 0);
|
||||
extern uint32 calculateCRC(const int32 *pBuffer, int32 lBufLen, uint32 lCrcValue = 0);
|
||||
|
||||
} // namespace Bagel
|
||||
|
||||
|
@ -33,41 +33,41 @@ namespace Bagel {
|
||||
static uint32 CreateHashCode(const byte *);
|
||||
|
||||
void HEADER_REC::synchronize(Common::Serializer &s) {
|
||||
s.syncAsSint32LE(m_lOffset);
|
||||
s.syncAsSint32LE(m_lLength);
|
||||
s.syncAsUint32LE(m_lCrc);
|
||||
s.syncAsUint32LE(m_lKey);
|
||||
s.syncAsSint32LE(_lOffset);
|
||||
s.syncAsSint32LE(_lLength);
|
||||
s.syncAsUint32LE(_lCrc);
|
||||
s.syncAsUint32LE(_lKey);
|
||||
}
|
||||
|
||||
void HEAD_INFO::synchronize(Common::Serializer &s) {
|
||||
s.syncAsSint32LE(m_lNumRecs);
|
||||
s.syncAsSint32LE(m_lAddress);
|
||||
s.syncAsUint32LE(m_lFlags);
|
||||
s.syncAsUint32LE(m_lFootCrc);
|
||||
s.syncAsSint32LE(_lNumRecs);
|
||||
s.syncAsSint32LE(_lAddress);
|
||||
s.syncAsUint32LE(_lFlags);
|
||||
s.syncAsUint32LE(_lFootCrc);
|
||||
}
|
||||
|
||||
|
||||
CBofDataFile::CBofDataFile() {
|
||||
m_szFileName[0] = '\0';
|
||||
m_szPassWord[0] = '\0';
|
||||
m_lHeaderLength = 0;
|
||||
m_lNumRecs = 0;
|
||||
m_pHeader = nullptr;
|
||||
m_bHeaderDirty = false;
|
||||
_szFileName[0] = '\0';
|
||||
_szPassWord[0] = '\0';
|
||||
_lHeaderLength = 0;
|
||||
_lNumRecs = 0;
|
||||
_pHeader = nullptr;
|
||||
_bHeaderDirty = false;
|
||||
}
|
||||
|
||||
CBofDataFile::CBofDataFile(const char *pszFileName, uint32 lFlags, const char *pPassword) {
|
||||
m_szFileName[0] = '\0';
|
||||
m_szPassWord[0] = '\0';
|
||||
m_lHeaderLength = 0;
|
||||
m_lNumRecs = 0;
|
||||
m_pHeader = nullptr;
|
||||
m_bHeaderDirty = false;
|
||||
_szFileName[0] = '\0';
|
||||
_szPassWord[0] = '\0';
|
||||
_lHeaderLength = 0;
|
||||
_lNumRecs = 0;
|
||||
_pHeader = nullptr;
|
||||
_bHeaderDirty = false;
|
||||
|
||||
SetFile(pszFileName, lFlags, pPassword);
|
||||
setFile(pszFileName, lFlags, pPassword);
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::SetFile(const char *pszFileName, uint32 lFlags, const char *pPassword) {
|
||||
ErrorCode CBofDataFile::setFile(const char *pszFileName, uint32 lFlags, const char *pPassword) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Validate input
|
||||
@ -75,7 +75,7 @@ ErrorCode CBofDataFile::SetFile(const char *pszFileName, uint32 lFlags, const ch
|
||||
Assert(strlen(pszFileName) < MAX_FNAME);
|
||||
|
||||
// Release any previous data-file
|
||||
ReleaseFile();
|
||||
releaseFile();
|
||||
|
||||
// All data files are binary, so force it
|
||||
lFlags |= CBF_BINARY;
|
||||
@ -85,23 +85,23 @@ ErrorCode CBofDataFile::SetFile(const char *pszFileName, uint32 lFlags, const ch
|
||||
// Don't want to overwrite past our password buffer
|
||||
Assert(strlen(pPassword) < MAX_PW_LEN);
|
||||
|
||||
Common::strcpy_s(m_szPassWord, pPassword);
|
||||
Common::strcpy_s(_szPassWord, pPassword);
|
||||
|
||||
// Force encryption on since they supplied a password
|
||||
m_lFlags |= CDF_ENCRYPT;
|
||||
_lFlags |= CDF_ENCRYPT;
|
||||
}
|
||||
|
||||
// Remember the flags
|
||||
m_lFlags = lFlags;
|
||||
_lFlags = lFlags;
|
||||
|
||||
if (FileGetFullPath(m_szFileName, pszFileName) != nullptr) {
|
||||
if (FileGetFullPath(_szFileName, pszFileName) != nullptr) {
|
||||
if (open() == ERR_NONE) {
|
||||
|
||||
// Read header block
|
||||
ReadHeader();
|
||||
readHeader();
|
||||
|
||||
// Close data file if we are not keeping it open
|
||||
if (!(m_lFlags & CDF_KEEPOPEN)) {
|
||||
if (!(_lFlags & CDF_KEEPOPEN)) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
@ -115,24 +115,24 @@ ErrorCode CBofDataFile::SetFile(const char *pszFileName, uint32 lFlags, const ch
|
||||
CBofDataFile::~CBofDataFile() {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
ReleaseFile();
|
||||
releaseFile();
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::ReleaseFile() {
|
||||
ErrorCode CBofDataFile::releaseFile() {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// If header was modified
|
||||
if (m_bHeaderDirty) {
|
||||
if (_bHeaderDirty) {
|
||||
// Write header to disk
|
||||
WriteHeader();
|
||||
writeHeader();
|
||||
}
|
||||
|
||||
close();
|
||||
|
||||
// Free header buffer
|
||||
if (m_pHeader != nullptr) {
|
||||
delete[] m_pHeader;
|
||||
m_pHeader = nullptr;
|
||||
if (_pHeader != nullptr) {
|
||||
delete[] _pHeader;
|
||||
_pHeader = nullptr;
|
||||
}
|
||||
|
||||
return _errCode;
|
||||
@ -150,22 +150,22 @@ ErrorCode CBofDataFile::create() {
|
||||
}
|
||||
|
||||
// Re-initialize
|
||||
if (m_pHeader != nullptr) {
|
||||
delete[] m_pHeader;
|
||||
m_pHeader = nullptr;
|
||||
if (_pHeader != nullptr) {
|
||||
delete[] _pHeader;
|
||||
_pHeader = nullptr;
|
||||
}
|
||||
|
||||
_stream = nullptr;
|
||||
m_lHeaderLength = 0;
|
||||
m_bHeaderDirty = false;
|
||||
_lHeaderLength = 0;
|
||||
_bHeaderDirty = false;
|
||||
|
||||
stHeaderInfo.m_lNumRecs = m_lNumRecs = 0;
|
||||
stHeaderInfo.m_lAddress = HEAD_INFO::size();
|
||||
stHeaderInfo._lNumRecs = _lNumRecs = 0;
|
||||
stHeaderInfo._lAddress = HEAD_INFO::size();
|
||||
|
||||
// Create the file
|
||||
if (CBofFile::create(m_szFileName, m_lFlags) == ERR_NONE) {
|
||||
if (CBofFile::create(_szFileName, _lFlags) == ERR_NONE) {
|
||||
// Write empty header info
|
||||
if (Write(stHeaderInfo) == ERR_NONE) {
|
||||
if (write(stHeaderInfo) == ERR_NONE) {
|
||||
|
||||
} else {
|
||||
_errCode = ERR_FWRITE;
|
||||
@ -187,17 +187,17 @@ ErrorCode CBofDataFile::open() {
|
||||
// Only continue if there is no current error
|
||||
if (_errCode == ERR_NONE) {
|
||||
if (_stream == nullptr) {
|
||||
if (!(m_lFlags & CDF_READONLY)) {
|
||||
if (m_lFlags & CDF_SAVEFILE) {
|
||||
if (m_lFlags & CDF_CREATE)
|
||||
if (!(_lFlags & CDF_READONLY)) {
|
||||
if (_lFlags & CDF_SAVEFILE) {
|
||||
if (_lFlags & CDF_CREATE)
|
||||
create();
|
||||
} else if (!FileExists(m_szFileName))
|
||||
} else if (!FileExists(_szFileName))
|
||||
create();
|
||||
}
|
||||
|
||||
if (_stream == nullptr) {
|
||||
// Open data file
|
||||
CBofFile::open(m_szFileName, m_lFlags);
|
||||
CBofFile::open(_szFileName, _lFlags);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -209,8 +209,8 @@ ErrorCode CBofDataFile::close() {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
if (_stream != nullptr) {
|
||||
if (m_bHeaderDirty) {
|
||||
WriteHeader();
|
||||
if (_bHeaderDirty) {
|
||||
writeHeader();
|
||||
}
|
||||
|
||||
CBofFile::close();
|
||||
@ -219,7 +219,7 @@ ErrorCode CBofDataFile::close() {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::ReadHeader() {
|
||||
ErrorCode CBofDataFile::readHeader() {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Only continue if there is no current error
|
||||
@ -231,64 +231,64 @@ ErrorCode CBofDataFile::ReadHeader() {
|
||||
if (!ErrorOccurred()) {
|
||||
// Determine number of records in file
|
||||
HEAD_INFO stHeaderInfo;
|
||||
if (Read(stHeaderInfo) == ERR_NONE) {
|
||||
m_lNumRecs = stHeaderInfo.m_lNumRecs;
|
||||
m_lHeaderStart = stHeaderInfo.m_lAddress;
|
||||
if (read(stHeaderInfo) == ERR_NONE) {
|
||||
_lNumRecs = stHeaderInfo._lNumRecs;
|
||||
_lHeaderStart = stHeaderInfo._lAddress;
|
||||
|
||||
// Length of header is number of records * header-record size
|
||||
m_lHeaderLength = m_lNumRecs * HEADER_REC::size();
|
||||
_lHeaderLength = _lNumRecs * HEADER_REC::size();
|
||||
|
||||
Common::SeekableReadStream *rs = dynamic_cast<Common::SeekableReadStream *>(_stream);
|
||||
assert(rs);
|
||||
int32 lFileLength = rs->size();
|
||||
|
||||
// Make sure header contains valid info
|
||||
if ((m_lHeaderStart >= HEAD_INFO::size()) &&
|
||||
(m_lHeaderStart <= lFileLength) && (m_lHeaderLength >= 0) &&
|
||||
(m_lHeaderLength < lFileLength)) {
|
||||
if ((_lHeaderStart >= HEAD_INFO::size()) &&
|
||||
(_lHeaderStart <= lFileLength) && (_lHeaderLength >= 0) &&
|
||||
(_lHeaderLength < lFileLength)) {
|
||||
|
||||
// Force Encrypted, and Compress if existing file has them
|
||||
m_lFlags |= stHeaderInfo.m_lFlags & CDF_ENCRYPT;
|
||||
m_lFlags |= stHeaderInfo.m_lFlags & CDF_COMPRESSED;
|
||||
_lFlags |= stHeaderInfo._lFlags & CDF_ENCRYPT;
|
||||
_lFlags |= stHeaderInfo._lFlags & CDF_COMPRESSED;
|
||||
|
||||
if (m_lHeaderLength != 0) {
|
||||
if (_lHeaderLength != 0) {
|
||||
// Allocate buffer to hold header
|
||||
if ((m_pHeader = new HEADER_REC[(int)m_lNumRecs]) != nullptr) {
|
||||
if ((_pHeader = new HEADER_REC[(int)_lNumRecs]) != nullptr) {
|
||||
// Seek to start of header
|
||||
Seek(m_lHeaderStart);
|
||||
Seek(_lHeaderStart);
|
||||
|
||||
// Read header
|
||||
ErrorCode errCode = ERR_NONE;
|
||||
for (int i = 0; i < m_lNumRecs && errCode == ERR_NONE; ++i) {
|
||||
errCode = Read(m_pHeader[i]);
|
||||
for (int i = 0; i < _lNumRecs && errCode == ERR_NONE; ++i) {
|
||||
errCode = read(_pHeader[i]);
|
||||
}
|
||||
|
||||
if (errCode == ERR_NONE) {
|
||||
uint32 lCrc = CalculateCRC(&m_pHeader->m_lOffset, 4 * m_lNumRecs);
|
||||
uint32 lCrc = calculateCRC(&_pHeader->_lOffset, 4 * _lNumRecs);
|
||||
|
||||
if (lCrc != stHeaderInfo.m_lFootCrc) {
|
||||
LogError(BuildString("Error: '%s' has invalid footer", m_szFileName));
|
||||
if (lCrc != stHeaderInfo._lFootCrc) {
|
||||
LogError(BuildString("Error: '%s' has invalid footer", _szFileName));
|
||||
_errCode = ERR_CRC;
|
||||
}
|
||||
|
||||
} else {
|
||||
LogError(BuildString("Error: Could not read footer in file '%s'", m_szFileName));
|
||||
LogError(BuildString("Error: Could not read footer in file '%s'", _szFileName));
|
||||
_errCode = ERR_FREAD;
|
||||
}
|
||||
|
||||
} else {
|
||||
LogError(BuildString("Error: Could not allocate footer for file '%s'", m_szFileName));
|
||||
LogError(BuildString("Error: Could not allocate footer for file '%s'", _szFileName));
|
||||
_errCode = ERR_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
LogError(BuildString("Error: '%s' has invalid header", m_szFileName));
|
||||
LogError(BuildString("Error: '%s' has invalid header", _szFileName));
|
||||
_errCode = ERR_FTYPE;
|
||||
}
|
||||
|
||||
} else {
|
||||
LogError(BuildString("Error: Could not read header in file '%s'", m_szFileName));
|
||||
LogError(BuildString("Error: Could not read header in file '%s'", _szFileName));
|
||||
_errCode = ERR_FREAD;
|
||||
}
|
||||
}
|
||||
@ -297,7 +297,7 @@ ErrorCode CBofDataFile::ReadHeader() {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::WriteHeader() {
|
||||
ErrorCode CBofDataFile::writeHeader() {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Only continue if there is no current error
|
||||
@ -309,39 +309,39 @@ ErrorCode CBofDataFile::WriteHeader() {
|
||||
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Header starts at the end of the last record
|
||||
HEADER_REC *pRec = &m_pHeader[m_lNumRecs - 1];
|
||||
m_lHeaderStart = pRec->m_lOffset + pRec->m_lLength;
|
||||
HEADER_REC *pRec = &_pHeader[_lNumRecs - 1];
|
||||
_lHeaderStart = pRec->_lOffset + pRec->_lLength;
|
||||
|
||||
HEAD_INFO stHeaderInfo;
|
||||
stHeaderInfo.m_lNumRecs = m_lNumRecs;
|
||||
stHeaderInfo.m_lAddress = m_lHeaderStart;
|
||||
stHeaderInfo.m_lFlags = m_lFlags;
|
||||
stHeaderInfo.m_lFootCrc = CalculateCRC(&m_pHeader->m_lOffset, 4 * m_lNumRecs);
|
||||
stHeaderInfo._lNumRecs = _lNumRecs;
|
||||
stHeaderInfo._lAddress = _lHeaderStart;
|
||||
stHeaderInfo._lFlags = _lFlags;
|
||||
stHeaderInfo._lFootCrc = calculateCRC(&_pHeader->_lOffset, 4 * _lNumRecs);
|
||||
|
||||
// Seek to front of file to write header info
|
||||
SeekToBeginning();
|
||||
|
||||
if (Write(stHeaderInfo) == ERR_NONE) {
|
||||
if (write(stHeaderInfo) == ERR_NONE) {
|
||||
// Seek to start of where header is to be written
|
||||
Seek(m_lHeaderStart);
|
||||
Seek(_lHeaderStart);
|
||||
|
||||
// Write header to data file
|
||||
ErrorCode errCode = ERR_NONE;
|
||||
for (int i = 0; i < m_lNumRecs && errCode == ERR_NONE; ++i) {
|
||||
errCode = Write(m_pHeader[i]);
|
||||
for (int i = 0; i < _lNumRecs && errCode == ERR_NONE; ++i) {
|
||||
errCode = write(_pHeader[i]);
|
||||
}
|
||||
|
||||
if (errCode == ERR_NONE) {
|
||||
// Header is now clean
|
||||
m_bHeaderDirty = false;
|
||||
_bHeaderDirty = false;
|
||||
|
||||
} else {
|
||||
LogError(BuildString("Error writing footer to file '%s'", m_szFileName));
|
||||
LogError(BuildString("Error writing footer to file '%s'", _szFileName));
|
||||
_errCode = ERR_FWRITE;
|
||||
}
|
||||
|
||||
} else {
|
||||
LogError(BuildString("Error writing header to file '%s'", m_szFileName));
|
||||
LogError(BuildString("Error writing header to file '%s'", _szFileName));
|
||||
_errCode = ERR_FWRITE;
|
||||
}
|
||||
}
|
||||
@ -350,7 +350,7 @@ ErrorCode CBofDataFile::WriteHeader() {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::ReadRecord(int32 lRecNum, void *pBuf) {
|
||||
ErrorCode CBofDataFile::readRecord(int32 lRecNum, void *pBuf) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Only continue if there is no current error
|
||||
@ -359,13 +359,13 @@ ErrorCode CBofDataFile::ReadRecord(int32 lRecNum, void *pBuf) {
|
||||
Assert(pBuf != nullptr);
|
||||
|
||||
// Validate record number
|
||||
Assert(lRecNum >= 0 && lRecNum < m_lNumRecs);
|
||||
Assert(lRecNum >= 0 && lRecNum < _lNumRecs);
|
||||
|
||||
// Make sure we have a valid header
|
||||
Assert(m_pHeader != nullptr);
|
||||
Assert(_pHeader != nullptr);
|
||||
// Get info about address of where record starts
|
||||
// and how large the record is.
|
||||
HEADER_REC *pRecInfo = &m_pHeader[(int)lRecNum];
|
||||
HEADER_REC *pRecInfo = &_pHeader[(int)lRecNum];
|
||||
|
||||
// Open the data file if it's not already open
|
||||
if (_stream == nullptr) {
|
||||
@ -374,24 +374,24 @@ ErrorCode CBofDataFile::ReadRecord(int32 lRecNum, void *pBuf) {
|
||||
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Seek to that point in the file
|
||||
Seek(pRecInfo->m_lOffset);
|
||||
Seek(pRecInfo->_lOffset);
|
||||
|
||||
// Read in the record
|
||||
if (Read(pBuf, pRecInfo->m_lLength) == ERR_NONE) {
|
||||
if (read(pBuf, pRecInfo->_lLength) == ERR_NONE) {
|
||||
// If this file is encrypted, then decrypt it
|
||||
if (m_lFlags & CDF_ENCRYPT) {
|
||||
Decrypt(pBuf, (int)pRecInfo->m_lLength, m_szPassWord);
|
||||
if (_lFlags & CDF_ENCRYPT) {
|
||||
Decrypt(pBuf, (int)pRecInfo->_lLength, _szPassWord);
|
||||
}
|
||||
|
||||
// Calculate and verify this record's CRC value
|
||||
uint32 lCrc = CalculateCRC(pBuf, (int)pRecInfo->m_lLength);
|
||||
uint32 lCrc = calculateCRC(pBuf, (int)pRecInfo->_lLength);
|
||||
|
||||
if (lCrc != pRecInfo->m_lCrc) {
|
||||
if (lCrc != pRecInfo->_lCrc) {
|
||||
_errCode = ERR_CRC;
|
||||
}
|
||||
|
||||
} else {
|
||||
LogError(BuildString("Error reading record %ld in file '%s'", lRecNum, m_szFileName));
|
||||
LogError(BuildString("Error reading record %ld in file '%s'", lRecNum, _szFileName));
|
||||
_errCode = ERR_FREAD;
|
||||
}
|
||||
}
|
||||
@ -400,7 +400,7 @@ ErrorCode CBofDataFile::ReadRecord(int32 lRecNum, void *pBuf) {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::ReadFromFile(int32 lRecNum, void *pBuf, int32 lBytes) {
|
||||
ErrorCode CBofDataFile::readFromFile(int32 lRecNum, void *pBuf, int32 lBytes) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Only continue if there is no current error
|
||||
@ -409,14 +409,14 @@ ErrorCode CBofDataFile::ReadFromFile(int32 lRecNum, void *pBuf, int32 lBytes) {
|
||||
Assert(pBuf != nullptr);
|
||||
|
||||
// Validate record number
|
||||
Assert(lRecNum >= 0 && lRecNum < m_lNumRecs);
|
||||
Assert(lRecNum >= 0 && lRecNum < _lNumRecs);
|
||||
|
||||
// Make sure we have a valid header
|
||||
Assert(m_pHeader != nullptr);
|
||||
Assert(_pHeader != nullptr);
|
||||
|
||||
// Get info about address of where record starts
|
||||
// and how large the record is.
|
||||
HEADER_REC *pRecInfo = &m_pHeader[(int)lRecNum];
|
||||
HEADER_REC *pRecInfo = &_pHeader[(int)lRecNum];
|
||||
|
||||
// Open the data file if it's not already open
|
||||
if (_stream == nullptr) {
|
||||
@ -425,19 +425,19 @@ ErrorCode CBofDataFile::ReadFromFile(int32 lRecNum, void *pBuf, int32 lBytes) {
|
||||
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Seek to that point in the file
|
||||
Seek(pRecInfo->m_lOffset);
|
||||
Seek(pRecInfo->_lOffset);
|
||||
|
||||
// Read in the requested bytes...
|
||||
if (Read(pBuf, lBytes) == ERR_NONE) {
|
||||
if (read(pBuf, lBytes) == ERR_NONE) {
|
||||
// If this file is encrypted, then decrypt it
|
||||
if (m_lFlags & CDF_ENCRYPT) {
|
||||
DecryptPartial(pBuf, (int32)pRecInfo->m_lLength, (int32)lBytes, m_szPassWord);
|
||||
if (_lFlags & CDF_ENCRYPT) {
|
||||
DecryptPartial(pBuf, (int32)pRecInfo->_lLength, (int32)lBytes, _szPassWord);
|
||||
}
|
||||
|
||||
// Don't bother with a CRC as this chunk of input won't generate a proper
|
||||
// CRC anyway.
|
||||
} else {
|
||||
LogError(BuildString("Error reading record %ld in file '%s'", lRecNum, m_szFileName));
|
||||
LogError(BuildString("Error reading record %ld in file '%s'", lRecNum, _szFileName));
|
||||
_errCode = ERR_FREAD;
|
||||
}
|
||||
}
|
||||
@ -446,63 +446,63 @@ ErrorCode CBofDataFile::ReadFromFile(int32 lRecNum, void *pBuf, int32 lBytes) {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::WriteRecord(int32 lRecNum, void *pBuf, int32 lSize, bool bUpdateHeader, uint32 lKey) {
|
||||
ErrorCode CBofDataFile::writeRecord(int32 lRecNum, void *pBuf, int32 lSize, bool bUpdateHeader, uint32 lKey) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Only continue if there is no current error
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Validate record number
|
||||
Assert(lRecNum >= 0 && lRecNum < m_lNumRecs);
|
||||
Assert(lRecNum >= 0 && lRecNum < _lNumRecs);
|
||||
|
||||
// Validate input buffer
|
||||
Assert(pBuf != nullptr);
|
||||
|
||||
// There must already be a valid header
|
||||
Assert(m_pHeader != nullptr);
|
||||
Assert(_pHeader != nullptr);
|
||||
|
||||
if (lSize == -1)
|
||||
lSize = m_pHeader[(int)lRecNum].m_lLength;
|
||||
lSize = _pHeader[(int)lRecNum]._lLength;
|
||||
|
||||
int32 lPrevOffset = HEAD_INFO::size();
|
||||
int32 lPrevLength = 0;
|
||||
|
||||
if (lRecNum != 0) {
|
||||
lPrevOffset = m_pHeader[(int)lRecNum - 1].m_lOffset;
|
||||
lPrevLength = m_pHeader[(int)lRecNum - 1].m_lLength;
|
||||
lPrevOffset = _pHeader[(int)lRecNum - 1]._lOffset;
|
||||
lPrevLength = _pHeader[(int)lRecNum - 1]._lLength;
|
||||
}
|
||||
|
||||
HEADER_REC *pRecInfo = &m_pHeader[(int)lRecNum];
|
||||
HEADER_REC *pRecInfo = &_pHeader[(int)lRecNum];
|
||||
|
||||
// Header needs to updated
|
||||
m_bHeaderDirty = true;
|
||||
_bHeaderDirty = true;
|
||||
|
||||
if (_stream == nullptr) {
|
||||
open();
|
||||
}
|
||||
|
||||
// This record starts at the end of the last record
|
||||
pRecInfo->m_lOffset = lPrevOffset + lPrevLength;
|
||||
pRecInfo->_lOffset = lPrevOffset + lPrevLength;
|
||||
|
||||
// Seek to where we want to write this record
|
||||
Seek(pRecInfo->m_lOffset);
|
||||
Seek(pRecInfo->_lOffset);
|
||||
|
||||
// Calculate new hash code based on this records key
|
||||
pRecInfo->m_lKey = lKey;
|
||||
pRecInfo->_lKey = lKey;
|
||||
if (lKey == 0xFFFFFFFF) {
|
||||
pRecInfo->m_lKey = CreateHashCode((const byte *)pBuf);
|
||||
pRecInfo->_lKey = CreateHashCode((const byte *)pBuf);
|
||||
}
|
||||
|
||||
// Calculate this record's CRC value
|
||||
pRecInfo->m_lCrc = CalculateCRC(pBuf, lSize);
|
||||
pRecInfo->_lCrc = calculateCRC(pBuf, lSize);
|
||||
|
||||
if (m_lFlags & CDF_ENCRYPT) {
|
||||
Encrypt(pBuf, lSize, m_szPassWord);
|
||||
if (_lFlags & CDF_ENCRYPT) {
|
||||
Encrypt(pBuf, lSize, _szPassWord);
|
||||
}
|
||||
|
||||
// If new record is larger then original
|
||||
if (lSize > pRecInfo->m_lLength) {
|
||||
if (lSize > pRecInfo->_lLength) {
|
||||
// How many bytes back do we have to write?
|
||||
int32 lDiff = lSize - pRecInfo->m_lLength;
|
||||
int32 lDiff = lSize - pRecInfo->_lLength;
|
||||
|
||||
//
|
||||
// Move the rest of file back that many bytes
|
||||
@ -511,7 +511,7 @@ ErrorCode CBofDataFile::WriteRecord(int32 lRecNum, void *pBuf, int32 lSize, bool
|
||||
// Read the rest of the file in chunks (of 200k or less),
|
||||
// and write each chunk back in it's new position.
|
||||
//
|
||||
int32 lBufLength = GetLength() - (pRecInfo->m_lOffset + pRecInfo->m_lLength);
|
||||
int32 lBufLength = GetLength() - (pRecInfo->_lOffset + pRecInfo->_lLength);
|
||||
int32 lChunkSize = MIN(lBufLength, (int32)200000);
|
||||
|
||||
// Allocate a buffer big enough for one chunk
|
||||
@ -520,16 +520,16 @@ ErrorCode CBofDataFile::WriteRecord(int32 lRecNum, void *pBuf, int32 lSize, bool
|
||||
// While there is data to move
|
||||
while (lBufLength > 0) {
|
||||
// Seek to beginning of the source for this chunk
|
||||
setPosition(pRecInfo->m_lOffset + pRecInfo->m_lLength + lBufLength - lChunkSize);
|
||||
setPosition(pRecInfo->_lOffset + pRecInfo->_lLength + lBufLength - lChunkSize);
|
||||
|
||||
// Read the chunk
|
||||
Read(pTmpBuf, lChunkSize);
|
||||
read(pTmpBuf, lChunkSize);
|
||||
|
||||
// Seek to this chunks new positon (offset by 'lDiff' bytes)
|
||||
setPosition(pRecInfo->m_lOffset + pRecInfo->m_lLength + lBufLength - lChunkSize + lDiff);
|
||||
setPosition(pRecInfo->_lOffset + pRecInfo->_lLength + lBufLength - lChunkSize + lDiff);
|
||||
|
||||
// Write chunk to new position
|
||||
Write(pTmpBuf, lChunkSize);
|
||||
write(pTmpBuf, lChunkSize);
|
||||
|
||||
// That much less to do next time thru
|
||||
lBufLength -= lChunkSize;
|
||||
@ -542,44 +542,44 @@ ErrorCode CBofDataFile::WriteRecord(int32 lRecNum, void *pBuf, int32 lSize, bool
|
||||
BofFree(pTmpBuf);
|
||||
|
||||
} else {
|
||||
ReportError(ERR_MEMORY, "Unable to allocate %ld bytes to expand record size in WriteRecord()", lBufLength);
|
||||
ReportError(ERR_MEMORY, "Unable to allocate %ld bytes to expand record size in writeRecord()", lBufLength);
|
||||
}
|
||||
|
||||
// Tell the rest of the records that they moved
|
||||
for (int i = lRecNum + 1; i < GetNumberOfRecs(); i++) {
|
||||
m_pHeader[i].m_lOffset += lDiff;
|
||||
for (int i = lRecNum + 1; i < getNumberOfRecs(); i++) {
|
||||
_pHeader[i]._lOffset += lDiff;
|
||||
}
|
||||
|
||||
// Remember it's new length
|
||||
pRecInfo->m_lLength = lSize;
|
||||
pRecInfo->_lLength = lSize;
|
||||
|
||||
// Seek to where we want to write this record
|
||||
Seek(pRecInfo->m_lOffset);
|
||||
Seek(pRecInfo->_lOffset);
|
||||
|
||||
// Write this record
|
||||
Write(pBuf, lSize);
|
||||
write(pBuf, lSize);
|
||||
|
||||
// If we are to update the header now
|
||||
if (bUpdateHeader) {
|
||||
WriteHeader();
|
||||
writeHeader();
|
||||
}
|
||||
|
||||
} else {
|
||||
// Write this record
|
||||
if (Write(pBuf, lSize) == ERR_NONE) {
|
||||
if (write(pBuf, lSize) == ERR_NONE) {
|
||||
// If this record got smaller
|
||||
if (pRecInfo->m_lLength > lSize) {
|
||||
if (pRecInfo->_lLength > lSize) {
|
||||
// Remember it's length
|
||||
pRecInfo->m_lLength = lSize;
|
||||
pRecInfo->_lLength = lSize;
|
||||
|
||||
// Allocate a buffer that could hold the largest record
|
||||
byte *pTmpBuf = (byte *)BofAlloc((int)GetMaxRecSize());
|
||||
byte *pTmpBuf = (byte *)BofAlloc((int)getMaxRecSize());
|
||||
if (pTmpBuf != nullptr) {
|
||||
for (int i = (int)lRecNum + 1; i < (int)m_lNumRecs - 1; i++) {
|
||||
if ((_errCode = ReadRecord(i, pTmpBuf)) != ERR_NONE)
|
||||
for (int i = (int)lRecNum + 1; i < (int)_lNumRecs - 1; i++) {
|
||||
if ((_errCode = readRecord(i, pTmpBuf)) != ERR_NONE)
|
||||
break;
|
||||
|
||||
if ((_errCode = WriteRecord(i + 1, pTmpBuf)) != ERR_NONE)
|
||||
if ((_errCode = writeRecord(i + 1, pTmpBuf)) != ERR_NONE)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -592,7 +592,7 @@ ErrorCode CBofDataFile::WriteRecord(int32 lRecNum, void *pBuf, int32 lSize, bool
|
||||
|
||||
// If we are to update the header now
|
||||
if (bUpdateHeader) {
|
||||
WriteHeader();
|
||||
writeHeader();
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -601,25 +601,25 @@ ErrorCode CBofDataFile::WriteRecord(int32 lRecNum, void *pBuf, int32 lSize, bool
|
||||
}
|
||||
|
||||
// If this record is encrypted the decrypt it
|
||||
if (m_lFlags & CDF_ENCRYPT) {
|
||||
Decrypt(pBuf, (int)pRecInfo->m_lLength, m_szPassWord);
|
||||
if (_lFlags & CDF_ENCRYPT) {
|
||||
Decrypt(pBuf, (int)pRecInfo->_lLength, _szPassWord);
|
||||
}
|
||||
}
|
||||
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::VerifyRecord(int32 lRecNum) {
|
||||
ErrorCode CBofDataFile::verifyRecord(int32 lRecNum) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Validate record number
|
||||
Assert(lRecNum >= 0 && lRecNum < m_lNumRecs);
|
||||
Assert(lRecNum >= 0 && lRecNum < _lNumRecs);
|
||||
|
||||
// Allocate space to hold this record
|
||||
void *pBuf = BofAlloc((int)GetRecSize(lRecNum));
|
||||
void *pBuf = BofAlloc((int)getRecSize(lRecNum));
|
||||
if (pBuf != nullptr) {
|
||||
_errCode = ReadRecord(lRecNum, pBuf);
|
||||
_errCode = readRecord(lRecNum, pBuf);
|
||||
BofFree(pBuf);
|
||||
|
||||
} else {
|
||||
@ -630,13 +630,13 @@ ErrorCode CBofDataFile::VerifyRecord(int32 lRecNum) {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::VerifyAllRecords() {
|
||||
ErrorCode CBofDataFile::verifyAllRecords() {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
if (_errCode == ERR_NONE) {
|
||||
int32 n = GetNumberOfRecs();
|
||||
int32 n = getNumberOfRecs();
|
||||
for (int32 i = 0; i < n; i++) {
|
||||
if ((_errCode = VerifyRecord(i)) != ERR_NONE) {
|
||||
if ((_errCode = verifyRecord(i)) != ERR_NONE) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -645,7 +645,7 @@ ErrorCode CBofDataFile::VerifyAllRecords() {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::AddRecord(void *pBuf, int32 lLength, bool bUpdateHeader, uint32 lKey) {
|
||||
ErrorCode CBofDataFile::addRecord(void *pBuf, int32 lLength, bool bUpdateHeader, uint32 lKey) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Only continue if there is no current error
|
||||
@ -661,32 +661,32 @@ ErrorCode CBofDataFile::AddRecord(void *pBuf, int32 lLength, bool bUpdateHeader,
|
||||
}
|
||||
|
||||
if (_errCode == ERR_NONE) {
|
||||
m_lNumRecs++;
|
||||
_lNumRecs++;
|
||||
|
||||
HEADER_REC *pTmpHeader = new HEADER_REC[(int)m_lNumRecs];
|
||||
HEADER_REC *pTmpHeader = new HEADER_REC[(int)_lNumRecs];
|
||||
if (pTmpHeader != nullptr) {
|
||||
if (m_pHeader != nullptr) {
|
||||
BofMemCopy(pTmpHeader, m_pHeader, (size_t)(HEADER_REC::size() * (m_lNumRecs - 1)));
|
||||
if (_pHeader != nullptr) {
|
||||
BofMemCopy(pTmpHeader, _pHeader, (size_t)(HEADER_REC::size() * (_lNumRecs - 1)));
|
||||
|
||||
delete[] m_pHeader;
|
||||
delete[] _pHeader;
|
||||
}
|
||||
|
||||
m_pHeader = pTmpHeader;
|
||||
_pHeader = pTmpHeader;
|
||||
|
||||
int32 lRecNum = m_lNumRecs - 1;
|
||||
HEADER_REC *pCurRec = &m_pHeader[lRecNum];
|
||||
int32 lRecNum = _lNumRecs - 1;
|
||||
HEADER_REC *pCurRec = &_pHeader[lRecNum];
|
||||
int32 lPrevLength = HEAD_INFO::size();
|
||||
int32 lPrevOffset = 0;
|
||||
|
||||
if (lRecNum != 0) {
|
||||
lPrevLength = m_pHeader[lRecNum - 1].m_lLength;
|
||||
lPrevOffset = m_pHeader[lRecNum - 1].m_lOffset;
|
||||
lPrevLength = _pHeader[lRecNum - 1]._lLength;
|
||||
lPrevOffset = _pHeader[lRecNum - 1]._lOffset;
|
||||
}
|
||||
|
||||
pCurRec->m_lLength = lLength;
|
||||
pCurRec->m_lOffset = lPrevOffset + lPrevLength;
|
||||
pCurRec->_lLength = lLength;
|
||||
pCurRec->_lOffset = lPrevOffset + lPrevLength;
|
||||
|
||||
WriteRecord(lRecNum, pBuf, lLength, bUpdateHeader, lKey);
|
||||
writeRecord(lRecNum, pBuf, lLength, bUpdateHeader, lKey);
|
||||
|
||||
} else {
|
||||
ReportError(ERR_MEMORY, "Could not allocate a data file header");
|
||||
@ -698,7 +698,7 @@ ErrorCode CBofDataFile::AddRecord(void *pBuf, int32 lLength, bool bUpdateHeader,
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::DeleteRecord(int32 lRecNum, bool bUpdateHeader) {
|
||||
ErrorCode CBofDataFile::deleteRecord(int32 lRecNum, bool bUpdateHeader) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
//
|
||||
@ -708,20 +708,20 @@ ErrorCode CBofDataFile::DeleteRecord(int32 lRecNum, bool bUpdateHeader) {
|
||||
// Only continue if there is no current error
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Validate record number
|
||||
Assert(lRecNum >= 0 && lRecNum < m_lNumRecs);
|
||||
Assert(lRecNum >= 0 && lRecNum < _lNumRecs);
|
||||
|
||||
m_bHeaderDirty = true;
|
||||
_bHeaderDirty = true;
|
||||
|
||||
// Header has moved
|
||||
m_lHeaderStart -= m_pHeader[(int)lRecNum].m_lLength;
|
||||
_lHeaderStart -= _pHeader[(int)lRecNum]._lLength;
|
||||
|
||||
// Header has changed size
|
||||
BofMemMove(m_pHeader + lRecNum, m_pHeader + lRecNum + 1, (size_t)((m_lNumRecs - lRecNum - 1) * HEADER_REC::size()));
|
||||
BofMemMove(_pHeader + lRecNum, _pHeader + lRecNum + 1, (size_t)((_lNumRecs - lRecNum - 1) * HEADER_REC::size()));
|
||||
|
||||
// On less record
|
||||
m_lNumRecs--;
|
||||
_lNumRecs--;
|
||||
|
||||
m_lHeaderLength = m_lNumRecs * HEADER_REC::size();
|
||||
_lHeaderLength = _lNumRecs * HEADER_REC::size();
|
||||
|
||||
// Open the data file if it's not already
|
||||
if (_stream == nullptr) {
|
||||
@ -730,20 +730,20 @@ ErrorCode CBofDataFile::DeleteRecord(int32 lRecNum, bool bUpdateHeader) {
|
||||
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Allocate a buffer that could hold the largest record
|
||||
byte *pBuf = (byte *)BofAlloc((int)GetMaxRecSize());
|
||||
byte *pBuf = (byte *)BofAlloc((int)getMaxRecSize());
|
||||
if (pBuf != nullptr) {
|
||||
// Remove this record from the file
|
||||
for (int i = (int)lRecNum; i < (int)m_lNumRecs - 1; i++) {
|
||||
if ((_errCode = ReadRecord(i + 1, pBuf)) != ERR_NONE)
|
||||
for (int i = (int)lRecNum; i < (int)_lNumRecs - 1; i++) {
|
||||
if ((_errCode = readRecord(i + 1, pBuf)) != ERR_NONE)
|
||||
break;
|
||||
|
||||
if ((_errCode = WriteRecord(i, pBuf)) != ERR_NONE)
|
||||
if ((_errCode = writeRecord(i, pBuf)) != ERR_NONE)
|
||||
break;
|
||||
}
|
||||
|
||||
// If we are to update the header now
|
||||
if (bUpdateHeader) {
|
||||
WriteHeader();
|
||||
writeHeader();
|
||||
}
|
||||
|
||||
BofFree(pBuf);
|
||||
@ -757,7 +757,7 @@ ErrorCode CBofDataFile::DeleteRecord(int32 lRecNum, bool bUpdateHeader) {
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
int32 CBofDataFile::FindRecord(uint32 lKey) {
|
||||
int32 CBofDataFile::findRecord(uint32 lKey) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
// Assume no match
|
||||
@ -766,11 +766,11 @@ int32 CBofDataFile::FindRecord(uint32 lKey) {
|
||||
// Only continue if there is no current error
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Scan the header for the key matching the hash code
|
||||
for (int32 i = 0; i < m_lNumRecs; i++) {
|
||||
for (int32 i = 0; i < _lNumRecs; i++) {
|
||||
// Header records must be valid
|
||||
Assert(m_pHeader != nullptr);
|
||||
Assert(_pHeader != nullptr);
|
||||
|
||||
if (m_pHeader[i].m_lKey == lKey) {
|
||||
if (_pHeader[i]._lKey == lKey) {
|
||||
lRecNum = i;
|
||||
break;
|
||||
}
|
||||
@ -780,7 +780,7 @@ int32 CBofDataFile::FindRecord(uint32 lKey) {
|
||||
return lRecNum;
|
||||
}
|
||||
|
||||
int32 CBofDataFile::GetRecSize(int32 lRecNum) {
|
||||
int32 CBofDataFile::getRecSize(int32 lRecNum) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
int32 lSize = -1;
|
||||
@ -788,17 +788,17 @@ int32 CBofDataFile::GetRecSize(int32 lRecNum) {
|
||||
// Only continue if there is no current error
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Validate record number
|
||||
Assert(lRecNum >= 0 && lRecNum < m_lNumRecs);
|
||||
Assert(lRecNum >= 0 && lRecNum < _lNumRecs);
|
||||
|
||||
Assert(m_pHeader != nullptr);
|
||||
Assert(_pHeader != nullptr);
|
||||
|
||||
lSize = m_pHeader[lRecNum].m_lLength;
|
||||
lSize = _pHeader[lRecNum]._lLength;
|
||||
}
|
||||
|
||||
return lSize;
|
||||
}
|
||||
|
||||
int32 CBofDataFile::GetMaxRecSize() const {
|
||||
int32 CBofDataFile::getMaxRecSize() const {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
int32 lLargest = -1;
|
||||
@ -806,34 +806,34 @@ int32 CBofDataFile::GetMaxRecSize() const {
|
||||
// Only continue if there is no current error
|
||||
if (_errCode == ERR_NONE) {
|
||||
// Validate header
|
||||
Assert(m_pHeader != nullptr);
|
||||
Assert(_pHeader != nullptr);
|
||||
|
||||
for (int i = 0; i < (int)m_lNumRecs; i++) {
|
||||
lLargest = MAX(lLargest, m_pHeader[i].m_lLength);
|
||||
for (int i = 0; i < (int)_lNumRecs; i++) {
|
||||
lLargest = MAX(lLargest, _pHeader[i]._lLength);
|
||||
}
|
||||
}
|
||||
|
||||
return lLargest;
|
||||
}
|
||||
|
||||
void CBofDataFile::SetPassword(const char *pszPassword) {
|
||||
void CBofDataFile::setPassword(const char *pszPassword) {
|
||||
Assert(IsValidObject(this));
|
||||
m_szPassWord[0] = '\0';
|
||||
_szPassWord[0] = '\0';
|
||||
|
||||
if (pszPassword != nullptr) {
|
||||
Assert(strlen(pszPassword) < MAX_PW_LEN);
|
||||
|
||||
Common::strcpy_s(m_szPassWord, pszPassword);
|
||||
Common::strcpy_s(_szPassWord, pszPassword);
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::Read(void *pDestBuf, int32 lBytes) {
|
||||
return CBofFile::Read(pDestBuf, lBytes);
|
||||
ErrorCode CBofDataFile::read(void *pDestBuf, int32 lBytes) {
|
||||
return CBofFile::read(pDestBuf, lBytes);
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::Read(HEAD_INFO &rec) {
|
||||
ErrorCode CBofDataFile::read(HEAD_INFO &rec) {
|
||||
byte buf[16];
|
||||
ErrorCode result = Read(&buf[0], 16);
|
||||
ErrorCode result = read(&buf[0], 16);
|
||||
|
||||
Common::MemoryReadStream mem(buf, 16);
|
||||
Common::Serializer s(&mem, nullptr);
|
||||
@ -842,9 +842,9 @@ ErrorCode CBofDataFile::Read(HEAD_INFO &rec) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::Read(HEADER_REC &rec) {
|
||||
ErrorCode CBofDataFile::read(HEADER_REC &rec) {
|
||||
byte buf[16];
|
||||
ErrorCode result = Read(&buf[0], 16);
|
||||
ErrorCode result = read(&buf[0], 16);
|
||||
|
||||
Common::MemoryReadStream mem(buf, 16);
|
||||
Common::Serializer s(&mem, nullptr);
|
||||
@ -853,28 +853,28 @@ ErrorCode CBofDataFile::Read(HEADER_REC &rec) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::Write(const void *pSrcBuf, int32 lBytes) {
|
||||
return CBofFile::Write(pSrcBuf, lBytes);
|
||||
ErrorCode CBofDataFile::write(const void *pSrcBuf, int32 lBytes) {
|
||||
return CBofFile::write(pSrcBuf, lBytes);
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::Write(HEAD_INFO &rec) {
|
||||
ErrorCode CBofDataFile::write(HEAD_INFO &rec) {
|
||||
byte buf[16];
|
||||
|
||||
Common::MemoryWriteStream mem(buf, 16);
|
||||
Common::Serializer s(nullptr, &mem);
|
||||
rec.synchronize(s);
|
||||
|
||||
return Write(&buf[0], 16);
|
||||
return write(&buf[0], 16);
|
||||
}
|
||||
|
||||
ErrorCode CBofDataFile::Write(HEADER_REC &rec) {
|
||||
ErrorCode CBofDataFile::write(HEADER_REC &rec) {
|
||||
byte buf[16];
|
||||
|
||||
Common::MemoryWriteStream mem(buf, 16);
|
||||
Common::Serializer s(nullptr, &mem);
|
||||
rec.synchronize(s);
|
||||
|
||||
return Write(&buf[0], 16);
|
||||
return write(&buf[0], 16);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -893,19 +893,19 @@ uint32 CreateHashCode(const byte *pKey) {
|
||||
|
||||
void SwapHeadInfo(HEAD_INFO *stHI) {
|
||||
// Macintosh is big endian, so we must swap our bytes
|
||||
stHI->m_lNumRecs = SWAPLONG(stHI->m_lNumRecs);
|
||||
stHI->m_lAddress = SWAPLONG(stHI->m_lAddress);
|
||||
stHI->m_lFlags = SWAPLONG(stHI->m_lFlags);
|
||||
stHI->m_lFootCrc = SWAPLONG(stHI->m_lFootCrc);
|
||||
stHI->_lNumRecs = SWAPLONG(stHI->_lNumRecs);
|
||||
stHI->_lAddress = SWAPLONG(stHI->_lAddress);
|
||||
stHI->_lFlags = SWAPLONG(stHI->_lFlags);
|
||||
stHI->_lFootCrc = SWAPLONG(stHI->_lFootCrc);
|
||||
}
|
||||
|
||||
void SwapHeaderRec(HEADER_REC *stHR, int nRecords) {
|
||||
HEADER_REC *p = stHR;
|
||||
for (int i = 0; i < nRecords; i++) {
|
||||
p->m_lOffset = SWAPLONG(p->m_lOffset);
|
||||
p->m_lLength = SWAPLONG(p->m_lLength);
|
||||
p->m_lCrc = SWAPLONG(p->m_lCrc);
|
||||
p->m_lKey = SWAPLONG(p->m_lKey);
|
||||
p->_lOffset = SWAPLONG(p->_lOffset);
|
||||
p->_lLength = SWAPLONG(p->_lLength);
|
||||
p->_lCrc = SWAPLONG(p->_lCrc);
|
||||
p->_lKey = SWAPLONG(p->_lKey);
|
||||
|
||||
p++;
|
||||
}
|
||||
|
@ -48,20 +48,20 @@ namespace Bagel {
|
||||
|
||||
struct HEADER_REC {
|
||||
public:
|
||||
int32 m_lOffset;
|
||||
int32 m_lLength;
|
||||
uint32 m_lCrc;
|
||||
uint32 m_lKey;
|
||||
int32 _lOffset;
|
||||
int32 _lLength;
|
||||
uint32 _lCrc;
|
||||
uint32 _lKey;
|
||||
|
||||
void synchronize(Common::Serializer &s);
|
||||
static int size() { return 16; }
|
||||
};
|
||||
|
||||
struct HEAD_INFO {
|
||||
int32 m_lNumRecs; // Number of records in this file
|
||||
int32 m_lAddress; // starting address of footer
|
||||
uint32 m_lFlags; // contains flags for this file
|
||||
uint32 m_lFootCrc; // CRC of the footer
|
||||
int32 _lNumRecs; // Number of records in this file
|
||||
int32 _lAddress; // starting address of footer
|
||||
uint32 _lFlags; // contains flags for this file
|
||||
uint32 _lFootCrc; // CRC of the footer
|
||||
|
||||
void synchronize(Common::Serializer &s);
|
||||
static int size() { return 16; }
|
||||
@ -69,26 +69,26 @@ struct HEAD_INFO {
|
||||
|
||||
class CBofDataFile : public CBofFile {
|
||||
private:
|
||||
char m_szPassWord[MAX_PW_LEN];
|
||||
int32 m_lHeaderLength = 0;
|
||||
int32 m_lHeaderStart = 0;
|
||||
int32 m_lNumRecs = 0;
|
||||
HEADER_REC *m_pHeader = nullptr;
|
||||
char _szPassWord[MAX_PW_LEN];
|
||||
int32 _lHeaderLength = 0;
|
||||
int32 _lHeaderStart = 0;
|
||||
int32 _lNumRecs = 0;
|
||||
HEADER_REC *_pHeader = nullptr;
|
||||
|
||||
bool m_bHeaderDirty;
|
||||
bool _bHeaderDirty;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Read the header (actually a footer) from the data-file.
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode ReadHeader();
|
||||
ErrorCode readHeader();
|
||||
|
||||
/**
|
||||
* Writes the header (actually a footer) to the data-file.
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode WriteHeader();
|
||||
ErrorCode writeHeader();
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -117,29 +117,29 @@ public:
|
||||
* @param pPassword Password for encryption
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode SetFile(const char *pszFileName, uint32 lFlags = CDF_DEFAULT, const char *pPassword = nullptr);
|
||||
ErrorCode setFile(const char *pszFileName, uint32 lFlags = CDF_DEFAULT, const char *pPassword = nullptr);
|
||||
|
||||
/**
|
||||
* Free memory used by this object
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode ReleaseFile();
|
||||
ErrorCode releaseFile();
|
||||
|
||||
/**
|
||||
* Retrieves size of specified record.
|
||||
* @param lRecNum Index of record to get size of
|
||||
* @return Size of specified record
|
||||
*/
|
||||
int32 GetRecSize(int32 lRecNum);
|
||||
int32 GetNumberOfRecs() const {
|
||||
return m_lNumRecs;
|
||||
int32 getRecSize(int32 lRecNum);
|
||||
int32 getNumberOfRecs() const {
|
||||
return _lNumRecs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves size of the largest record.
|
||||
* @return Size of largest record in the data-file
|
||||
*/
|
||||
int32 GetMaxRecSize() const;
|
||||
int32 getMaxRecSize() const;
|
||||
|
||||
/**
|
||||
* Opens an existing data-file, or creates a new one.
|
||||
@ -165,14 +165,14 @@ public:
|
||||
* @param pBuf Buffer to store record
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode ReadRecord(int32 lRecNum, void *pBuf);
|
||||
ErrorCode readRecord(int32 lRecNum, void *pBuf);
|
||||
|
||||
/**
|
||||
* Read a set number of bytes from the beginning of a file,
|
||||
* don't bother with a CRC, but decrypt if necessary. This is dependent upon
|
||||
* the decryption being based on a single byte ordering scheme.
|
||||
*/
|
||||
ErrorCode ReadFromFile(int32 lRecNum, void *pBuf, int32 lBytes);
|
||||
ErrorCode readFromFile(int32 lRecNum, void *pBuf, int32 lBytes);
|
||||
|
||||
/**
|
||||
* Writes specified to data-file.
|
||||
@ -182,20 +182,20 @@ public:
|
||||
* @param bUpdateHeader true if header is to be committed to disk
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode WriteRecord(int32 lRecNum, void *pBuf, int32 lRecSize = -1, bool bUpdateHeader = false, uint32 lKey = 0xFFFFFFFF);
|
||||
ErrorCode writeRecord(int32 lRecNum, void *pBuf, int32 lRecSize = -1, bool bUpdateHeader = false, uint32 lKey = 0xFFFFFFFF);
|
||||
|
||||
/**
|
||||
* Verifies specified record in data-file.
|
||||
* @param lRecNum Record number to verify
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode VerifyRecord(int32 lRecNum);
|
||||
ErrorCode verifyRecord(int32 lRecNum);
|
||||
|
||||
/**
|
||||
* Verifies all records in this file
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode VerifyAllRecords();
|
||||
ErrorCode verifyAllRecords();
|
||||
|
||||
/**
|
||||
* Adds a new record to the data-file.
|
||||
@ -205,7 +205,7 @@ public:
|
||||
* @param key Key
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode AddRecord(void *pBuf, int32 lRecSize, bool bUpdateHeader = false, uint32 lKey = 0xFFFFFFFF);
|
||||
ErrorCode addRecord(void *pBuf, int32 lRecSize, bool bUpdateHeader = false, uint32 lKey = 0xFFFFFFFF);
|
||||
|
||||
/**
|
||||
* Deletes specified record from data-file.
|
||||
@ -213,22 +213,22 @@ public:
|
||||
* @param bUpdateHeader true if header is to be committed to disk
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode DeleteRecord(int32 lRecNum, bool bUpdateHeader = false);
|
||||
ErrorCode deleteRecord(int32 lRecNum, bool bUpdateHeader = false);
|
||||
|
||||
/**
|
||||
* Finds record by it's key.
|
||||
* @param lKey Key to search records with
|
||||
* @return Index of record matching key, or -1
|
||||
*/
|
||||
int32 FindRecord(uint32 lKey);
|
||||
int32 findRecord(uint32 lKey);
|
||||
|
||||
/**
|
||||
* Sets encryption password
|
||||
* @param pszPassword New password
|
||||
*/
|
||||
void SetPassword(const char *pszPassword);
|
||||
const char *GetPassword() const {
|
||||
return m_szPassWord;
|
||||
void setPassword(const char *pszPassword);
|
||||
const char *getPassword() const {
|
||||
return _szPassWord;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -237,9 +237,9 @@ public:
|
||||
* @param lBytes Number of bytes
|
||||
* @return Error code
|
||||
*/
|
||||
ErrorCode Read(void *pDestBuf, int32 lBytes);
|
||||
ErrorCode Read(HEADER_REC &rec);
|
||||
ErrorCode Read(HEAD_INFO &rec);
|
||||
ErrorCode read(void *pDestBuf, int32 lBytes);
|
||||
ErrorCode read(HEADER_REC &rec);
|
||||
ErrorCode read(HEAD_INFO &rec);
|
||||
|
||||
/**
|
||||
* Write to a currently open file
|
||||
@ -247,9 +247,9 @@ public:
|
||||
* @param lBytes Number of bytes
|
||||
* @return Error code
|
||||
*/
|
||||
ErrorCode Write(const void *pSrcBuf, int32 lBytes);
|
||||
ErrorCode Write(HEADER_REC &rec);
|
||||
ErrorCode Write(HEAD_INFO &rec);
|
||||
ErrorCode write(const void *pSrcBuf, int32 lBytes);
|
||||
ErrorCode write(HEADER_REC &rec);
|
||||
ErrorCode write(HEAD_INFO &rec);
|
||||
};
|
||||
|
||||
} // namespace Bagel
|
||||
|
@ -39,12 +39,12 @@ CBofDebugOptions::CBofDebugOptions(const char *pszFileName) : CBofOptions(pszFil
|
||||
ConfMan.registerDefault("MessageSpy", false);
|
||||
|
||||
|
||||
ReadSetting("DebugOptions", "AbortsOn", &m_bAbortsOn, ConfMan.getBool("AbortsOn"));
|
||||
ReadSetting("DebugOptions", "MessageBoxOn", &m_bMessageBoxOn, ConfMan.getBool("MessageBoxOn"));
|
||||
ReadSetting("DebugOptions", "RandomOn", &m_bRandomOn, ConfMan.getBool("RandomOn"));
|
||||
ReadSetting("DebugOptions", "DebugLevel", &m_nDebugLevel, ConfMan.getInt("DebugLevel"));
|
||||
ReadSetting("DebugOptions", "ShowIO", &m_bShowIO, ConfMan.getBool("ShowIO"));
|
||||
ReadSetting("DebugOptions", "MessageSpy", &m_bShowMessages, ConfMan.getBool("MessageSpy"));
|
||||
readSetting("DebugOptions", "AbortsOn", &_bAbortsOn, ConfMan.getBool("AbortsOn"));
|
||||
readSetting("DebugOptions", "MessageBoxOn", &_bMessageBoxOn, ConfMan.getBool("MessageBoxOn"));
|
||||
readSetting("DebugOptions", "RandomOn", &_bRandomOn, ConfMan.getBool("RandomOn"));
|
||||
readSetting("DebugOptions", "DebugLevel", &_nDebugLevel, ConfMan.getInt("DebugLevel"));
|
||||
readSetting("DebugOptions", "ShowIO", &_bShowIO, ConfMan.getBool("ShowIO"));
|
||||
readSetting("DebugOptions", "MessageSpy", &_bShowMessages, ConfMan.getBool("MessageSpy"));
|
||||
}
|
||||
|
||||
void BofAssert(bool bExpression, int nLine, const char *pszSourceFile, const char *pszTimeStamp) {
|
||||
|
@ -38,12 +38,12 @@ public:
|
||||
*/
|
||||
CBofDebugOptions(const char *pszFileName);
|
||||
|
||||
int m_nDebugLevel;
|
||||
bool m_bAbortsOn;
|
||||
bool m_bMessageBoxOn;
|
||||
bool m_bRandomOn;
|
||||
bool m_bShowIO;
|
||||
bool m_bShowMessages;
|
||||
int _nDebugLevel;
|
||||
bool _bAbortsOn;
|
||||
bool _bMessageBoxOn;
|
||||
bool _bRandomOn;
|
||||
bool _bShowIO;
|
||||
bool _bShowMessages;
|
||||
};
|
||||
|
||||
extern CBofDebugOptions *g_pDebugOptions;
|
||||
|
@ -31,11 +31,11 @@ namespace Bagel {
|
||||
#define CHUNK_SIZE 0x00007FFF
|
||||
|
||||
CBofFile::CBofFile() {
|
||||
m_szFileName[0] = '\0';
|
||||
_szFileName[0] = '\0';
|
||||
}
|
||||
|
||||
CBofFile::CBofFile(const char *pszFileName, uint32 lFlags) {
|
||||
m_szFileName[0] = '\0';
|
||||
_szFileName[0] = '\0';
|
||||
Assert(pszFileName != nullptr);
|
||||
|
||||
// Open now?
|
||||
@ -59,22 +59,22 @@ ErrorCode CBofFile::create(const char *pszFileName, uint32 lFlags) {
|
||||
// Can't create a read-only file
|
||||
Assert(!(lFlags & CBF_READONLY));
|
||||
|
||||
m_lFlags = lFlags;
|
||||
_lFlags = lFlags;
|
||||
|
||||
// Remember this files name
|
||||
Common::strcpy_s(m_szFileName, pszFileName);
|
||||
Common::strcpy_s(_szFileName, pszFileName);
|
||||
|
||||
// Create the file
|
||||
Common::OutSaveFile *save = g_system->getSavefileManager()->openForSaving(pszFileName, false);
|
||||
if (save != nullptr) {
|
||||
_stream = new SaveReadWriteStream(save);
|
||||
|
||||
if (g_pDebugOptions != nullptr && g_pDebugOptions->m_bShowIO) {
|
||||
LogInfo(BuildString("Creating file '%s'", m_szFileName));
|
||||
if (g_pDebugOptions != nullptr && g_pDebugOptions->_bShowIO) {
|
||||
LogInfo(BuildString("Creating file '%s'", _szFileName));
|
||||
}
|
||||
|
||||
} else {
|
||||
ReportError(ERR_FOPEN, "Unable to create %s", m_szFileName);
|
||||
ReportError(ERR_FOPEN, "Unable to create %s", _szFileName);
|
||||
}
|
||||
|
||||
return _errCode;
|
||||
@ -96,7 +96,7 @@ ErrorCode CBofFile::open(const char *pszFileName, uint32 lFlags) {
|
||||
Assert(!((lFlags & CBF_READONLY) && (lFlags & CBF_CREATE)));
|
||||
|
||||
// Keep a copy of these flags
|
||||
m_lFlags = lFlags;
|
||||
_lFlags = lFlags;
|
||||
|
||||
if (_stream)
|
||||
return _errCode;
|
||||
@ -107,7 +107,7 @@ ErrorCode CBofFile::open(const char *pszFileName, uint32 lFlags) {
|
||||
|
||||
} else {
|
||||
// Remember this files' name
|
||||
Common::strcpy_s(m_szFileName, pszFileName);
|
||||
Common::strcpy_s(_szFileName, pszFileName);
|
||||
|
||||
if (lFlags & CBF_SAVEFILE) {
|
||||
_stream = g_system->getSavefileManager()->openForLoading(pszFileName);
|
||||
@ -121,8 +121,8 @@ ErrorCode CBofFile::open(const char *pszFileName, uint32 lFlags) {
|
||||
if (f->open(pszFileName)) {
|
||||
_stream = f;
|
||||
|
||||
if (g_pDebugOptions != nullptr && g_pDebugOptions->m_bShowIO) {
|
||||
LogInfo(BuildString("Opened file '%s'", m_szFileName));
|
||||
if (g_pDebugOptions != nullptr && g_pDebugOptions->_bShowIO) {
|
||||
LogInfo(BuildString("Opened file '%s'", _szFileName));
|
||||
}
|
||||
} else {
|
||||
delete f;
|
||||
@ -138,8 +138,8 @@ void CBofFile::close() {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
if (_stream != nullptr) {
|
||||
if (g_pDebugOptions != nullptr && g_pDebugOptions->m_bShowIO) {
|
||||
LogInfo(BuildString("Closed file '%s'", m_szFileName));
|
||||
if (g_pDebugOptions != nullptr && g_pDebugOptions->_bShowIO) {
|
||||
LogInfo(BuildString("Closed file '%s'", _szFileName));
|
||||
}
|
||||
|
||||
delete _stream;
|
||||
@ -147,7 +147,7 @@ void CBofFile::close() {
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCode CBofFile::Read(void *pDestBuf, int32 lBytes) {
|
||||
ErrorCode CBofFile::read(void *pDestBuf, int32 lBytes) {
|
||||
Assert(IsValidObject(this));
|
||||
Assert(pDestBuf != nullptr);
|
||||
Assert(lBytes >= 0);
|
||||
@ -164,28 +164,28 @@ ErrorCode CBofFile::Read(void *pDestBuf, int32 lBytes) {
|
||||
lBytes -= CHUNK_SIZE;
|
||||
|
||||
if ((int)rs->read(pBuf, nLength) != nLength) {
|
||||
ReportError(ERR_FREAD, "Unable to read %d bytes from %s", nLength, m_szFileName);
|
||||
ReportError(ERR_FREAD, "Unable to read %d bytes from %s", nLength, _szFileName);
|
||||
}
|
||||
|
||||
pBuf += nLength;
|
||||
}
|
||||
|
||||
} else {
|
||||
error("Attempt to read from a file that is not open for reading: %s", m_szFileName);
|
||||
error("Attempt to read from a file that is not open for reading: %s", _szFileName);
|
||||
}
|
||||
}
|
||||
|
||||
return _errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofFile::Write(const void *pSrcBuf, int32 lBytes) {
|
||||
ErrorCode CBofFile::write(const void *pSrcBuf, int32 lBytes) {
|
||||
Assert(IsValidObject(this));
|
||||
|
||||
Common::WriteStream *ws = dynamic_cast<Common::WriteStream *>(_stream);
|
||||
|
||||
if (ws != nullptr) {
|
||||
// As long as this file is not set for readonly, then write the buffer
|
||||
if (!(m_lFlags & CBF_READONLY)) {
|
||||
if (!(_lFlags & CBF_READONLY)) {
|
||||
const byte *pBuf = (const byte *)pSrcBuf;
|
||||
|
||||
while (lBytes > 0) {
|
||||
@ -193,7 +193,7 @@ ErrorCode CBofFile::Write(const void *pSrcBuf, int32 lBytes) {
|
||||
lBytes -= CHUNK_SIZE;
|
||||
|
||||
if ((int)ws->write(pBuf, nLength) != nLength) {
|
||||
ReportError(ERR_FWRITE, "Unable to write %d bytes to %s", nLength, m_szFileName);
|
||||
ReportError(ERR_FWRITE, "Unable to write %d bytes to %s", nLength, _szFileName);
|
||||
}
|
||||
|
||||
pBuf += nLength;
|
||||
@ -203,7 +203,7 @@ ErrorCode CBofFile::Write(const void *pSrcBuf, int32 lBytes) {
|
||||
Commit();
|
||||
|
||||
} else {
|
||||
LogWarning(BuildString("Attempted to write to the READONLY file '%s'", m_szFileName));
|
||||
LogWarning(BuildString("Attempted to write to the READONLY file '%s'", _szFileName));
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -97,9 +97,9 @@ public:
|
||||
|
||||
class CBofFile : public CBofObject, public CBofError {
|
||||
protected:
|
||||
char m_szFileName[MAX_FNAME];
|
||||
char _szFileName[MAX_FNAME];
|
||||
Common::Stream *_stream = nullptr;
|
||||
uint32 m_lFlags = CBF_DEFAULT;
|
||||
uint32 _lFlags = CBF_DEFAULT;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -144,7 +144,7 @@ public:
|
||||
* @param lBytes Number of bytes
|
||||
* @return Error code
|
||||
*/
|
||||
ErrorCode Read(void *pDestBuf, int32 lBytes);
|
||||
ErrorCode read(void *pDestBuf, int32 lBytes);
|
||||
|
||||
/**
|
||||
* Write to a currently open file
|
||||
@ -152,7 +152,7 @@ public:
|
||||
* @param lBytes Number of bytes
|
||||
* @return Error code
|
||||
*/
|
||||
ErrorCode Write(const void *pSrcBuf, int32 lBytes);
|
||||
ErrorCode write(const void *pSrcBuf, int32 lBytes);
|
||||
|
||||
/**
|
||||
* Flushes I/O stream
|
||||
|
@ -125,7 +125,7 @@ void BofMemCopy(void *pDst, const void *pSrc, int32 lLength) {
|
||||
}
|
||||
}
|
||||
|
||||
bool ReadLine(Common::SeekableReadStream *fp, char *pszBuf) {
|
||||
bool readLine(Common::SeekableReadStream *fp, char *pszBuf) {
|
||||
if (fp->eos())
|
||||
return false;
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace Bagel {
|
||||
#define USE_REGISTRY 1
|
||||
|
||||
CBofOptions::CBofOptions(const char *pszOptionFile) {
|
||||
m_szFileName[0] = '\0';
|
||||
_szFileName[0] = '\0';
|
||||
m_pOptionList = nullptr;
|
||||
m_bDirty = false;
|
||||
|
||||
@ -45,7 +45,7 @@ CBofOptions::~CBofOptions() {
|
||||
|
||||
release();
|
||||
|
||||
m_szFileName[0] = '\0';
|
||||
_szFileName[0] = '\0';
|
||||
}
|
||||
|
||||
ErrorCode CBofOptions::LoadOptionFile(const char *pszOptionFile) {
|
||||
@ -57,7 +57,7 @@ ErrorCode CBofOptions::LoadOptionFile(const char *pszOptionFile) {
|
||||
|
||||
release();
|
||||
|
||||
Common::strcpy_s(m_szFileName, pszOptionFile);
|
||||
Common::strcpy_s(_szFileName, pszOptionFile);
|
||||
|
||||
return Load();
|
||||
}
|
||||
@ -72,12 +72,12 @@ ErrorCode CBofOptions::Load() {
|
||||
release();
|
||||
|
||||
Common::File f;
|
||||
if (Common::File::exists(m_szFileName) && f.open(m_szFileName)) {
|
||||
if (Common::File::exists(_szFileName) && f.open(_szFileName)) {
|
||||
char szBuf[MAX_OPTION_LEN];
|
||||
|
||||
Assert(m_pOptionList == nullptr);
|
||||
|
||||
while (ReadLine(&f, szBuf)) {
|
||||
while (readLine(&f, szBuf)) {
|
||||
COption *pNewOption = new COption(szBuf);
|
||||
if (pNewOption != nullptr) {
|
||||
if (m_pOptionList != nullptr) {
|
||||
@ -207,7 +207,7 @@ ErrorCode CBofOptions::WriteSetting(const char *pszSection, const char *pszVar,
|
||||
return errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofOptions::ReadSetting(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 maxLen) {
|
||||
ErrorCode CBofOptions::readSetting(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 maxLen) {
|
||||
// Can't access nullptr pointers
|
||||
Assert(section != nullptr);
|
||||
Assert(option != nullptr);
|
||||
@ -251,7 +251,7 @@ ErrorCode CBofOptions::ReadSetting(const char *section, const char *option, char
|
||||
Common::strcpy_s(stringValue, maxLen, p);
|
||||
|
||||
} else {
|
||||
LogError(BuildString("Error in %s, section: %s, entry: %s", m_szFileName, section, option));
|
||||
LogError(BuildString("Error in %s, section: %s, entry: %s", _szFileName, section, option));
|
||||
errCode = ERR_FTYPE;
|
||||
}
|
||||
}
|
||||
@ -259,7 +259,7 @@ ErrorCode CBofOptions::ReadSetting(const char *section, const char *option, char
|
||||
return errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofOptions::ReadSetting(const char *section, const char *option, int *intValue, int defaultValue) {
|
||||
ErrorCode CBofOptions::readSetting(const char *section, const char *option, int *intValue, int defaultValue) {
|
||||
Assert(section != nullptr);
|
||||
Assert(option != nullptr);
|
||||
Assert(intValue != nullptr);
|
||||
@ -274,7 +274,7 @@ ErrorCode CBofOptions::ReadSetting(const char *section, const char *option, int
|
||||
char szDefault[20], szBuf[20];
|
||||
|
||||
Common::sprintf_s(szDefault, "%d", defaultValue);
|
||||
ErrorCode errCode = ReadSetting(section, option, szBuf, szDefault, 20);
|
||||
ErrorCode errCode = readSetting(section, option, szBuf, szDefault, 20);
|
||||
|
||||
if (intValue != nullptr)
|
||||
*intValue = atoi(szBuf);
|
||||
@ -282,7 +282,7 @@ ErrorCode CBofOptions::ReadSetting(const char *section, const char *option, int
|
||||
return errCode;
|
||||
}
|
||||
|
||||
ErrorCode CBofOptions::ReadSetting(const char *section, const char *option, bool *boolValue, bool defaultValue) {
|
||||
ErrorCode CBofOptions::readSetting(const char *section, const char *option, bool *boolValue, bool defaultValue) {
|
||||
Assert(section != nullptr);
|
||||
Assert(option != nullptr);
|
||||
Assert(boolValue != nullptr);
|
||||
@ -295,7 +295,7 @@ ErrorCode CBofOptions::ReadSetting(const char *section, const char *option, bool
|
||||
}
|
||||
|
||||
int v;
|
||||
ErrorCode errCode = ReadSetting(section, option, &v, defaultValue);
|
||||
ErrorCode errCode = readSetting(section, option, &v, defaultValue);
|
||||
*boolValue = v != 0;
|
||||
return errCode;
|
||||
}
|
||||
@ -356,7 +356,7 @@ COption *CBofOptions::FindOption(const char *pszSection, const char *pszVar) {
|
||||
return pFound;
|
||||
}
|
||||
|
||||
bool CBofOptions::ReadLine(Common::SeekableReadStream *pFile, char *pszBuf) {
|
||||
bool CBofOptions::readLine(Common::SeekableReadStream *pFile, char *pszBuf) {
|
||||
Assert(pFile != nullptr);
|
||||
Assert(pszBuf != nullptr);
|
||||
|
||||
|
@ -70,10 +70,10 @@ private:
|
||||
* @param pFile Pointer to open file for reading
|
||||
* @param pszBuf Buffer to fill with text read
|
||||
*/
|
||||
bool ReadLine(Common::SeekableReadStream *pFile, char *pszBuf);
|
||||
bool readLine(Common::SeekableReadStream *pFile, char *pszBuf);
|
||||
|
||||
protected:
|
||||
char m_szFileName[MAX_FNAME];
|
||||
char _szFileName[MAX_FNAME];
|
||||
COption *m_pOptionList;
|
||||
bool m_bDirty;
|
||||
|
||||
@ -105,7 +105,7 @@ public:
|
||||
ErrorCode LoadOptionFile(const char *pszFile);
|
||||
|
||||
const char *getFileName() const {
|
||||
return ((const char *)m_szFileName);
|
||||
return ((const char *)_szFileName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +135,7 @@ public:
|
||||
* @param nSize Max length of stringValue buffer
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode ReadSetting(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 nSize);
|
||||
ErrorCode readSetting(const char *section, const char *option, char *stringValue, const char *defaultValue, uint32 nSize);
|
||||
|
||||
/**
|
||||
* Reads value for the specified option
|
||||
@ -145,7 +145,7 @@ public:
|
||||
* @param defaultValue Default value if not exists
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode ReadSetting(const char *section, const char *option, int *nValue, int defaultValue);
|
||||
ErrorCode readSetting(const char *section, const char *option, int *nValue, int defaultValue);
|
||||
|
||||
/**
|
||||
* Reads value for the specified option
|
||||
@ -155,7 +155,7 @@ public:
|
||||
* @param defaultValue Default value if not exists
|
||||
* @return Error return code
|
||||
*/
|
||||
ErrorCode ReadSetting(const char *section, const char *option, bool *boolValue, bool defaultValue);
|
||||
ErrorCode readSetting(const char *section, const char *option, bool *boolValue, bool defaultValue);
|
||||
|
||||
/**
|
||||
* Loads current .INI options file
|
||||
|
@ -57,7 +57,7 @@ ErrorCode CBofStringTable::Load(const char *pszFileName) {
|
||||
BofMemSet(m_pBuf, 0, m_lBufSize + 1);
|
||||
|
||||
// Read in entire file
|
||||
Read(m_pBuf, m_lBufSize);
|
||||
read(m_pBuf, m_lBufSize);
|
||||
|
||||
BuildTable();
|
||||
|
||||
@ -158,7 +158,7 @@ const char *CBofStringTable::GetString(int nId) {
|
||||
}
|
||||
|
||||
if (pCurString == nullptr) {
|
||||
LogWarning(BuildString("Resource String %d not found in %s", nId, m_szFileName));
|
||||
LogWarning(BuildString("Resource String %d not found in %s", nId, _szFileName));
|
||||
}
|
||||
|
||||
return pszString;
|
||||
|
@ -79,7 +79,7 @@ CBofSound::CBofSound(CBofWindow *pWnd, const char *pszPathName, uint16 wFlags, c
|
||||
m_wFlags = wFlags; // Flags for playing
|
||||
m_bPaused = false; // Not suspended
|
||||
m_bExtensionsUsed = false; // No extended flags used.
|
||||
m_szFileName[0] = '\0';
|
||||
_szFileName[0] = '\0';
|
||||
|
||||
m_handle = {};
|
||||
m_pFileBuf = nullptr;
|
||||
@ -114,7 +114,7 @@ CBofSound::CBofSound(CBofWindow *pWnd, const char *pszPathName, uint16 wFlags, c
|
||||
|
||||
// Continue as long as this file exists
|
||||
if (FileExists(szTempPath)) {
|
||||
FileGetFullPath(m_szFileName, szTempPath);
|
||||
FileGetFullPath(_szFileName, szTempPath);
|
||||
|
||||
if (!(m_wFlags & SOUND_QUEUE)) {
|
||||
if (m_wFlags & SOUND_WAVE || m_wFlags & SOUND_MIX) {
|
||||
@ -127,7 +127,7 @@ CBofSound::CBofSound(CBofWindow *pWnd, const char *pszPathName, uint16 wFlags, c
|
||||
if (m_wFlags & SOUND_MIDI) {
|
||||
StrReplaceStr(szTempPath, ".MID", ".MOV");
|
||||
if (FileExists(szTempPath)) {
|
||||
FileGetFullPath(m_szFileName, szTempPath);
|
||||
FileGetFullPath(_szFileName, szTempPath);
|
||||
m_chType = SOUND_TYPE_QT;
|
||||
} else {
|
||||
ReportError(ERR_FFIND, szTempPath);
|
||||
@ -746,7 +746,7 @@ bool BofPlaySoundEx(const char *pszSoundFile, uint32 nFlags, int iQSlot, bool bW
|
||||
|
||||
bool CBofSound::LoadSound() {
|
||||
Assert(IsValidObject(this));
|
||||
Assert(m_szFileName[0] != '\0');
|
||||
Assert(_szFileName[0] != '\0');
|
||||
|
||||
// Assume failure
|
||||
bool bSuccess = false;
|
||||
@ -757,7 +757,7 @@ bool CBofSound::LoadSound() {
|
||||
|
||||
Common::File in;
|
||||
|
||||
if (in.open(m_szFileName)) {
|
||||
if (in.open(_szFileName)) {
|
||||
m_iFileSize = in.size();
|
||||
|
||||
m_pFileBuf = (byte *)malloc(m_iFileSize);
|
||||
|
@ -95,7 +95,7 @@ public:
|
||||
}
|
||||
|
||||
char *getFileName() {
|
||||
return &m_szFileName[0];
|
||||
return &_szFileName[0];
|
||||
}
|
||||
|
||||
void setFlags(uint16 wFlags) {
|
||||
@ -181,7 +181,7 @@ private:
|
||||
bool ReleaseSound();
|
||||
|
||||
private:
|
||||
char m_szFileName[MAX_FNAME]; // Path spec for sound file
|
||||
char _szFileName[MAX_FNAME]; // Path spec for sound file
|
||||
int8 m_chType = 0; // Type of sound commands used
|
||||
|
||||
uint16 m_wLoops = 0; // Number of times to loop the sound (0xFFFF means infinite)
|
||||
|
@ -96,8 +96,8 @@ bool Console::cmdLoad(int argc, const char **argv) {
|
||||
char nameBuffer[MAX_SAVETITLE];
|
||||
// No slot specified, so just list saves
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (saves.FindRecord(i) != -1) {
|
||||
saves.ReadTitleOnly(i, nameBuffer);
|
||||
if (saves.findRecord(i) != -1) {
|
||||
saves.readTitleOnly(i, nameBuffer);
|
||||
if (strlen(nameBuffer) > 0)
|
||||
debugPrintf("%2d - %s\n", i, nameBuffer);
|
||||
}
|
||||
@ -106,7 +106,7 @@ bool Console::cmdLoad(int argc, const char **argv) {
|
||||
// Read in actual savegame
|
||||
int slotNum = atoi(argv[1]);
|
||||
|
||||
if (saves.ReadSavedGame(slotNum) == ERR_NONE)
|
||||
if (saves.readSavedGame(slotNum) == ERR_NONE)
|
||||
return false;
|
||||
|
||||
debugPrintf("Could not read savegame.\n");
|
||||
|
@ -156,7 +156,7 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
|
||||
lSize = cFile.GetLength();
|
||||
if ((_pszText = (char *)BofCAlloc(lSize + 1, 1)) != nullptr) {
|
||||
|
||||
cFile.Read(_pszText, lSize);
|
||||
cFile.read(_pszText, lSize);
|
||||
|
||||
_pszNextLine = _pszText;
|
||||
_pszEnd = _pszText + lSize;
|
||||
|
@ -57,9 +57,9 @@ void MusicPlayer::play(CBofSound *sound) {
|
||||
} else if (sound->m_chType == SOUND_TYPE_QT) {
|
||||
parser = MidiParser::createParser_QT();
|
||||
// HACK: loadMusic doesn't work with QT MIDI
|
||||
loaded = ((MidiParser_QT *)parser)->loadFromContainerFile(sound->m_szFileName);
|
||||
loaded = ((MidiParser_QT *)parser)->loadFromContainerFile(sound->_szFileName);
|
||||
} else {
|
||||
warning("Invalid sound %s passed to MusicPlayer", sound->m_szFileName);
|
||||
warning("Invalid sound %s passed to MusicPlayer", sound->_szFileName);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ void MusicPlayer::play(CBofSound *sound) {
|
||||
_isPlaying = true;
|
||||
_sound = sound;
|
||||
} else {
|
||||
warning("Failed to play %s", sound->m_szFileName);
|
||||
warning("Failed to play %s", sound->_szFileName);
|
||||
delete parser;
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ ErrorCode SBarComputer::readDrnkFile() {
|
||||
return ERR_MEMORY;
|
||||
|
||||
// Read the text file into buffers
|
||||
fpDrinkFile.Read(_pDrinkBuff, fpDrinkFile.GetLength());
|
||||
fpDrinkFile.read(_pDrinkBuff, fpDrinkFile.GetLength());
|
||||
|
||||
// Get pointers indexing into Drink buffers
|
||||
char *pPosInBuff = _pDrinkBuff;
|
||||
@ -331,7 +331,7 @@ ErrorCode SBarComputer::readIngFile() {
|
||||
return ERR_MEMORY;
|
||||
|
||||
// Read the text file into buffers
|
||||
fpIngFile.Read(_pIngBuff, fpIngFile.GetLength());
|
||||
fpIngFile.read(_pIngBuff, fpIngFile.GetLength());
|
||||
|
||||
// Get pointers indexing into Ingredient buffers
|
||||
char *pPosInBuff = _pIngBuff;
|
||||
|
@ -117,7 +117,7 @@ void vilInitFilters(CBofBitmap *pBmp) {
|
||||
CBofFile nfile(cString, CBF_READONLY);
|
||||
buff = new char[nfile.GetLength() + 1];
|
||||
memset(buff, 0, nfile.GetLength() + 1);
|
||||
nfile.Read(buff, nfile.GetLength());
|
||||
nfile.read(buff, nfile.GetLength());
|
||||
StrReplaceChar(buff, '\n', ' ');
|
||||
StrReplaceChar(buff, '\r', ' ');
|
||||
pTipBmp = new CBofBitmap((nfile.GetLength() + 1) * 7, 20, pBmp->getPalette());
|
||||
@ -370,7 +370,7 @@ static bool VildroidFilter(CBofBitmap *pBmp, CBofRect *pRect) {
|
||||
buff = new char[nfile.GetLength() + 1];
|
||||
memset(buff, 0, nfile.GetLength() + 1);
|
||||
pChipBmp = new CBofBitmap(VILDROIDCHIPTEXTWIDTH, 300, pBmp->getPalette());
|
||||
nfile.Read(buff, nfile.GetLength());
|
||||
nfile.read(buff, nfile.GetLength());
|
||||
CBofRect txtRect(0, 0, VILDROIDCHIPTEXTWIDTH, 18);
|
||||
uint32 test = 0;
|
||||
char *pBuff1 = buff;
|
||||
@ -413,7 +413,7 @@ static bool VildroidFilter(CBofBitmap *pBmp, CBofRect *pRect) {
|
||||
buff = new char[nfile.GetLength() + 1];
|
||||
memset(buff, 0, nfile.GetLength() + 1);
|
||||
pChipBmp = new CBofBitmap(VILDROIDCHIPTEXTWIDTH, 300, pBmp->getPalette());
|
||||
nfile.Read(buff, nfile.GetLength());
|
||||
nfile.read(buff, nfile.GetLength());
|
||||
CBofRect txtRect(0, 0, VILDROIDCHIPTEXTWIDTH, 18);
|
||||
uint32 test = 0;
|
||||
char *pBuff1 = buff;
|
||||
|
@ -4185,7 +4185,7 @@ void SrafComputer::notifyBoss(CBofString &sSoundFile, int nStafferID) {
|
||||
|
||||
if (nLength != 0 && (pszBuf = (char *)BofAlloc(nLength + 1)) != nullptr) {
|
||||
BofMemSet(pszBuf, 0, nLength + 1);
|
||||
fTxtFile.Read(pszBuf, nLength);
|
||||
fTxtFile.read(pszBuf, nLength);
|
||||
|
||||
// Put it up on the screen
|
||||
displayMessage(pszBuf);
|
||||
@ -4563,7 +4563,7 @@ SrafTextScreen::SrafTextScreen(const CBofString &str, bool isText) :
|
||||
|
||||
size_t len = file->GetLength();
|
||||
char *tmp = new char[len + 1];
|
||||
file->Read(tmp, len);
|
||||
file->read(tmp, len);
|
||||
tmp[len] = '\0';
|
||||
|
||||
_text = CBofString(tmp);
|
||||
|
@ -108,7 +108,7 @@ ErrorCode SBarVidWnd::attach() {
|
||||
|
||||
_pMovie = new CBagCharacterObject;
|
||||
if (_pMovie != nullptr) {
|
||||
_pMovie->SetFileName(BuildVidDir("BRNL.SMK"));
|
||||
_pMovie->setFileName(BuildVidDir("BRNL.SMK"));
|
||||
_pMovie->setPosition(CBofPoint(209, 10));
|
||||
_pMovie->attach();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user