diff options
author | Max Horn | 2003-10-10 13:55:08 +0000 |
---|---|---|
committer | Max Horn | 2003-10-10 13:55:08 +0000 |
commit | 5301edc38306c27143f38d74085e6c095688f6aa (patch) | |
tree | 101c5188d06ac1f476edae9f3a5755e48554dc64 /common | |
parent | 1f9497cb1fbfcc8c3ffd412ce450144983b2452d (diff) | |
download | scummvm-rg350-5301edc38306c27143f38d74085e6c095688f6aa.tar.gz scummvm-rg350-5301edc38306c27143f38d74085e6c095688f6aa.tar.bz2 scummvm-rg350-5301edc38306c27143f38d74085e6c095688f6aa.zip |
some cleanup
svn-id: r10720
Diffstat (limited to 'common')
-rw-r--r-- | common/file.cpp | 9 | ||||
-rw-r--r-- | common/file.h | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/common/file.cpp b/common/file.cpp index 1110c683b5..cb6eb4545a 100644 --- a/common/file.cpp +++ b/common/file.cpp @@ -23,7 +23,7 @@ #include "common/util.h" -char *File::_defaultDirectory = 0; +Common::String File::_defaultDirectory; FILE *File::fopenNoCase(const char *filename, const char *directory, const char *mode) { @@ -119,9 +119,8 @@ FILE *File::fopenNoCase(const char *filename, const char *directory, const char return NULL; } -void File::setDefaultDirectory(const char *directory) { - free(_defaultDirectory); - _defaultDirectory = strdup(directory); +void File::setDefaultDirectory(const Common::String &directory) { + _defaultDirectory = directory; } File::File() { @@ -147,7 +146,7 @@ bool File::open(const char *filename, const char *directory, int mode, byte encb // If no directory was specified, use the default directory (if any). if (directory == NULL) - directory = _defaultDirectory ? _defaultDirectory : ""; + directory = _defaultDirectory.isEmpty() ? "" : _defaultDirectory.c_str(); clearIOFailed(); diff --git a/common/file.h b/common/file.h index c07d4e9d4a..b043608d22 100644 --- a/common/file.h +++ b/common/file.h @@ -24,6 +24,7 @@ #include "stdafx.h" #include "common/scummsys.h" +#include "common/str.h" class File { private: @@ -35,7 +36,7 @@ private: static FILE *fopenNoCase(const char *filename, const char *directory, const char *mode); - static char *_defaultDirectory; + static Common::String _defaultDirectory; public: enum { @@ -43,10 +44,11 @@ public: kFileWriteMode = 2 }; - static void setDefaultDirectory(const char *directory); + static void setDefaultDirectory(const Common::String &directory); File(); virtual ~File(); + bool open(const char *filename, const Common::String &directory) { return open(filename, directory.c_str()); } bool open(const char *filename, const char *directory = NULL, int mode = kFileReadMode, byte encbyte = 0); void close(); bool isOpen(); |