libfilezilla
fsresult.hpp
Go to the documentation of this file.
1 #ifndef LIBFILEZILLA_FSRESULT_HEADER
2 #define LIBFILEZILLA_FSRESULT_HEADER
3 
8 #include "private/visibility.hpp"
9 
10 #include <stdint.h>
11 #include <stddef.h>
12 
13 namespace fz {
14 
25 class FZ_PUBLIC_SYMBOL result
26 {
27 public:
28  enum error {
29  ok,
30  none = ok,
31 
34 
37 
40 
43 
46 
48  other
49  };
50 
51 #if FZ_WINDOWS
52  typedef uint32_t raw_t; // DWORD alternative without windows.h
53 #else
54  typedef int raw_t;
55 #endif
56 
57  explicit operator bool() const { return error_ == 0; }
58 
59  error error_{};
60 
61  raw_t raw_{};
62 };
63 
73 class FZ_PUBLIC_SYMBOL rwresult final
74 {
75 public:
76 #if FZ_WINDOWS
77  typedef uint32_t raw_t; // DWORD alternative without windows.h
78 #else
79  typedef int raw_t;
80 #endif
81 
82  enum error {
83  none,
84 
87 
90 
93 
95  other
96  };
97 
98  explicit rwresult(error e, raw_t raw)
99  : error_(e)
100  , raw_(raw)
101  , value_(-1)
102  {}
103 
104  explicit rwresult(size_t value)
105  : value_(value)
106  {}
107 
108  explicit operator bool() const { return error_ == 0; }
109 
110  error error_{};
111 
113  raw_t raw_{};
114 
116  size_t value_{};
117 };
118 }
119 
120 #endif
Small class to return filesystem errors.
Definition: fsresult.hpp:26
error
Definition: fsresult.hpp:28
@ noperm
Permission denied.
Definition: fsresult.hpp:36
@ nofile
Requested file does not exist or is not a file.
Definition: fsresult.hpp:39
@ invalid
Invalid arguments, syntax error.
Definition: fsresult.hpp:33
@ nospace
Out of disk space.
Definition: fsresult.hpp:45
@ nodir
Requested dir does not exist or is not a dir.
Definition: fsresult.hpp:42
Holds the result of read/write operations.
Definition: fsresult.hpp:74
error
Definition: fsresult.hpp:82
@ wouldblock
The operation would have blocked, but the file descriptor is marked non-blocking.
Definition: fsresult.hpp:92
@ invalid
Invalid arguments, syntax error.
Definition: fsresult.hpp:86
@ nospace
Out of disk space.
Definition: fsresult.hpp:89
@ error
Error messages aimed at the user.
Definition: logger.hpp:21
The namespace used by libfilezilla.
Definition: apply.hpp:17
@ ok
Success, proceed.