diff options
| author | Cameron Cawley | 2019-08-04 21:45:17 +0100 | 
|---|---|---|
| committer | Filippos Karapetis | 2019-08-05 10:01:30 +0300 | 
| commit | 8b8fb6d3a4748ded6f47cf057fc22f9aeab225d0 (patch) | |
| tree | 363e8777d147e90a75ece84e6aca42be60697dc6 /backends/platform/sdl/posix | |
| parent | d10c69d0d1c596d4ecce9cbf967c75f3cf95a47b (diff) | |
| download | scummvm-rg350-8b8fb6d3a4748ded6f47cf057fc22f9aeab225d0.tar.gz scummvm-rg350-8b8fb6d3a4748ded6f47cf057fc22f9aeab225d0.tar.bz2 scummvm-rg350-8b8fb6d3a4748ded6f47cf057fc22f9aeab225d0.zip  | |
SDL: Simplify implementation of createLogFile()
Diffstat (limited to 'backends/platform/sdl/posix')
| -rw-r--r-- | backends/platform/sdl/posix/posix.cpp | 36 | ||||
| -rw-r--r-- | backends/platform/sdl/posix/posix.h | 13 | 
2 files changed, 6 insertions, 43 deletions
diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 227f8ef0b3..b204daa643 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -269,55 +269,29 @@ void OSystem_POSIX::addSysArchivesToSearchSet(Common::SearchSet &s, int priority  	OSystem_SDL::addSysArchivesToSearchSet(s, priority);  } -Common::WriteStream *OSystem_POSIX::createLogFile() { -	// Start out by resetting _logFilePath, so that in case -	// of a failure, we know that no log file is open. -	_logFilePath.clear(); - -	const char *prefix = nullptr; +Common::String OSystem_POSIX::getDefaultLogFileName() {  	Common::String logFile; -#ifdef MACOSX -	prefix = getenv("HOME"); -	if (prefix == nullptr) { -		return 0; -	} -	logFile = "Library/Logs"; -#elif SAMSUNGTV -	prefix = nullptr; -	logFile = "/mtd_ram"; -#else  	// On POSIX systems we follow the XDG Base Directory Specification for  	// where to store files. The version we based our code upon can be found  	// over here: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html -	prefix = getenv("XDG_CACHE_HOME"); +	const char *prefix = getenv("XDG_CACHE_HOME");  	if (prefix == nullptr || !*prefix) {  		prefix = getenv("HOME");  		if (prefix == nullptr) { -			return 0; +			return Common::String();  		}  		logFile = ".cache/";  	}  	logFile += "scummvm/logs"; -#endif  	if (!Posix::assureDirectoryExists(logFile, prefix)) { -		return 0; +		return Common::String();  	} -	if (prefix) { -		logFile = Common::String::format("%s/%s", prefix, logFile.c_str()); -	} - -	logFile += "/scummvm.log"; - -	Common::FSNode file(logFile); -	Common::WriteStream *stream = file.createWriteStream(); -	if (stream) -		_logFilePath = logFile; -	return stream; +	return Common::String::format("%s/%s/scummvm.log", prefix, logFile.c_str());  }  bool OSystem_POSIX::displayLogFile() { diff --git a/backends/platform/sdl/posix/posix.h b/backends/platform/sdl/posix/posix.h index fd9bbadc9a..5df6738d45 100644 --- a/backends/platform/sdl/posix/posix.h +++ b/backends/platform/sdl/posix/posix.h @@ -52,19 +52,8 @@ protected:  	 */  	Common::String _baseConfigName; -	/** -	 * The path of the currently open log file, if any. -	 * -	 * @note This is currently a string and not an FSNode for simplicity; -	 * e.g. we don't need to include fs.h here, and currently the -	 * only use of this value is to use it to open the log file in an -	 * editor; for that, we need it only as a string anyway. -	 */ -	Common::String _logFilePath; -  	virtual Common::String getDefaultConfigFileName(); - -	virtual Common::WriteStream *createLogFile(); +	virtual Common::String getDefaultLogFileName();  	Common::String getXdgUserDir(const char *name);  | 
