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; }