Skip to main content

UEFMFileWatcher

Monitors a single file for changes. When the file is modified, the OnFileChanged delegate fires with the file path and change type.

Delegate​

FOnFileChanged​

DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnFileChanged, const FString&, FilePath, int32, ChangeType)
ParameterTypeDescription
FilePathFStringPath to the changed file
ChangeTypeint32Type of change (see below)

Change Types​

ValueMeaning
0Unknown
1Added
2Modified
3Removed

Functions​

StartWatching​

Callable Starts watching a file.

C++

bool StartWatching(const FString& FilePath)
ParameterTypeDescription
FilePathFStringFull path to the file to watch

Returns: true if watching started successfully

Category: EFM|File Watcher

Blueprint Node

ƒStart Watching
File Path
Return Value

StopWatching​

Callable Stops watching.

C++

void StopWatching()

Category: EFM|File Watcher

Blueprint Node

ƒStop Watching

IsWatching​

Pure Checks if currently watching.

C++

bool IsWatching() const

Category: EFM|File Watcher

Blueprint Node

ƒIs Watching
Return Value

GetWatchedFilePath​

Pure Gets the path of the watched file.

C++

FString GetWatchedFilePath() const

Category: EFM|File Watcher

Blueprint Node

ƒGet Watched File Path
Return Value

Properties​

OnFileChanged​

Assignable Event fired when the watched file changes.

UPROPERTY(BlueprintAssignable)
FOnFileChanged OnFileChanged

Example​

// Create watcher
Watcher = Create UEFMFileWatcher

// Bind event
Watcher.OnFileChanged = OnFileChangedEvent

// Start watching
Watcher.StartWatching(GetGameSavedDirectory() + "config.ini")

// OnFileChangedEvent(FilePath, ChangeType):
// if ChangeType == 2: // Modified
// ReloadConfig(FilePath)
// Log("Config reloaded: " + FilePath)

// Later, stop watching
Watcher.StopWatching()