Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Typedefs | Functions | Variables
dir_watch_inotify.cpp File Reference
#include "precompiled.h"
#include "lib/sysdep/dir_watch.h"
#include "lib/sysdep/sysdep.h"
#include "ps/CLogger.h"
#include <map>
#include <string>
#include <sys/inotify.h>

Go to the source code of this file.

Classes

struct  NotificationEvent
 
struct  DirWatch
 

Typedefs

typedef std::map< int, PDirWatchDirWatchMap
 

Functions

static void inotify_deinit ()
 
static void inotify_event_loop_process_events ()
 
static void * inotify_event_loop (void *)
 
Status dir_watch_Add (const OsPath &path, PDirWatch &dirWatch)
 start watching a single directory for changes. More...
 
Status dir_watch_Poll (DirWatchNotifications &notifications)
 return all pending directory watch notifications. More...
 

Variables

static std::vector
< NotificationEvent
g_notifications
 
static pthread_t g_event_loop_thread
 
static pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER
 
static int initialized = 0
 
static int inotifyfd
 
static DirWatchMap g_paths
 

Typedef Documentation

typedef std::map<int, PDirWatch> DirWatchMap

Definition at line 62 of file dir_watch_inotify.cpp.

Function Documentation

Status dir_watch_Add ( const OsPath path,
PDirWatch dirWatch 
)

start watching a single directory for changes.

Parameters
path(must end in slash)
dirWatchopaque smart pointer to the watch state; used to manage its lifetime (this is deemed more convenient than a separate dir_watch_Remove interface).

clients typically want to watch entire directory subtrees (e.g. a mod), which is supported by Windows but not FAM. to reduce overhead, the Windows backend always watches subtrees, but portable clients should still add a watch for each subdirectory (the shared watch state is reference-counted). rationale: since the VFS has per-directory data structures, it is convenient to store PDirWatch there instead of creating a second tree structure here.

Definition at line 171 of file dir_watch_inotify.cpp.

Status dir_watch_Poll ( DirWatchNotifications notifications)

return all pending directory watch notifications.

Parameters
notificationsreceives any pending notifications in unspecified order.
Returns
Status (INFO::OK doesn't imply notifications were returned)

note: the run time of this function is independent of the number of directory watches and number of files.

rationale for a polling interface: users (e.g. the main game loop) typically want to receive change notifications at a single point, rather than deal with the complexity of asynchronous notifications.

Definition at line 220 of file dir_watch_inotify.cpp.

static void inotify_deinit ( )
static

Definition at line 83 of file dir_watch_inotify.cpp.

static void* inotify_event_loop ( void *  )
static

Definition at line 135 of file dir_watch_inotify.cpp.

static void inotify_event_loop_process_events ( )
static

Definition at line 97 of file dir_watch_inotify.cpp.

Variable Documentation

pthread_t g_event_loop_thread
static

Definition at line 47 of file dir_watch_inotify.cpp.

Definition at line 51 of file dir_watch_inotify.cpp.

std::vector<NotificationEvent> g_notifications
static

Definition at line 46 of file dir_watch_inotify.cpp.

DirWatchMap g_paths
static

Definition at line 63 of file dir_watch_inotify.cpp.

int initialized = 0
static

Definition at line 56 of file dir_watch_inotify.cpp.

int inotifyfd
static

Definition at line 59 of file dir_watch_inotify.cpp.