[Scummvm-cvs-logs] SF.net SVN: scummvm: [30060] scummvm/trunk/backends/saves/default
david_corrales at users.sourceforge.net
david_corrales at users.sourceforge.net
Fri Dec 28 17:47:29 CET 2007
Revision: 30060
http://scummvm.svn.sourceforge.net/scummvm/?rev=30060&view=rev
Author: david_corrales
Date: 2007-12-28 08:47:28 -0800 (Fri, 28 Dec 2007)
Log Message:
-----------
Change the checkPath() method to receive a String& instead of a char*, to make code clearer.
Modified Paths:
--------------
scummvm/trunk/backends/saves/default/default-saves.cpp
scummvm/trunk/backends/saves/default/default-saves.h
Modified: scummvm/trunk/backends/saves/default/default-saves.cpp
===================================================================
--- scummvm/trunk/backends/saves/default/default-saves.cpp 2007-12-28 13:51:11 UTC (rev 30059)
+++ scummvm/trunk/backends/saves/default/default-saves.cpp 2007-12-28 16:47:28 UTC (rev 30060)
@@ -129,72 +129,71 @@
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
Modified: scummvm/trunk/backends/saves/default/default-saves.h
===================================================================
--- scummvm/trunk/backends/saves/default/default-saves.h 2007-12-28 13:51:11 UTC (rev 30059)
+++ scummvm/trunk/backends/saves/default/default-saves.h 2007-12-28 16:47:28 UTC (rev 30060)
@@ -51,7 +51,7 @@
* 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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list