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};
27
29enum class FileSystemWatcherErrorDetail : uint32_t
30{
31 None = 0,
32 AssignWatchPath,
33 BuildSubfolderPath,
34 BuildNotificationPath,
35 BuildFullPath,
36 WatchPathCapacity,
37 WorkerAlreadyStarted,
38 PosixPthreadCreate,
39 PosixPthreadJoin,
40 WindowsCreateThread,
41 WindowsWaitForSingleObject,
42 LinuxCreateShutdownPipe,
43 LinuxInitializeInotify,
44 LinuxWriteShutdownPipe,
45 LinuxInotifyDescriptor,
46 LinuxRemoveWatch,
47 LinuxAddRootWatch,
48 LinuxAddSubdirectoryWatch,
49 LinuxOpenRootDirectory,
50 LinuxWatchHandleCapacity,
51 LinuxPendingDirectoryCapacity,
52 LinuxRelativePathStorage,
53 AppleRunLoop,
54 AppleCreateRunLoopSource,
55 AppleAllocateWatchPaths,
56 AppleCreateWatchPathString,
57 AppleCreateWatchPathsArray,
58 AppleCreateEventStream,
59 AppleStartEventStream,
60 WindowsOpenDirectory,
61 WindowsSubmitDirectoryChanges,
62};
63
65static constexpr ResultCategory FileSystemWatcherResultCategory = ResultCategory(6);
66
71struct [[nodiscard]] ResultFileSystemWatcher
72{
73 Result result;
74 FileSystemWatcherErrorDetail detail = FileSystemWatcherErrorDetail::None;
75 uint32_t nativeError = 0;
76
77 explicit constexpr ResultFileSystemWatcher(bool valid = true) : result(valid) {}
79 FileSystemWatcherErrorDetail detail = FileSystemWatcherErrorDetail::None,
80 uint32_t nativeError = 0)
81 : result(Result::Error(FileSystemWatcherResultCategory, error)), detail(detail), nativeError(nativeError)
82 {}
83 constexpr ResultFileSystemWatcher(Result result) : result(result) {}
84
85 template <typename ResultLike>
86 constexpr ResultFileSystemWatcher(const ResultLike& other) : result(other.toResult())
87 {}
88
89 explicit constexpr operator bool() const { return static_cast<bool>(result); }
90
91 constexpr operator Result() const { return result; }
92
93 constexpr Result toResult() const { return result; }
94 constexpr bool isError(FileSystemWatcherError error) const
95 {
96 return result.isError(FileSystemWatcherResultCategory, error);
97 }
98};
99
101} // 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:30
FileSystemWatcher result retaining backend-stage and native-error context.
Definition FileSystemWatcherError.h:72