libfilezilla
fsresult.hpp
1 #ifndef LIBFILEZILLA_FSRESULT_HEADER
2 #define LIBFILEZILLA_FSRESULT_HEADER
3 
4 #include "private/visibility.hpp"
5 
6 #include <stdint.h>
7 #include <stddef.h>
8 
9 namespace fz {
10 
21 class FZ_PUBLIC_SYMBOL result
22 {
23 public:
24  enum error {
25  ok,
26  none = ok,
27 
30 
33 
36 
39 
42 
44  other
45  };
46 
47 #if FZ_WINDOWS
48  typedef uint32_t raw_t; // DWORD alternative without windows.h
49 #else
50  typedef int raw_t;
51 #endif
52 
53  explicit operator bool() const { return error_ == 0; }
54 
55  error error_{};
56 
57  raw_t raw_{};
58 };
59 
60 class FZ_PUBLIC_SYMBOL rwresult final
61 {
62 public:
63 #if FZ_WINDOWS
64  typedef uint32_t raw_t; // DWORD alternative without windows.h
65 #else
66  typedef int raw_t;
67 #endif
68 
69  enum error {
70  none,
71 
74 
77 
80 
82  other
83  };
84 
85  explicit rwresult(error e, raw_t raw)
86  : error_(e)
87  , raw_(raw)
88  , value_(-1)
89  {}
90 
91  explicit rwresult(size_t value)
92  : value_(value)
93  {}
94 
95  explicit operator bool() const { return error_ == 0; }
96 
97  error error_{};
98 
100  raw_t raw_{};
101 
103  size_t value_{};
104 };
105 }
106 
107 #endif
Small class to return filesystem errors.
Definition: fsresult.hpp:22
error
Definition: fsresult.hpp:24
@ noperm
Permission denied.
Definition: fsresult.hpp:32
@ nofile
Requested file does not exist or is not a file.
Definition: fsresult.hpp:35
@ invalid
Invalid arguments, syntax error.
Definition: fsresult.hpp:29
@ nospace
Out of disk space.
Definition: fsresult.hpp:41
@ nodir
Requested dir does not exist or is not a dir.
Definition: fsresult.hpp:38
Definition: fsresult.hpp:61
error
Definition: fsresult.hpp:69
@ wouldblock
The operation would have blocked, but the file descriptor is marked non-blocking.
Definition: fsresult.hpp:79
@ invalid
Invalid arguments, syntax error.
Definition: fsresult.hpp:73
@ nospace
Out of disk space.
Definition: fsresult.hpp:76
@ error
Error messages aimed at the user.
Definition: logger.hpp:21
The namespace used by libfilezilla.
Definition: apply.hpp:17