General Purpose library for Freestanding C++ and POSIX systems
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

304 linhas
6.4 KiB

4 anos atrás
4 anos atrás
  1. #pragma once
  2. #include "gp_config.hpp"
  3. #include "gp/buffer.hpp"
  4. #include "gp/variant.hpp"
  5. namespace gp {
  6. namespace fs {
  7. struct bad_file final {
  8. static constexpr auto _what = "bad_file";
  9. constexpr auto what() {
  10. return _what;
  11. }
  12. };
  13. struct faulty_buffer final {
  14. static constexpr auto _what = "faulty_buffer";
  15. constexpr auto what() {
  16. return _what;
  17. }
  18. };
  19. struct interrupted final {
  20. static constexpr auto _what = "interrupted";
  21. constexpr auto what() {
  22. return _what;
  23. }
  24. };
  25. struct io_error final {
  26. static constexpr auto _what = "io_error";
  27. constexpr auto what() {
  28. return _what;
  29. }
  30. };
  31. struct is_directory final {
  32. static constexpr auto _what = "is_directory";
  33. constexpr auto what() {
  34. return _what;
  35. }
  36. };
  37. struct try_again final {
  38. static constexpr auto _what = "try_again";
  39. constexpr auto what() {
  40. return _what;
  41. }
  42. };
  43. struct not_connected final {
  44. static constexpr auto _what = "not_connected";
  45. constexpr auto what() {
  46. return _what;
  47. }
  48. };
  49. struct impossible_io final {
  50. static constexpr auto _what = "impossible_io";
  51. constexpr auto what() {
  52. return _what;
  53. }
  54. };
  55. struct negative_offset final {
  56. static constexpr auto _what = "negative_offset";
  57. constexpr auto what() {
  58. return _what;
  59. }
  60. };
  61. struct is_pipe final {
  62. static constexpr auto _what = "is_pipe";
  63. constexpr auto what() {
  64. return _what;
  65. }
  66. };
  67. struct buffer_too_big final {
  68. static constexpr auto _what = "buffer_too_big";
  69. constexpr auto what() {
  70. return _what;
  71. }
  72. };
  73. struct path_not_directory final {
  74. static constexpr auto _what = "path_not_directory";
  75. constexpr auto what() {
  76. return _what;
  77. }
  78. };
  79. struct name_too_long final {
  80. static constexpr auto _what = "name_too_long";
  81. constexpr auto what() {
  82. return _what;
  83. }
  84. };
  85. struct does_not_exist final {
  86. static constexpr auto _what = "does_not_exist";
  87. constexpr auto what() {
  88. return _what;
  89. }
  90. };
  91. struct may_loop final {
  92. static constexpr auto _what = "may_loop";
  93. constexpr auto what() {
  94. return _what;
  95. }
  96. };
  97. struct invalid_flags final {
  98. static constexpr auto _what = "invalid_flags";
  99. constexpr auto what() {
  100. return _what;
  101. }
  102. };
  103. struct is_read_only final {
  104. static constexpr auto _what = "is_read_only";
  105. constexpr auto what() {
  106. return _what;
  107. }
  108. };
  109. struct fd_limit_reached final {
  110. static constexpr auto _what = "fd_limit_reached";
  111. constexpr auto what() {
  112. return _what;
  113. }
  114. };
  115. struct file_limit_reached final {
  116. static constexpr auto _what = "file_limit_reached";
  117. constexpr auto what() {
  118. return _what;
  119. }
  120. };
  121. struct no_locking final {
  122. static constexpr auto _what = "no_locking";
  123. constexpr auto what() {
  124. return _what;
  125. }
  126. };
  127. struct would_block final {
  128. static constexpr auto _what = "would_block";
  129. constexpr auto what() {
  130. return _what;
  131. }
  132. };
  133. struct no_inodes final {
  134. static constexpr auto _what = "no_inodes";
  135. constexpr auto what() {
  136. return _what;
  137. }
  138. };
  139. struct no_space final {
  140. static constexpr auto _what = "no_space";
  141. constexpr auto what() {
  142. return _what;
  143. }
  144. };
  145. struct quota_reached final {
  146. static constexpr auto _what = "quota_reached";
  147. constexpr auto what() {
  148. return _what;
  149. }
  150. };
  151. struct cannot_write_shared_text final {
  152. static constexpr auto _what = "cannot_write_shared_text";
  153. constexpr auto what() {
  154. return _what;
  155. }
  156. };
  157. struct faulty_filename final {
  158. static constexpr auto _what = "faulty_filename";
  159. constexpr auto what() {
  160. return _what;
  161. }
  162. };
  163. struct exists_already final {
  164. static constexpr auto _what = "exists_already";
  165. constexpr auto what() {
  166. return _what;
  167. }
  168. };
  169. struct is_append_only final {
  170. static constexpr auto _what = "is_append_only";
  171. constexpr auto what() {
  172. return _what;
  173. }
  174. };
  175. struct unimplemented_operation final {
  176. static constexpr auto _what = "unimplemented_operation";
  177. constexpr auto what() {
  178. return _what;
  179. }
  180. };
  181. struct is_busy final {
  182. static constexpr auto _what = "is_busy";
  183. constexpr auto what() {
  184. return _what;
  185. }
  186. };
  187. struct bad_relative_path final {
  188. static constexpr auto _what = "bad_relative_path";
  189. constexpr auto what() {
  190. return _what;
  191. }
  192. };
  193. struct no_permissions final {
  194. static constexpr auto _what = "no_permissions";
  195. constexpr auto what() {
  196. return _what;
  197. }
  198. };
  199. struct success final {
  200. static constexpr auto _what = "success";
  201. constexpr auto what() {
  202. return _what;
  203. }
  204. };
  205. struct too_big final {
  206. static constexpr auto _what = "too_big";
  207. constexpr auto what() {
  208. return _what;
  209. }
  210. };
  211. struct network_down final {
  212. static constexpr auto _what = "network_down";
  213. constexpr auto what() {
  214. return _what;
  215. }
  216. };
  217. struct destination_not_available final {
  218. static constexpr auto _what = "destination_not_available";
  219. constexpr auto what() {
  220. return _what;
  221. }
  222. };
  223. struct insufficient_buffer_space final {
  224. static constexpr auto _what = "insufficient_buffer_space";
  225. constexpr auto what() {
  226. return _what;
  227. }
  228. };
  229. using read_return = gp::fixed_variant<
  230. typename buffer<char>::associated_iterator, // iterator to last element read
  231. bad_file,
  232. faulty_buffer,
  233. interrupted,
  234. io_error,
  235. is_directory,
  236. try_again,
  237. not_connected,
  238. impossible_io,
  239. negative_offset,
  240. is_pipe,
  241. buffer_too_big
  242. >;
  243. using open_return = gp::fixed_variant<
  244. gp_config::file_descriptor_t,
  245. path_not_directory,
  246. name_too_long,
  247. does_not_exist,
  248. may_loop,
  249. is_directory,
  250. invalid_flags,
  251. is_read_only,
  252. fd_limit_reached,
  253. file_limit_reached,
  254. impossible_io,
  255. interrupted,
  256. no_locking,
  257. would_block,
  258. no_space,
  259. no_inodes,
  260. quota_reached,
  261. io_error,
  262. cannot_write_shared_text,
  263. faulty_filename,
  264. exists_already,
  265. is_append_only,
  266. unimplemented_operation,
  267. is_busy,
  268. bad_relative_path,
  269. no_permissions
  270. >;
  271. using close_return = gp::fixed_variant<
  272. success,
  273. bad_file,
  274. interrupted,
  275. io_error
  276. >;
  277. using write_return = gp::fixed_variant<
  278. typename buffer<char>::associated_iterator,
  279. bad_file,
  280. no_space,
  281. quota_reached,
  282. too_big,
  283. interrupted,
  284. io_error,
  285. faulty_buffer,
  286. is_pipe,
  287. try_again,
  288. network_down,
  289. destination_not_available,
  290. impossible_io,
  291. buffer_too_big,
  292. negative_offset,
  293. insufficient_buffer_space
  294. >;
  295. class file_flags{};
  296. class file_permissions{};
  297. }
  298. }