MRPT  1.9.9
mrpt::system::CFileSystemWatcher Class Reference

Detailed Description

This class subscribes to notifications of file system changes, thus it can be used to efficiently stay informed about changes in a directory tree.

  • Windows: Requires Windows 2000 or newer.
  • Linux: Requires kernel 2.6.13 or newer. Using this class in an old Linux or other unsoported system (Unix,etc...) has no effect, i.e. no notification will be ever received.
    See also
    CDirectoryExplorer

Definition at line 27 of file CFileSystemWatcher.h.

#include <mrpt/system/CFileSystemWatcher.h>

Classes

struct  TFileSystemChange
 Each of the changes detected by utils::CFileSystemWatcher. More...
 

Public Types

using TFileSystemChangeList = std::deque< TFileSystemChange >
 

Public Member Functions

 CFileSystemWatcher (const std::string &path)
 Creates the subscription to a specified path. More...
 
virtual ~CFileSystemWatcher ()
 Destructor. More...
 
void getChanges (TFileSystemChangeList &out_list)
 Call this method sometimes to get the list of changes in the watched directory. More...
 

Private Member Functions

void thread_win32_watch ()
 Watch thread; only needed in win32. More...
 

Private Attributes

std::string m_watchedDirectory
 Ended in "/". More...
 
voidm_hNotif {nullptr}
 
std::thread m_watchThread
 
std::queue< TFileSystemChange * > m_queue_events_win32_msgs
 
std::mutex m_queue_events_win32_cs
 

Member Typedef Documentation

◆ TFileSystemChangeList

Constructor & Destructor Documentation

◆ CFileSystemWatcher()

CFileSystemWatcher::CFileSystemWatcher ( const std::string path)

Creates the subscription to a specified path.

Parameters
pathThe file or directory to watch.

Definition at line 41 of file CFileSystemWatcher.cpp.

References ASSERT_, m_hNotif, m_watchedDirectory, m_watchThread, MRPT_END, MRPT_START, thread_win32_watch(), and THROW_EXCEPTION.

Here is the call graph for this function:

◆ ~CFileSystemWatcher()

CFileSystemWatcher::~CFileSystemWatcher ( )
virtual

Destructor.

Definition at line 91 of file CFileSystemWatcher.cpp.

References m_hNotif.

Member Function Documentation

◆ getChanges()

◆ thread_win32_watch()

void CFileSystemWatcher::thread_win32_watch ( )
private

Watch thread; only needed in win32.

Definition at line 257 of file CFileSystemWatcher.cpp.

References ASSERTMSG_, mrpt::system::directoryExists(), mrpt::system::CFileSystemWatcher::TFileSystemChange::eventCreated, mrpt::system::CFileSystemWatcher::TFileSystemChange::eventDeleted, mrpt::system::CFileSystemWatcher::TFileSystemChange::eventModified, mrpt::system::CFileSystemWatcher::TFileSystemChange::eventMovedFrom, mrpt::system::CFileSystemWatcher::TFileSystemChange::eventMovedTo, mrpt::system::CFileSystemWatcher::TFileSystemChange::isDir, m_hNotif, m_queue_events_win32_cs, m_queue_events_win32_msgs, m_watchedDirectory, and mrpt::system::CFileSystemWatcher::TFileSystemChange::path.

Referenced by CFileSystemWatcher().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_hNotif

void* mrpt::system::CFileSystemWatcher::m_hNotif {nullptr}
private

◆ m_queue_events_win32_cs

std::mutex mrpt::system::CFileSystemWatcher::m_queue_events_win32_cs
mutableprivate

Definition at line 74 of file CFileSystemWatcher.h.

Referenced by getChanges(), and thread_win32_watch().

◆ m_queue_events_win32_msgs

std::queue<TFileSystemChange*> mrpt::system::CFileSystemWatcher::m_queue_events_win32_msgs
private

Definition at line 73 of file CFileSystemWatcher.h.

Referenced by getChanges(), and thread_win32_watch().

◆ m_watchedDirectory

std::string mrpt::system::CFileSystemWatcher::m_watchedDirectory
private

Ended in "/".

Definition at line 67 of file CFileSystemWatcher.h.

Referenced by CFileSystemWatcher(), getChanges(), and thread_win32_watch().

◆ m_watchThread

std::thread mrpt::system::CFileSystemWatcher::m_watchThread
private

Definition at line 70 of file CFileSystemWatcher.h.

Referenced by CFileSystemWatcher().




Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019