diff options
author | Max Horn | 2003-09-17 21:06:16 +0000 |
---|---|---|
committer | Max Horn | 2003-09-17 21:06:16 +0000 |
commit | 468275bb94f975b9e1c2e7e90a03caa37bd0e142 (patch) | |
tree | 1c3a7f30ca33043dba1a7de1119d6c50da7181fa /common | |
parent | c0d1061a2dcfd8c50c70ca99b99a41e81207fa86 (diff) | |
download | scummvm-rg350-468275bb94f975b9e1c2e7e90a03caa37bd0e142.tar.gz scummvm-rg350-468275bb94f975b9e1c2e7e90a03caa37bd0e142.tar.bz2 scummvm-rg350-468275bb94f975b9e1c2e7e90a03caa37bd0e142.zip |
added a static method setDefaultDirectory to class File; used this to simplify some code; added a global g_sound pointer in bs2, this cuts down on uses of g_sword2 (of course both should be removed on the long run); some other minor tweaks/fixes
svn-id: r10278
Diffstat (limited to 'common')
-rw-r--r-- | common/engine.h | 2 | ||||
-rw-r--r-- | common/file.cpp | 13 | ||||
-rw-r--r-- | common/file.h | 10 |
3 files changed, 20 insertions, 5 deletions
diff --git a/common/engine.h b/common/engine.h index bcab61efc6..5bd4857cef 100644 --- a/common/engine.h +++ b/common/engine.h @@ -73,8 +73,6 @@ public: // Get the save game dir path const char *getSavePath() const; - virtual const char *getGameDataPath() const { return _gameDataPath; } - // Specific for each engine preparare of erroe string virtual void errorString(const char *buf_input, char *buf_output) = 0; }; diff --git a/common/file.cpp b/common/file.cpp index 81fd148e98..3f1412033d 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -22,6 +22,10 @@ #include "common/file.h" #include "common/util.h" + +char *File::_defaultDirectory = 0; + + FILE *File::fopenNoCase(const char *filename, const char *directory, const char *mode) { FILE *file; char buf[512]; @@ -111,6 +115,11 @@ FILE *File::fopenNoCase(const char *filename, const char *directory, const char return NULL; } +void File::setDefaultDirectory(const char *directory) { + free(_defaultDirectory); + _defaultDirectory = strdup(directory); +} + File::File() { _handle = NULL; _ioFailed = false; @@ -131,6 +140,10 @@ bool File::open(const char *filename, const char *directory, int mode, byte encb if (filename == NULL || *filename == 0) return false; + + // If no directory was specified, use the default directory (if any). + if (directory == NULL) + directory = _defaultDirectory ? _defaultDirectory : ""; clearIOFailed(); diff --git a/common/file.h b/common/file.h index 7d6ab8f395..c07d4e9d4a 100644 --- a/common/file.h +++ b/common/file.h @@ -33,17 +33,21 @@ private: byte _encbyte; char *_name; // For debugging - FILE *fopenNoCase(const char *filename, const char *directory, const char *mode); + static FILE *fopenNoCase(const char *filename, const char *directory, const char *mode); + + static char *_defaultDirectory; public: enum { kFileReadMode = 1, kFileWriteMode = 2 }; - + + static void setDefaultDirectory(const char *directory); + File(); virtual ~File(); - bool open(const char *filename, const char *directory, int mode = kFileReadMode, byte encbyte = 0); + bool open(const char *filename, const char *directory = NULL, int mode = kFileReadMode, byte encbyte = 0); void close(); bool isOpen(); bool ioFailed(); |