From 5301edc38306c27143f38d74085e6c095688f6aa Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 10 Oct 2003 13:55:08 +0000 Subject: some cleanup svn-id: r10720 --- common/file.cpp | 9 ++++----- common/file.h | 6 ++++-- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'common') 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(); -- cgit v1.2.3