diff options
Diffstat (limited to 'backends/platform/openpandora/op-backend.cpp')
| -rw-r--r-- | backends/platform/openpandora/op-backend.cpp | 54 | 
1 files changed, 23 insertions, 31 deletions
| diff --git a/backends/platform/openpandora/op-backend.cpp b/backends/platform/openpandora/op-backend.cpp index 1d620ff73b..0295643cb0 100644 --- a/backends/platform/openpandora/op-backend.cpp +++ b/backends/platform/openpandora/op-backend.cpp @@ -42,8 +42,7 @@  #include "audio/mixer_intern.h" -#include <unistd.h> -#include <limits.h> +#include <unistd.h> // for getcwd()  /* Dump console info to files. */  #define DUMP_STDOUT @@ -53,60 +52,57 @@ OSystem_OP::OSystem_OP()  	OSystem_POSIX() {  } +Common::String OSystem_OP::getCurrentDirectory() { +	char cwd[MAXPATHLEN+1]; +	return Common::String(getcwd(cwd, MAXPATHLEN)); +} +  void OSystem_OP::initBackend() {  	assert(!_inited);  	/* Setup default save path to be workingdir/saves */ -	char savePath[PATH_MAX+1]; -	char workDirName[PATH_MAX+1]; - -	if (getcwd(workDirName, PATH_MAX) == NULL) { +	Common::String workDirName = getCurrentDirectory(); +	if (workDirName.empty()) {  		error("Could not obtain current working directory.");  	} else { -		printf("Current working directory: %s\n", workDirName); +		printf("Current working directory: %s\n", workDirName.c_str());  	} -	strcpy(savePath, workDirName); -	strcat(savePath, "/../saves"); -	printf("Current save directory: %s\n", savePath); +	Common::String savePath = workDirName + "/../saves"); +	printf("Current save directory: %s\n", savePath.c_str());  	_savefileManager = new DefaultSaveFileManager(savePath);  #ifdef DUMP_STDOUT  	// The OpenPandora has a serial console on the EXT connection but most users do not use this so we  	// output all our STDOUT and STDERR to files for debug purposes. -	char STDOUT_FILE[PATH_MAX+1]; -	char STDERR_FILE[PATH_MAX+1]; - -	strcpy(STDOUT_FILE, workDirName); -	strcpy(STDERR_FILE, workDirName); -	strcat(STDOUT_FILE, "/scummvm.stdout.txt"); -	strcat(STDERR_FILE, "/scummvm.stderr.txt"); +	Common::String STDOUT_FILE = workDirName + "/scummvm.stdout.txt"; +	Common::String STDERR_FILE = workDirName + "/scummvm.stderr.txt";  	// Flush the output in case anything is queued  	fclose(stdout);  	fclose(stderr);  	// Redirect standard input and standard output -	FILE *newfp = freopen(STDOUT_FILE, "w", stdout); +	FILE *newfp = freopen(STDOUT_FILE.c_str(), "w", stdout);  	if (newfp == NULL) {  #if !defined(stdout) -		stdout = fopen(STDOUT_FILE, "w"); +		stdout = fopen(STDOUT_FILE.c_str(), "w");  #else -		newfp = fopen(STDOUT_FILE, "w"); +		newfp = fopen(STDOUT_FILE.c_str(), "w");  		if (newfp) {  			*stdout = *newfp;  		}  #endif  	} -	newfp = freopen(STDERR_FILE, "w", stderr); +	newfp = freopen(STDERR_FILE.c_str(), "w", stderr);  	if (newfp == NULL) {  #if !defined(stderr) -		stderr = fopen(STDERR_FILE, "w"); +		stderr = fopen(STDERR_FILE.c_str(), "w");  #else -		newfp = fopen(STDERR_FILE, "w"); +		newfp = fopen(STDERR_FILE.c_str(), "w");  		if (newfp) {  			*stderr = *newfp;  		} @@ -163,17 +159,13 @@ void OSystem_OP::initSDL() {  void OSystem_OP::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {  	/* Setup default extra data paths for engine data files and plugins */ -	char workDirName[PATH_MAX+1]; - -	if (getcwd(workDirName, PATH_MAX) == NULL) { +	Common::String workDirName = getCurrentDirectory(); +	if (workDirName.empty()) {  		error("Error: Could not obtain current working directory.");  	} -	char enginedataPath[PATH_MAX+1]; - -	strcpy(enginedataPath, workDirName); -	strcat(enginedataPath, "/../data"); -	printf("Default engine data directory: %s\n", enginedataPath); +	Common::String enginedataPath = workDirName + "/../data"); +	printf("Default engine data directory: %s\n", enginedataPath.c_str());  	Common::FSNode engineNode(enginedataPath);  	if (engineNode.exists() && engineNode.isDirectory()) { | 
