libnick 2024.12.0
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Filesystem::FileSystemWatcher Class Reference

A watcher of a file system folder. More...

#include <filesystemwatcher.h>

Public Member Functions

 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.
 
 ~FileSystemWatcher ()
 Destructs a FileSystemWatcher.
 
const std::filesystem::path & getPath () const
 Gets the path of the folder being watched.
 
WatcherFlags getWatcherFlags () const
 Gets the flags of what to watch changes for.
 
bool getIncludeSubdirectories () const
 Gets whether or not subdirectories of the folder are watched.
 
Events::Event< FileSystemChangedEventArgs > & changed ()
 Gets the event for when a watched flag of the folder is changed.
 
bool isExtensionWatched (const std::filesystem::path &extension)
 Gets whether or not a file extension is being watched.
 
bool addExtensionFilter (const std::filesystem::path &extension)
 Adds an extension of a file to watch for changes in the folder.
 
bool removeExtensionFilter (const std::filesystem::path &extension)
 Removes an extension of a file to watch for changes in the folder.
 
bool clearExtensionFilters ()
 Clears all watched extension filters. This will cause all extensions to be implicitly watched.
 

Detailed Description

A watcher of a file system folder.

Constructor & Destructor Documentation

◆ FileSystemWatcher()

Nickvision::Filesystem::FileSystemWatcher::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.

Parameters
pathThe path of the folder to watch
includeSubdirectoriesWhether or not to include subdirectories for the folder
watcherFlagsThe flags of what to watch changes for
Exceptions
std::runtime_errorThrown if unable to initialize watcher

◆ ~FileSystemWatcher()

Nickvision::Filesystem::FileSystemWatcher::~FileSystemWatcher ( )

Destructs a FileSystemWatcher.

Member Function Documentation

◆ addExtensionFilter()

bool Nickvision::Filesystem::FileSystemWatcher::addExtensionFilter ( const std::filesystem::path & extension)

Adds an extension of a file to watch for changes in the folder.

Parameters
extensionThe file extension to add
Returns
True if successful, else false

◆ changed()

Events::Event< FileSystemChangedEventArgs > & Nickvision::Filesystem::FileSystemWatcher::changed ( )

Gets the event for when a watched flag of the folder is changed.

Returns
The changed event

◆ clearExtensionFilters()

bool Nickvision::Filesystem::FileSystemWatcher::clearExtensionFilters ( )

Clears all watched extension filters. This will cause all extensions to be implicitly watched.

Returns
True if successful, else false

◆ getIncludeSubdirectories()

bool Nickvision::Filesystem::FileSystemWatcher::getIncludeSubdirectories ( ) const

Gets whether or not subdirectories of the folder are watched.

Returns
True if subdirectories watched, else false

◆ getPath()

const std::filesystem::path & Nickvision::Filesystem::FileSystemWatcher::getPath ( ) const

Gets the path of the folder being watched.

Returns
The path of the folder being watched

◆ getWatcherFlags()

WatcherFlags Nickvision::Filesystem::FileSystemWatcher::getWatcherFlags ( ) const

Gets the flags of what to watch changes for.

Returns
The flags of watched properties

◆ isExtensionWatched()

bool Nickvision::Filesystem::FileSystemWatcher::isExtensionWatched ( const std::filesystem::path & extension)

Gets whether or not a file extension is being watched.

Parameters
extensionThe file extension to check
Returns
True if extension is being watched, else false
True if list of extension filters is empty

◆ removeExtensionFilter()

bool Nickvision::Filesystem::FileSystemWatcher::removeExtensionFilter ( const std::filesystem::path & extension)

Removes an extension of a file to watch for changes in the folder.

Parameters
extensionThe file extension to remove
Returns
True if successful, else false

The documentation for this class was generated from the following file: