ReXGlue SDK
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
19namespace rex::filesystem {
20
22enum class FileSystemError : u8 {
23 kNone = 0,
26 kExists,
27 kIsDirectory,
28 kNotDirectory,
29 kAccessDenied,
31 kUnsupported,
32 kNoMount,
33 kMountExists,
35 kCorrupt,
36 kIO,
39};
40
47[[nodiscard]] inline rex::Error BuildError(FileSystemError code, std::string message) {
48 ErrorCategory category = ErrorCategory::kIO;
49 switch (code) {
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::Error BuildError(FileSystemError code, std::string message)
Definition file_system_error.h:47
FileSystemError
Definition file_system_error.h:22
@ kNotSameDevice
Definition file_system_error.h:38
@ kEndOfFile
Definition file_system_error.h:30
@ kInvalidPath
Definition file_system_error.h:34
@ kPathNotFound
Definition file_system_error.h:25
@ kSharingViolation
Definition file_system_error.h:37
@ kNotFound
Definition file_system_error.h:24
ErrorCategory
Definition result.h:24
@ kFormat
Definition result.h:28
Definition result.h:43
int code
Definition result.h:46
Integer types, byte order wrappers and size literals.