Putting TOT filename generation and LOM checking into TOTFile

svn-id: r41822
This commit is contained in:
Sven Hesse 2009-06-23 23:55:35 +00:00
parent 04d4ce4a8b
commit 82f1ebcafe
4 changed files with 25 additions and 23 deletions

View File

@ -319,33 +319,16 @@ char *Script::getResultStr() const {
return _expression->getResultStr();
}
bool Script::load(const char *fileName) {
bool Script::load(const Common::String &fileName) {
unload();
_finished = false;
bool lom = false;
bool isLOM;
Common::String *fileBase;
_totFile = TOTFile::createFileName(fileName, isLOM);
const char *dot;
if ((dot = strrchr(fileName, '.'))) {
// fileName includes an extension
fileBase = new Common::String(fileName, dot);
// Is it a LOM file?
if (!scumm_stricmp(dot + 1, "LOM"))
lom = true;
} else
fileBase = new Common::String(fileName);
// If it's a LOM file, it includes the TOT file
_totFile = *fileBase + (lom ? ".lom" : ".tot");
delete fileBase;
if (lom) {
if (isLOM) {
if (!loadLOM(_totFile)) {
unload();
return false;

View File

@ -99,7 +99,7 @@ public:
byte *getData();
/** Load a script file. */
bool load(const char *fileName);
bool load(const Common::String &fileName);
/** Unload the script. */
void unload();
/** Was a script loaded? */

View File

@ -98,4 +98,20 @@ bool TOTFile::getProperties(Properties &props) const {
return true;
}
Common::String TOTFile::createFileName(const Common::String &base, bool &isLOM) {
isLOM = false;
const char *dot;
if ((dot = strrchr(base.c_str(), '.'))) {
// fileName includes an extension
if (!scumm_stricmp(dot + 1, "LOM"))
isLOM = true;
return base;
}
return base + ".tot";
}
} // End of namespace Gob

View File

@ -26,8 +26,9 @@
#ifndef GOB_TOTFILE_H
#define GOB_TOTFILE_H
#include "common/str.h"
namespace Common {
class String;
class SeekableReadStream;
}
@ -62,6 +63,8 @@ public:
Common::SeekableReadStream *getStream() const;
bool getProperties(Properties &props) const;
static Common::String createFileName(const Common::String &base, bool &isLOM);
private:
GobEngine *_vm;