aboutsummaryrefslogtreecommitdiff
path: root/backends/platform/openpandora
diff options
context:
space:
mode:
authorCameron Cawley2019-11-03 22:48:37 +0000
committerDavid Turner2019-11-30 20:50:27 +0000
commit88761ea49ce5244dc33a0784bbfba702f82d3241 (patch)
tree72f30b7d8a231954700301807671d8e7f8d4015a /backends/platform/openpandora
parent1af858466684d0e7c4f23389a5433aa8741592fa (diff)
downloadscummvm-rg350-88761ea49ce5244dc33a0784bbfba702f82d3241.tar.gz
scummvm-rg350-88761ea49ce5244dc33a0784bbfba702f82d3241.tar.bz2
scummvm-rg350-88761ea49ce5244dc33a0784bbfba702f82d3241.zip
GPH/OPENPANDORA: Replace use of strcat()/strcpy() with Common::String()
Diffstat (limited to 'backends/platform/openpandora')
-rw-r--r--backends/platform/openpandora/op-backend.cpp54
-rw-r--r--backends/platform/openpandora/op-sdl.h7
2 files changed, 26 insertions, 35 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()) {
diff --git a/backends/platform/openpandora/op-sdl.h b/backends/platform/openpandora/op-sdl.h
index dd239e58f8..815b96dd9f 100644
--- a/backends/platform/openpandora/op-sdl.h
+++ b/backends/platform/openpandora/op-sdl.h
@@ -31,10 +31,6 @@
#include "backends/events/openpandora/op-events.h"
#include "backends/graphics/openpandora/op-graphics.h"
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#endif
-
class OSystem_OP : public OSystem_POSIX {
public:
OSystem_OP();
@@ -53,6 +49,9 @@ protected:
* with an OpenPandora workaround.
*/
virtual void initSDL();
+
+private:
+ Common::String getCurrentDirectory();
};
#endif
#endif //OP_SDL_H