Add std::filesystem::filesystem_error object.

Not a standards-compliant implementation, but has the same vague shape, so should be easier to port later(?).
This commit is contained in:
Jared Boone 2016-05-12 18:19:28 -07:00
parent 479a96fc22
commit 4567db2fdb
2 changed files with 36 additions and 0 deletions

View File

@ -140,6 +140,32 @@ std::string next_filename_stem_matching_pattern(const std::string& filename_stem
namespace std {
namespace filesystem {
std::string filesystem_error::what() const {
switch(err) {
case FR_OK: return "";
case FR_DISK_ERR: return "disk error";
case FR_INT_ERR: return "insanity detected";
case FR_NOT_READY: return "not ready";
case FR_NO_FILE: return "no file";
case FR_NO_PATH: return "no path";
case FR_INVALID_NAME: return "invalid name";
case FR_DENIED: return "denied";
case FR_EXIST: return "exists";
case FR_INVALID_OBJECT: return "invalid object";
case FR_WRITE_PROTECTED: return "write protected";
case FR_INVALID_DRIVE: return "invalid drive";
case FR_NOT_ENABLED: return "not enabled";
case FR_NO_FILESYSTEM: return "no filesystem";
case FR_MKFS_ABORTED: return "mkfs aborted";
case FR_TIMEOUT: return "timeout";
case FR_LOCKED: return "locked";
case FR_NOT_ENOUGH_CORE: return "not enough core";
case FR_TOO_MANY_OPEN_FILES: return "too many open files";
case FR_INVALID_PARAMETER: return "invalid parameter";
default: return "unknown";
}
}
directory_iterator::directory_iterator(
const char* path,
const char* wild

View File

@ -76,6 +76,16 @@ std::string next_filename_stem_matching_pattern(const std::string& filename_stem
namespace std {
namespace filesystem {
struct filesystem_error {
const BYTE err;
operator bool() const {
return err != FR_OK;
}
std::string what() const;
};
using path = std::string;
using file_status = BYTE;