ReXGlue SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
file_system_error.h
Go to the documentation of this file.
1
10
11
#pragma once
12
13
#include <string>
14
#include <utility>
15
16
#include <
rex/result.h
>
17
#include <
rex/types.h
>
18
19
namespace
rex::filesystem {
20
22
enum class
FileSystemError
: u8 {
23
kNone = 0,
24
kNotFound
,
25
kPathNotFound
,
26
kExists,
27
kIsDirectory,
28
kNotDirectory,
29
kAccessDenied,
30
kEndOfFile
,
31
kUnsupported,
32
kNoMount,
33
kMountExists,
34
kInvalidPath
,
35
kCorrupt,
36
kIO,
37
kSharingViolation
,
38
kNotSameDevice
,
39
};
40
47
[[nodiscard]]
inline
rex::Error
BuildError
(
FileSystemError
code, std::string message) {
48
ErrorCategory
category = ErrorCategory::kIO;
49
switch
(code) {
50
case
FileSystemError::kNotFound
:
51
case
FileSystemError::kPathNotFound
:
52
case
FileSystemError::kNoMount:
53
category = ErrorCategory::kNotFound;
54
break
;
55
case
FileSystemError::kCorrupt:
56
category =
ErrorCategory::kFormat
;
57
break
;
58
case
FileSystemError::kUnsupported:
59
category = ErrorCategory::kNotImplemented;
60
break
;
61
default
:
62
break
;
63
}
64
return
{category, std::move(message),
static_cast<
int
>
(code)};
65
}
66
67
[[nodiscard]]
inline
FileSystemError CodeOf(
const
rex::Error
& error) {
68
return
static_cast<
FileSystemError
>
(error.
code
);
69
}
70
71
}
// namespace rex::filesystem
rex::filesystem::BuildError
rex::Error BuildError(FileSystemError code, std::string message)
Definition
file_system_error.h:47
rex::filesystem::FileSystemError
FileSystemError
Definition
file_system_error.h:22
rex::filesystem::FileSystemError::kNotSameDevice
@ kNotSameDevice
Definition
file_system_error.h:38
rex::filesystem::FileSystemError::kEndOfFile
@ kEndOfFile
Definition
file_system_error.h:30
rex::filesystem::FileSystemError::kInvalidPath
@ kInvalidPath
Definition
file_system_error.h:34
rex::filesystem::FileSystemError::kPathNotFound
@ kPathNotFound
Definition
file_system_error.h:25
rex::filesystem::FileSystemError::kSharingViolation
@ kSharingViolation
Definition
file_system_error.h:37
rex::filesystem::FileSystemError::kNotFound
@ kNotFound
Definition
file_system_error.h:24
rex::ErrorCategory
ErrorCategory
Definition
result.h:24
rex::ErrorCategory::kFormat
@ kFormat
Definition
result.h:28
result.h
rex::Error
Definition
result.h:43
rex::Error::code
int code
Definition
result.h:46
types.h
Integer types, byte order wrappers and size literals.
rex
filesystem
file_system_error.h
Generated by
1.18.0