aboutsummaryrefslogtreecommitdiff
path: root/common/savefile.h
diff options
context:
space:
mode:
authorDavid Corrales2007-07-18 20:51:26 +0000
committerDavid Corrales2007-07-18 20:51:26 +0000
commit21f352b2df2b45b9bcff6a0c21d57a1e480d4802 (patch)
tree81ab0fa29a08f4c5c9ef3b255b06a963ac4545dd /common/savefile.h
parent720c974fafaca16b6e86f28ffc14c8c3aa574e15 (diff)
downloadscummvm-rg350-21f352b2df2b45b9bcff6a0c21d57a1e480d4802.tar.gz
scummvm-rg350-21f352b2df2b45b9bcff6a0c21d57a1e480d4802.tar.bz2
scummvm-rg350-21f352b2df2b45b9bcff6a0c21d57a1e480d4802.zip
Added error codes to the SaveFileManager via the SFMError enum. Also, solved TODO's in the default-saves implementation.
svn-id: r28140
Diffstat (limited to 'common/savefile.h')
-rw-r--r--common/savefile.h44
1 files changed, 43 insertions, 1 deletions
diff --git a/common/savefile.h b/common/savefile.h
index fec6fc697b..7c97ea5058 100644
--- a/common/savefile.h
+++ b/common/savefile.h
@@ -78,8 +78,50 @@ public:
class SaveFileManager : NonCopyable {
public:
+ enum SFMError {
+ SFM_NO_ERROR, //Default state, indicates no error has been recorded
+ SFM_DIR_ACCESS, //stat(), mkdir()::EACCES: Search or write permission denied
+ SFM_DIR_LINKMAX, //mkdir()::EMLINK: The link count of the parent directory would exceed {LINK_MAX}
+ SFM_DIR_LOOP, //stat(), mkdir()::ELOOP: Too many symbolic links encountered while traversing the path
+ SFM_DIR_NAMETOOLONG, //stat(), mkdir()::ENAMETOOLONG: The path name is too long
+ SFM_DIR_NOENT, //stat(), mkdir()::ENOENT: A component of the path path does not exist, or the path is an empty string
+ SFM_DIR_NOTDIR, //stat(), mkdir()::ENOTDIR: A component of the path prefix is not a directory
+ SFM_DIR_ROFS //mkdir()::EROFS: The parent directory resides on a read-only file system
+ };
+
+protected:
+ SFMError _error;
+ String _errorDesc;
+
+public:
virtual ~SaveFileManager() {}
-
+
+ /**
+ * Clears the last set error code and string.
+ */
+ virtual void clearError() { _error = SFM_NO_ERROR; _errorDesc = ""; }
+
+ /**
+ * Returns the last ocurred error code. If none ocurred, returns SFM_NO_ERROR.
+ *
+ * @return A SFMError indicating the type of the last error.
+ */
+ virtual SFMError getError() { return _error; }
+
+ /**
+ * Returns the last ocurred error description. If none ocurred, returns 0.
+ *
+ * @return A string describing the last error.
+ */
+ virtual String getErrorDesc() { return _errorDesc; }
+
+ /**
+ * Sets the last ocurred error.
+ * @param error Code identifying the last error.
+ * @param errorDesc String describing the last error.
+ */
+ virtual void setError(SFMError error, String errorDesc) { _error = error; _errorDesc = errorDesc; }
+
/**
* Open the file with name filename in the given directory for saving.
* @param filename the filename