clang 19.0.0git
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
clang::DirectoryWatcher Class Reference

Provides notifications for file changes in a directory. More...

#include "clang/DirectoryWatcher/DirectoryWatcher.h"

Classes

struct  Event
 

Public Member Functions

virtual ~DirectoryWatcher ()=default
 
 DirectoryWatcher (const DirectoryWatcher &)=delete
 
DirectoryWatcheroperator= (const DirectoryWatcher &)=delete
 
 DirectoryWatcher (DirectoryWatcher &&)=default
 

Static Public Member Functions

static llvm::Expected< std::unique_ptr< DirectoryWatcher > > create (llvm::StringRef Path, std::function< void(llvm::ArrayRef< DirectoryWatcher::Event > Events, bool IsInitial)> Receiver, bool WaitForInitialSync)
 llvm fatal_error if
 

Protected Member Functions

 DirectoryWatcher ()=default
 

Detailed Description

Provides notifications for file changes in a directory.

Invokes client-provided function on every filesystem event in the watched directory. Initially the watched directory is scanned and for every file found, an event is synthesized as if the file was added.

This is not a general purpose directory monitoring tool - list of limitations follows.

Only flat directories with no subdirectories are supported. In case subdirectories are present the behavior is unspecified - events might be passed to Receiver on macOS (due to FSEvents being used) while they probably won't be passed on Linux (due to inotify being used).

Known potential inconsistencies

Notifications are provided only for changes done through local user-space filesystem interface. Specifically, it's unspecified if notification would be provided in case of a:

No support for LLVM VFS.

It is unspecified whether notifications for files being deleted are sent in case the whole watched directory is sent.

Directories containing "too many" files and/or receiving events "too frequently" are not supported - if the initial scan can't be finished before the watcher instance gets invalidated (see WatcherGotInvalidated) there's no good error handling strategy - the only option for client is to destroy the watcher, restart watching with new instance and hope it won't repeat.

Definition at line 64 of file DirectoryWatcher.h.

Constructor & Destructor Documentation

◆ ~DirectoryWatcher()

virtual clang::DirectoryWatcher::~DirectoryWatcher ( )
virtualdefault

◆ DirectoryWatcher() [1/3]

clang::DirectoryWatcher::DirectoryWatcher ( const DirectoryWatcher )
delete

◆ DirectoryWatcher() [2/3]

clang::DirectoryWatcher::DirectoryWatcher ( DirectoryWatcher &&  )
default

◆ DirectoryWatcher() [3/3]

clang::DirectoryWatcher::DirectoryWatcher ( )
protecteddefault

Member Function Documentation

◆ create()

llvm::Expected< std::unique_ptr< DirectoryWatcher > > clang::DirectoryWatcher::create ( llvm::StringRef  Path,
std::function< void(llvm::ArrayRef< DirectoryWatcher::Event > Events, bool IsInitial)>  Receiver,
bool  WaitForInitialSync 
)
static

llvm fatal_error if

Parameters
Pathdoesn't exist or isn't a directory. Returns llvm::Expected Error if OS kernel API told us we can't start watching. In such case it's unclear whether just retrying has any chance to succeed.

Definition at line 14 of file DirectoryWatcher-not-implemented.cpp.

◆ operator=()

DirectoryWatcher & clang::DirectoryWatcher::operator= ( const DirectoryWatcher )
delete

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