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 Linux =
sizeof(
Thread) +
sizeof(
void*) * 2;
56 static constexpr int Default = Linux;
58 static constexpr size_t Alignment =
alignof(
void*);
60 using Object = ThreadRunnerInternal;
63 struct FolderWatcherInternal;
64 struct FolderWatcherSizes
66 static constexpr int MaxNumberOfSubdirs = 128;
67 static constexpr int MaxChangesBufferSize = 1024;
68 static constexpr int Windows =
70 static constexpr int Apple =
sizeof(
void*);
72 static constexpr int Default = Linux;
74 static constexpr size_t Alignment =
alignof(
void*);
76 using Object = FolderWatcherInternal;
78 struct InternalDefinition
80 static constexpr int Windows = 3 *
sizeof(
void*);
81 static constexpr int Apple = 43 *
sizeof(
void*) +
sizeof(
Mutex);
82 static constexpr int Linux =
sizeof(
void*) * 4;
83 static constexpr int Default = Linux;
85 static constexpr size_t Alignment =
alignof(
void*);
87 using Object = Internal;
117 friend struct Internal;
155#elif SC_PLATFORM_LINUX
186 friend decltype(
internal);
187 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:956
Starts an handle polling operation.
Definition: Async.h:906
Starts a wake-up operation, allowing threads to execute callbacks on loop thread.
Definition: Async.h:369
An automatically reset event object to synchronize two threads.
Definition: Threading.h:174
File Descriptor (use SC::File to open and use it with strings and containers).
Definition: FileDescriptor.h:52
Delivers notifications using Async (SC::AsyncEventLoop).
Definition: FileSystemWatcher.h:147
Represents a single folder being watched.
Definition: FileSystemWatcher.h:127
Function< void(const Notification &)> notifyCallback
Function that will be called on a notification.
Definition: FileSystemWatcher.h:128
Result stopWatching()
Stop watching this directory.
Notification holding type and path.
Definition: FileSystemWatcher.h:105
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:106
Operation operation
Notification type.
Definition: FileSystemWatcher.h:108
StringView relativePath
Relative path of the file being notified from basePath
Definition: FileSystemWatcher.h:107
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:98
@ 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