2014-12-07 19:09:38 -05:00
|
|
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
2014-07-17 13:49:42 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/inotify.h>
|
|
|
|
|
|
|
|
|
|
#define EVENT_SIZE ( sizeof (struct inotify_event) )
|
|
|
|
|
#define BUF_LEN ( 1024 * ( EVENT_SIZE + 16 ) )
|
|
|
|
|
|
|
|
|
|
class FDirectoryWatchRequestLinux
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
FDirectoryWatchRequestLinux();
|
|
|
|
|
virtual ~FDirectoryWatchRequestLinux();
|
|
|
|
|
|
|
|
|
|
/** Sets up the directory handle and request information */
|
|
|
|
|
bool Init(const FString& InDirectory);
|
|
|
|
|
|
|
|
|
|
/** Adds a delegate to get fired when the directory changes */
|
2015-01-08 09:29:27 -05:00
|
|
|
FDelegateHandle AddDelegate( const IDirectoryWatcher::FDirectoryChanged& InDelegate );
|
2014-07-17 13:49:42 -04:00
|
|
|
/** Removes a delegate to get fired when the directory changes */
|
2015-01-08 09:29:27 -05:00
|
|
|
DELEGATE_DEPRECATED("This overload of RemoveDelegate is deprecated, instead pass the result of AddDelegate.")
|
2014-07-17 13:49:42 -04:00
|
|
|
bool RemoveDelegate( const IDirectoryWatcher::FDirectoryChanged& InDelegate );
|
2015-01-08 09:29:27 -05:00
|
|
|
/** Same as above, but for use within other deprecated calls to prevent multiple deprecation warnings */
|
|
|
|
|
bool DEPRECATED_RemoveDelegate( const IDirectoryWatcher::FDirectoryChanged& InDelegate );
|
|
|
|
|
/** Removes a delegate to get fired when the directory changes */
|
|
|
|
|
bool RemoveDelegate( FDelegateHandle InHandle );
|
2014-07-17 13:49:42 -04:00
|
|
|
/** Returns true if this request has any delegates listening to directory changes */
|
|
|
|
|
bool HasDelegates() const;
|
|
|
|
|
/** Prepares the request for deletion */
|
|
|
|
|
void EndWatchRequest();
|
|
|
|
|
/** Triggers all pending file change notifications */
|
|
|
|
|
void ProcessPendingNotifications();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2014-08-05 19:12:20 -04:00
|
|
|
FString Directory;
|
|
|
|
|
|
|
|
|
|
bool bRunning;
|
2014-07-17 13:49:42 -04:00
|
|
|
bool bEndWatchRequestInvoked;
|
|
|
|
|
|
2014-08-05 19:12:20 -04:00
|
|
|
int FileDescriptor;
|
|
|
|
|
int * WatchDescriptor;
|
|
|
|
|
int NotifyFilter;
|
2014-07-17 13:49:42 -04:00
|
|
|
|
2014-08-05 19:12:20 -04:00
|
|
|
TArray<FString> AllFiles;
|
2014-07-17 13:49:42 -04:00
|
|
|
TArray<IDirectoryWatcher::FDirectoryChanged> Delegates;
|
|
|
|
|
TArray<FFileChangeData> FileChanges;
|
|
|
|
|
|
2014-08-05 19:12:20 -04:00
|
|
|
void Shutdown();
|
|
|
|
|
void ProcessChanges();
|
2014-07-17 13:49:42 -04:00
|
|
|
};
|