Pyrogenesis  trunk
Classes | Typedefs | Functions | Variables
wdir_watch.cpp File Reference
#include "precompiled.h"
#include "lib/sysdep/dir_watch.h"
#include "lib/allocators/shared_ptr.h"
#include "lib/path.h"
#include "lib/sysdep/os/win/win.h"
#include "lib/sysdep/os/win/winit.h"
#include "lib/sysdep/os/win/wutil.h"
#include "lib/sysdep/os/win/wiocp.h"
Include dependency graph for wdir_watch.cpp:

Classes

class  DirHandle
 
class  DirWatchRequest
 
class  IntrusiveLink
 
struct  DirWatch
 
class  DirWatchManager
 

Typedefs

typedef std::shared_ptr< DirWatchRequestPDirWatchRequest
 

Functions

 WINIT_REGISTER_MAIN_INIT (wdir_watch_Init)
 
 WINIT_REGISTER_MAIN_SHUTDOWN (wdir_watch_Shutdown)
 
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...
 
static Status wdir_watch_Init ()
 
static Status wdir_watch_Shutdown ()
 

Variables

static DirWatchManagers_dirWatchManager
 

Typedef Documentation

◆ PDirWatchRequest

typedef std::shared_ptr<DirWatchRequest> PDirWatchRequest

Function Documentation

◆ dir_watch_Add()

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.

◆ dir_watch_Poll()

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.

◆ wdir_watch_Init()

static Status wdir_watch_Init ( )
static

◆ wdir_watch_Shutdown()

static Status wdir_watch_Shutdown ( )
static

◆ WINIT_REGISTER_MAIN_INIT()

WINIT_REGISTER_MAIN_INIT ( wdir_watch_Init  )

◆ WINIT_REGISTER_MAIN_SHUTDOWN()

WINIT_REGISTER_MAIN_SHUTDOWN ( wdir_watch_Shutdown  )

Variable Documentation

◆ s_dirWatchManager

DirWatchManager* s_dirWatchManager
static