5#include "../Async/Async.h"
6#include "../Foundation/Function.h"
7#include "../Foundation/OpaqueObject.h"
8#include "../Foundation/Result.h"
9#include "../Threading/Threading.h"
43 struct ThreadRunnerInternal;
44 struct ThreadRunnerDefinition
46 static constexpr int MaxWatchablePaths = 1024;
47 static constexpr int Windows =
49 static constexpr int Apple =
sizeof(
void*);
50 static constexpr int Linux =
sizeof(
Thread) +
sizeof(
void*) * 2;
51 static constexpr int Default = Linux;
53 static constexpr size_t Alignment =
alignof(
void*);
55 using Object = ThreadRunnerInternal;
58 struct FolderWatcherInternal;
59 struct FolderWatcherSizes
61 static constexpr int MaxNumberOfSubdirs = 128;
62 static constexpr int MaxChangesBufferSize = 1024;
63 static constexpr int Windows =
65 static constexpr int Apple =
sizeof(
void*);
66 static constexpr int Linux = 1056;
67 static constexpr int Default = Linux;
69 static constexpr size_t Alignment =
alignof(
void*);
71 using Object = FolderWatcherInternal;
73 struct InternalDefinition
75 static constexpr int Windows = 3 *
sizeof(
void*);
76 static constexpr int Apple = 43 *
sizeof(
void*) +
sizeof(
Mutex);
77 static constexpr int Linux =
sizeof(
void*) * 4;
78 static constexpr int Default = Linux;
80 static constexpr size_t Alignment =
alignof(
void*);
82 using Object = Internal;
111 friend struct Internal;
153#elif SC_PLATFORM_LINUX
184 friend decltype(internal);
185 friend decltype(FolderWatcher::internal);
186 IntrusiveDoubleLinkedList<FolderWatcher> watchers;
unsigned long long uint64_t
Platform independent (8) bytes unsigned int.
Definition PrimitiveTypes.h:42
Asynchronous I/O (files, sockets, timers, processes, fs events, threads wake-up) (see Async) AsyncEve...
Definition Async.h:1187
Starts an handle polling operation.
Definition Async.h:820
Starts a wake-up operation, allowing threads to execute callbacks on loop thread.
Definition Async.h:339
An automatically reset event object to synchronize two threads.
Definition Threading.h:174
Open, read and write to/from a file descriptor (like a file or pipe).
Definition File.h:76
Delivers notifications using Async (SC::AsyncEventLoop).
Definition FileSystemWatcher.h:145
Represents a single folder being watched.
Definition FileSystemWatcher.h:121
Function< void(const Notification &)> notifyCallback
Function that will be called on a notification.
Definition FileSystemWatcher.h:122
void setDebugName(const char *debugName)
Sets debug name for AsyncFilePoll used on Windows (used only for debug purposes)
Result stopWatching()
Stop watching this directory.
Notification holding type and path.
Definition FileSystemWatcher.h:100
StringSpan relativePath
Relative path of the file being notified from basePath
Definition FileSystemWatcher.h:102
Operation operation
Notification type.
Definition FileSystemWatcher.h:103
StringSpan basePath
Reference to the watched directory.
Definition FileSystemWatcher.h:101
SC::Result getFullPath(StringPath &path) const
Get the full path of the file being watched.
Notifies about events (add, remove, rename, modified) on files and directories.
Definition FileSystemWatcher.h:40
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 init(EventLoopRunner &runner, AsyncEventLoop &eventLoop)
Setup watcher to receive async notifications on SC::AsyncEventLoop.
Operation
Specifies the event classes.
Definition FileSystemWatcher.h:93
@ 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.
Result watch(FolderWatcher &watcher, StringSpan path)
Starts watching a single directory, calling FolderWatcher::notifyCallback on file events.
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
Pre-sized char array holding enough space to represent a file system path.
Definition StringPath.h:10
An read-only view over a string (to avoid including Strings library when parsing is not needed).
Definition StringSpan.h:31
A native OS thread.
Definition Threading.h:118