Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Yershov <yershov@corp.mail.ru>2016-02-16 12:25:00 +0300
committerSergey Yershov <yershov@corp.mail.ru>2016-03-23 16:22:25 +0300
commitdadee84154f7a3e7c1d0e543af619651e3bf5dc7 (patch)
tree2581fda49d06939f62f73932631da6d450215904 /platform
parent65e3f493c9b1b63d055bdbd35e385a8972180f17 (diff)
[new downloader][MAPSME-121] Improve error handling for space check functions
Diffstat (limited to 'platform')
-rw-r--r--platform/platform.cpp8
-rw-r--r--platform/platform.hpp4
-rw-r--r--platform/platform_unix_impl.cpp38
3 files changed, 44 insertions, 6 deletions
diff --git a/platform/platform.cpp b/platform/platform.cpp
index e67269f0a0..2bc3a102f7 100644
--- a/platform/platform.cpp
+++ b/platform/platform.cpp
@@ -44,6 +44,14 @@ Platform::EError Platform::ErrnoToError()
return ERR_DIRECTORY_NOT_EMPTY;
case EEXIST:
return ERR_FILE_ALREADY_EXISTS;
+ case ENAMETOOLONG:
+ return ERR_NAME_TOO_LONG;
+ case ENOTDIR:
+ return ERR_NOT_A_DIRECTORY;
+ case ELOOP:
+ return ERR_SYMLINK_LOOP;
+ case EIO:
+ return ERR_IO_ERROR;
default:
return ERR_UNKNOWN;
}
diff --git a/platform/platform.hpp b/platform/platform.hpp
index 186f3d4c9d..7557f19856 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -32,6 +32,10 @@ public:
ERR_ACCESS_FAILED,
ERR_DIRECTORY_NOT_EMPTY,
ERR_FILE_ALREADY_EXISTS,
+ ERR_NAME_TOO_LONG,
+ ERR_NOT_A_DIRECTORY,
+ ERR_SYMLINK_LOOP,
+ ERR_IO_ERROR,
ERR_UNKNOWN
};
diff --git a/platform/platform_unix_impl.cpp b/platform/platform_unix_impl.cpp
index fda11526e4..f88e662607 100644
--- a/platform/platform_unix_impl.cpp
+++ b/platform/platform_unix_impl.cpp
@@ -32,6 +32,26 @@ struct CloseDir
closedir(dir);
}
};
+
+string DebugPrint(Platform::EError err)
+{
+ switch (err)
+ {
+ case Platform::ERR_OK: return "Ok";
+ case Platform::ERR_FILE_DOES_NOT_EXIST: return "File does not exist.";
+ case Platform::ERR_ACCESS_FAILED: return "Access failed.";
+ case Platform::ERR_DIRECTORY_NOT_EMPTY: return "Directory not empty.";
+ case Platform::ERR_FILE_ALREADY_EXISTS: return "File already exists.";
+ case Platform::ERR_NAME_TOO_LONG:
+ return "The length of a component of path exceeds {NAME_MAX} characters.";
+ case Platform::ERR_NOT_A_DIRECTORY:
+ return "A component of the path prefix of Path is not a directory.";
+ case Platform::ERR_SYMLINK_LOOP:
+ return "Too many symbolic links were encountered in translating path.";
+ case Platform::ERR_IO_ERROR: return "An I/O error occurred.";
+ case Platform::ERR_UNKNOWN: return "Unknown";
+ }
+}
} // namespace
void Platform::GetSystemFontNames(FilesList & res) const
@@ -185,12 +205,15 @@ Platform::TStorageStatus Platform::GetWritableStorageStatus(uint64_t neededSize)
struct statfs st;
int const ret = statfs(m_writableDir.c_str(), &st);
- LOG(LDEBUG, ("statfs return = ", ret,
- "; block size = ", st.f_bsize,
- "; blocks available = ", st.f_bavail));
+ LOG(LDEBUG, ("statfs return =", ret,
+ "; block size =", st.f_bsize,
+ "; blocks available =", st.f_bavail));
if (ret != 0)
+ {
+ LOG(LERROR, ("Path:", m_writableDir, "statfs error:", ErrnoToError()));
return STORAGE_DISCONNECTED;
+ }
/// @todo May be add additional storage space.
if (st.f_bsize * st.f_bavail < neededSize)
@@ -204,9 +227,12 @@ uint64_t Platform::GetWritableStorageSpace() const
struct statfs st;
int const ret = statfs(m_writableDir.c_str(), &st);
- LOG(LDEBUG, ("statfs return = ", ret,
- "; block size = ", st.f_bsize,
- "; blocks available = ", st.f_bavail));
+ LOG(LDEBUG, ("statfs return =", ret,
+ "; block size =", st.f_bsize,
+ "; blocks available =", st.f_bavail));
+
+ if (ret != 0)
+ LOG(LERROR, ("Path:", m_writableDir, "statfs error:", ErrnoToError()));
return (ret != 0) ? 0 : st.f_bsize * st.f_bavail;
}