5#include "../Async/Async.h"
6#include "../Containers/IntrusiveDoubleLinkedList.h"
7#include "../Foundation/Function.h"
8#include "../Foundation/OpaqueObject.h"
9#include "../Foundation/Result.h"
10#include "../Strings/SmallString.h"
11#include "../Threading/Threading.h"
15struct FileSystemWatcher;
48 struct ThreadRunnerInternal;
49 struct ThreadRunnerDefinition
51 static constexpr int MaxWatchablePaths = 1024;
52 static constexpr int Windows =
54 static constexpr int Apple =
sizeof(
void*);
55 static constexpr int Default =
sizeof(
Thread) +
sizeof(
void*) * 2;
57 static constexpr size_t Alignment =
alignof(
void*);
59 using Object = ThreadRunnerInternal;
62 struct FolderWatcherInternal;
63 struct FolderWatcherSizes
65 static constexpr int MaxNumberOfSubdirs = 128;
66 static constexpr int MaxChangesBufferSize = 1024;
67 static constexpr int Windows =
69 static constexpr int Apple =
sizeof(
void*);
70 static constexpr int Default =
73 static constexpr size_t Alignment =
alignof(
void*);
75 using Object = FolderWatcherInternal;
77 struct InternalDefinition
79 static constexpr int Windows = 3 *
sizeof(
void*);
80 static constexpr int Apple = 43 *
sizeof(
void*) +
sizeof(
Mutex);
81 static constexpr int Default =
sizeof(
void*) * 4;
83 static constexpr size_t Alignment =
alignof(
void*);
85 using Object = Internal;
115 friend struct Internal;
153#elif SC_PLATFORM_LINUX
184 friend decltype(
internal);
185 friend decltype(FolderWatcher::internal);
unsigned long long uint64_t
Platform independent (8) bytes unsigned int.
Definition: PrimitiveTypes.h:42
A contiguous sequence of elements kept inside its inline storage.
Definition: Array.h:43
Asynchronous I/O (files, sockets, timers, processes, fs events, threads wake-up) (see Async) AsyncEve...
Definition: Async.h:933
Starts an handle polling operation.
Definition: Async.h:883
Starts a wake-up operation, allowing threads to execute callbacks on loop thread.
Definition: Async.h:346
An automatically reset event object to synchronize two threads.
Definition: Threading.h:174
Wraps an OS File descriptor to read and write to and from it.
Definition: FileDescriptor.h:57
Delivers notifications using Async (SC::AsyncEventLoop).
Definition: FileSystemWatcher.h:145
Represents a single folder being watched.
Definition: FileSystemWatcher.h:125
Function< void(const Notification &)> notifyCallback
Function that will be called on a notification.
Definition: FileSystemWatcher.h:126
Result stopWatching()
Stop watching this directory.
Notification holding type and path.
Definition: FileSystemWatcher.h:103
SC::Result getFullPath(String &bufferString, StringView &outFullPath) const
Get the full path of the file being watched.
StringView basePath
Reference to the watched directory.
Definition: FileSystemWatcher.h:104
Operation operation
Notification type.
Definition: FileSystemWatcher.h:106
StringView relativePath
Relative path of the file being notified from basePath
Definition: FileSystemWatcher.h:105
Notifies about events (add, remove, rename, modified) on files and directories.
Definition: FileSystemWatcher.h:45
Result close()
Stops all watchers and frees the ThreadRunner or EventLoopRunner passed in init.
Result init(ThreadRunner &runner)
Setup watcher to receive notifications from a background thread.
Result watch(FolderWatcher &watcher, StringView path)
Starts watching a single directory, calling FolderWatcher::notifyCallback on file events.
Result init(EventLoopRunner &runner, AsyncEventLoop &eventLoop)
Setup watcher to receive async notifications on SC::AsyncEventLoop.
Operation
Specifies the event classes.
Definition: FileSystemWatcher.h:96
@ Modified
A file or directory has been modified in its contents and/or timestamp.
@ AddRemoveRename
A file or directory has been added, removed or renamed.
Wraps function pointers, member functions and lambdas without ever allocating.
Definition: Function.h:50
An Intrusive Double Linked List.
Definition: IntrusiveDoubleLinkedList.h:22
A native OS mutex to synchronize access to shared resources.
Definition: Threading.h:28
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition: Result.h:12
String with compile time configurable inline storage (small string optimization)
Definition: SmallString.h:21
A non-modifiable owning string with associated encoding.
Definition: String.h:30
Non-owning view over a range of characters with UTF Encoding.
Definition: StringView.h:47
A native OS thread.
Definition: Threading.h:118
A contiguous sequence of heap allocated elements.
Definition: Vector.h:51