diff options
author | David Corrales | 2007-12-28 16:47:28 +0000 |
---|---|---|
committer | David Corrales | 2007-12-28 16:47:28 +0000 |
commit | a31bd32bc59e7ffab62143ec44801b6256483c88 (patch) | |
tree | 3b1df2175f02282b4e8421cc6ee539745b1b23cb /backends/saves/default | |
parent | a9813fbdfaec50fc6e1d154c4b0d9280ece6411b (diff) | |
download | scummvm-rg350-a31bd32bc59e7ffab62143ec44801b6256483c88.tar.gz scummvm-rg350-a31bd32bc59e7ffab62143ec44801b6256483c88.tar.bz2 scummvm-rg350-a31bd32bc59e7ffab62143ec44801b6256483c88.zip |
Change the checkPath() method to receive a String& instead of a char*, to make code clearer.
svn-id: r30060
Diffstat (limited to 'backends/saves/default')
-rw-r--r-- | backends/saves/default/default-saves.cpp | 33 | ||||
-rw-r--r-- | backends/saves/default/default-saves.h | 2 |
2 files changed, 17 insertions, 18 deletions
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index d096a5f47e..bb65cfd29b 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -129,72 +129,71 @@ Common::StringList DefaultSaveFileManager::listSavefiles(const char *regex) { return results; } -void DefaultSaveFileManager::checkPath(const char *path) { +void DefaultSaveFileManager::checkPath(const Common::String &path) { clearError(); - Common::String pathStr(path); #if defined(UNIX) || defined(__SYMBIAN32__) struct stat sb; // Check whether the dir exists - if (stat(path, &sb) == -1) { + if (stat(path.c_str(), &sb) == -1) { // The dir does not exist, or stat failed for some other reason. // If the problem was that the path pointed to nothing, try // to create the dir (ENOENT case). switch (errno) { case EACCES: - setError(SFM_DIR_ACCESS, "Search or write permission denied: "+pathStr); + setError(SFM_DIR_ACCESS, "Search or write permission denied: "+path); break; #if !defined(__SYMBIAN32__) case ELOOP: - setError(SFM_DIR_LOOP, "Too many symbolic links encountered while traversing the path: "+pathStr); + setError(SFM_DIR_LOOP, "Too many symbolic links encountered while traversing the path: "+path); break; #endif case ENAMETOOLONG: - setError(SFM_DIR_NAMETOOLONG, "The path name is too long: "+pathStr); + setError(SFM_DIR_NAMETOOLONG, "The path name is too long: "+path); break; case ENOENT: - if (mkdir(path, 0755) != 0) { + if (mkdir(path.c_str(), 0755) != 0) { // mkdir could fail for various reasons: The parent dir doesn't exist, // or is not writeable, the path could be completly bogus, etc. - warning("mkdir for '%s' failed!", path); + warning("mkdir for '%s' failed!", path.c_str()); perror("mkdir"); switch (errno) { case EACCES: - setError(SFM_DIR_ACCESS, "Search or write permission denied: "+pathStr); + setError(SFM_DIR_ACCESS, "Search or write permission denied: "+path); break; case EMLINK: - setError(SFM_DIR_LINKMAX, "The link count of the parent directory would exceed {LINK_MAX}: "+pathStr); + setError(SFM_DIR_LINKMAX, "The link count of the parent directory would exceed {LINK_MAX}: "+path); break; #if !defined(__SYMBIAN32__) case ELOOP: - setError(SFM_DIR_LOOP, "Too many symbolic links encountered while traversing the path: "+pathStr); + setError(SFM_DIR_LOOP, "Too many symbolic links encountered while traversing the path: "+path); break; #endif case ENAMETOOLONG: - setError(SFM_DIR_NAMETOOLONG, "The path name is too long: "+pathStr); + setError(SFM_DIR_NAMETOOLONG, "The path name is too long: "+path); break; case ENOENT: - setError(SFM_DIR_NOENT, "A component of the path does not exist, or the path is an empty string: "+pathStr); + setError(SFM_DIR_NOENT, "A component of the path does not exist, or the path is an empty string: "+path); break; case ENOTDIR: - setError(SFM_DIR_NOTDIR, "A component of the path prefix is not a directory: "+pathStr); + setError(SFM_DIR_NOTDIR, "A component of the path prefix is not a directory: "+path); break; case EROFS: - setError(SFM_DIR_ROFS, "The parent directory resides on a read-only file system:"+pathStr); + setError(SFM_DIR_ROFS, "The parent directory resides on a read-only file system:"+path); break; } } break; case ENOTDIR: - setError(SFM_DIR_NOTDIR, "A component of the path prefix is not a directory: "+pathStr); + setError(SFM_DIR_NOTDIR, "A component of the path prefix is not a directory: "+path); break; } } else { // So stat() succeeded. But is the path actually pointing to a directory? if (!S_ISDIR(sb.st_mode)) { - setError(SFM_DIR_NOTDIR, "The given savepath is not a directory: "+pathStr); + setError(SFM_DIR_NOTDIR, "The given savepath is not a directory: "+path); } } #endif diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h index 8dd7db0367..6cf842b00c 100644 --- a/backends/saves/default/default-saves.h +++ b/backends/saves/default/default-saves.h @@ -51,7 +51,7 @@ protected: * Checks the given path for read access, existence, etc. * Sets the internal error and error message accordingly. */ - void checkPath(const char *path); + void checkPath(const Common::String &path); }; #endif |