23#ifndef FILESYSTEMWATCHER_H
24#define FILESYSTEMWATCHER_H
35#elif defined(__APPLE__)
36#include <CoreServices/CoreServices.h>
63 const std::filesystem::path&
getPath()
const;
109 std::thread m_watchThread;
110 mutable std::mutex m_mutex;
111 std::filesystem::path m_path;
112 bool m_includeSubdirectories;
116 std::vector<std::filesystem::path> m_extensionFilters;
118 HANDLE m_terminateEvent;
119#elif defined(__linux__)
121#elif defined(__APPLE__)
122 static void callback(ConstFSEventStreamRef stream,
void* clientCallBackInfo,
size_t numEvents,
void* eventPaths,
const FSEventStreamEventFlags eventFlags[],
const FSEventStreamEventId eventIds[]);
123 FSEventStreamRef m_stream;
124 CFRunLoopRef m_runLoop;
An event that can have handlers subscribe to it, which in turn will be called when the event is invok...
Definition event.h:49
A watcher of a file system folder.
Definition filesystemwatcher.h:45
WatcherFlags getWatcherFlags() const
Gets the flags of what to watch changes for.
bool addExtensionFilter(const std::filesystem::path &extension)
Adds an extension of a file to watch for changes in the folder.
bool getIncludeSubdirectories() const
Gets whether or not subdirectories of the folder are watched.
const std::filesystem::path & getPath() const
Gets the path of the folder being watched.
Events::Event< FileSystemChangedEventArgs > & changed()
Gets the event for when a watched flag of the folder is changed.
bool clearExtensionFilters()
Clears all watched extension filters. This will cause all extensions to be implicitly watched.
~FileSystemWatcher()
Destructs a FileSystemWatcher.
bool removeExtensionFilter(const std::filesystem::path &extension)
Removes an extension of a file to watch for changes in the folder.
FileSystemWatcher(const std::filesystem::path &path, bool includeSubdirectories, WatcherFlags watcherFlags=WatcherFlags::FileName|WatcherFlags::DirectoryName|WatcherFlags::Attributes|WatcherFlags::Size|WatcherFlags::LastWrite|WatcherFlags::LastAccess)
Constructs a FileSystemWatcher.
bool isExtensionWatched(const std::filesystem::path &extension)
Gets whether or not a file extension is being watched.
Definition applicationuserdirectory.h:27
WatcherFlags
Flags to describe properties of a file system object that can change.
Definition watcherflags.h:32
@ DirectoryName
The name of a directory in the file system object has changed.
@ LastWrite
The last write time of an item in the file system object has changed.
@ FileName
The name of a file in the file system object has changed.
@ Attributes
The attributes of an item in the file system object have changed.
@ LastAccess
The last access time of an item in the file system object has changed.
@ Size
The size of an item in the file system object has changed.