libfilezilla
Loading...
Searching...
No Matches
fsresult.hpp
Go to the documentation of this file.
1#ifndef LIBFILEZILLA_FSRESULT_HEADER
2#define LIBFILEZILLA_FSRESULT_HEADER
3
7
8#include "private/visibility.hpp"
9
10#include <stdint.h>
11#include <stddef.h>
12
13namespace fz {
14
25class FZ_PUBLIC_SYMBOL result
26{
27public:
29 enum error {
30 ok,
31 none = ok,
32
35
38
41
44
47
50
53
56
59 };
60
61#if FZ_WINDOWS
62 typedef uint32_t raw_t; // DWORD alternative without windows.h
63#else
64 typedef int raw_t;
65#endif
66
67 explicit operator bool() const { return error_ == 0; }
68
69 error error_{};
70
71 raw_t raw_{};
72};
73
82
83class FZ_PUBLIC_SYMBOL rwresult final
84{
85public:
86#if FZ_WINDOWS
87 typedef uint32_t raw_t; // DWORD alternative without windows.h
88#else
89 typedef int raw_t;
90#endif
91
92 enum error {
93 none,
94
97
100
103
106 };
107
108 rwresult() = default;
109
110 explicit rwresult(error e, raw_t raw)
111 : error_(e)
112 , raw_(raw)
113 {}
114 explicit rwresult(error e) = delete;
115
116 explicit rwresult(size_t value)
117 : value_(value)
118 {}
119
120 explicit operator bool() const { return error_ == 0; }
121
122 error error_{};
123
124 union {
126 raw_t raw_;
127
129 size_t value_{};
130 };
131};
132}
133
134#endif
Small class to return filesystem errors.
Definition fsresult.hpp:26
error
Filesystem operation result categories; raw_ retains the native error when available.
Definition fsresult.hpp:29
@ noperm
Permission denied.
Definition fsresult.hpp:37
@ preexisting
File already exists when asked to explicitly create a new file.
Definition fsresult.hpp:52
@ cross_device
Operation cannot cross filesystem boundaries.
Definition fsresult.hpp:55
@ nofile
Requested file does not exist or is not a file.
Definition fsresult.hpp:40
@ other
Some other error.
Definition fsresult.hpp:58
@ resource_limit
Dynamic resource utilization, like too many open files.
Definition fsresult.hpp:49
@ invalid
Invalid arguments, syntax error.
Definition fsresult.hpp:34
@ nospace
Out of disk space (physical, or space quota).
Definition fsresult.hpp:46
@ nodir
Requested dir does not exist or is not a dir.
Definition fsresult.hpp:43
Holds the result of read/write operations.
Definition fsresult.hpp:84
error
Definition fsresult.hpp:92
@ other
Some other error.
Definition fsresult.hpp:105
@ wouldblock
The operation would have blocked, but the file descriptor is marked non-blocking.
Definition fsresult.hpp:102
@ invalid
Invalid arguments, syntax error.
Definition fsresult.hpp:96
@ nospace
Out of disk space.
Definition fsresult.hpp:99
@ error
Error messages aimed at the user.
Definition logger.hpp:21
The namespace used by libfilezilla.
Definition apply.hpp:17
raw_t raw_
Undefined if error_ is none.
size_t value_
Undefined if error_ is not none.