Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
FileSystemWatcherError.h
1// Copyright (c) Stefano Cristiano
2// SPDX-License-Identifier: MIT
3#pragma once
4
5#include "../Common/Result.h"
6
7namespace SC
8{
11
13enum class FileSystemWatcherError : uint32_t
14{
15 NotInitialized = 1,
16 AlreadyWatching,
17 NotWatching,
18 UnsupportedPathEncoding,
19 PathPreparationFailed,
20 WatchLimitExceeded,
21 BufferTooSmall,
22 InitializationFailed,
23 WatchSetupFailed,
24 StopWatchingFailed,
25 CloseFailed,
26 MonitoringFailed,
27};
28
30enum class FileSystemWatcherErrorDetail : uint32_t
31{
32 None = 0,
33 AssignWatchPath,
34 BuildSubfolderPath,
35 BuildNotificationPath,
36 BuildFullPath,
37 WatchPathCapacity,
38 WorkerAlreadyStarted,
39 PosixPthreadCreate,
40 PosixPthreadJoin,
41 WindowsCreateThread,
42 WindowsWaitForSingleObject,
43 PosixCreateShutdownPipe,
44 InotifyInitialize,
45 PosixWriteShutdownPipe,
46 InotifyDescriptor,
47 InotifyRemoveWatch,
48 InotifyAddRootWatch,
49 InotifyAddSubdirectoryWatch,
50 InotifyOpenRootDirectory,
51 InotifyWatchHandleCapacity,
52 InotifyPendingDirectoryCapacity,
53 InotifyRelativePathStorage,
54 AppleRunLoop,
55 AppleCreateRunLoopSource,
56 AppleAllocateWatchPaths,
57 AppleCreateWatchPathString,
58 AppleCreateWatchPathsArray,
59 AppleCreateEventStream,
60 AppleStartEventStream,
61 WindowsOpenDirectory,
62 WindowsSubmitDirectoryChanges,
63 AppleOpenRootDirectory,
64 WindowsQueryRootDirectory,
65 InotifyOpenDirectoryStream,
66 InotifyReadDirectoryEntries,
67 InotifyInspectDirectoryEntry,
68 InotifyOpenSubdirectory,
69 InotifyReadEvents,
70 InotifyWaitForEvents,
71 InotifyWatchInvalidated,
72 AppleResolveWatchRoot,
73 AppleWatchInvalidated,
74 WindowsCompleteDirectoryChanges,
75 WindowsCreateWatchEvent,
76 WindowsSignalWatchEvent,
77 WindowsWaitForWatchEvents,
78 WindowsCancelDirectoryChanges,
79 InotifyVerifyDirectoryIdentity,
80};
81
83static constexpr ResultCategory FileSystemWatcherResultCategory = ResultCategory(6);
84
89struct [[nodiscard]] ResultFileSystemWatcher
90{
91 Result result;
92 FileSystemWatcherErrorDetail detail = FileSystemWatcherErrorDetail::None;
93 uint32_t nativeError = 0;
94
95 explicit constexpr ResultFileSystemWatcher(bool valid = true) : result(valid) {}
97 FileSystemWatcherErrorDetail detail = FileSystemWatcherErrorDetail::None,
98 uint32_t nativeError = 0)
99 : result(Result::Error(FileSystemWatcherResultCategory, error)), detail(detail), nativeError(nativeError)
100 {}
101 constexpr ResultFileSystemWatcher(Result result) : result(result) {}
102
103 template <typename ResultLike>
104 constexpr ResultFileSystemWatcher(const ResultLike& other) : result(other.toResult())
105 {}
106
107 explicit constexpr operator bool() const { return static_cast<bool>(result); }
108
109 constexpr operator Result() const { return result; }
110
111 constexpr Result toResult() const { return result; }
112 constexpr bool isError(FileSystemWatcherError error) const
113 {
114 return result.isError(FileSystemWatcherResultCategory, error);
115 }
116};
117
119} // namespace SC
FileSystemWatcherError
Stable portable failures returned by the FileSystemWatcher library.
Definition FileSystemWatcherError.h:14
FileSystemWatcherErrorDetail
Stable backend stages retained as context for a FileSystemWatcher failure.
Definition FileSystemWatcherError.h:31
FileSystemWatcher result retaining backend-stage and native-error context.
Definition FileSystemWatcherError.h:90