Skip to content
Watch changes in directories
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Demo
Source
Test
.gitignore
LICENSE Fixes #1: Pure LGPL is not compatible with FPC RTL Jul 3, 2017
README.md

README.md

DirectoryWatcher

Watch changes in directories on different platforms.

This is an abstraction layer for

  • ReadDirectoryChangesW on Windows
  • FSEvent on Mac OS
  • inotify on Linux

How to use

// Create new DirectoryWatcher
DirectoryWatcher := TDirectoryWatcherBuilder
                    .New
                    .WatchDirectory(FolderToWatch)
                    .Recursively(True)
                    .OnChangeTrigger(OnFileEvent)
                    .Build;

// Start watching in different thread
DirectoryWatcher.Start;

// Stop DirectoryWatcher
DirectoryWatcher := Nil;

// ...

procedure TDirectoryWatcherDemo.OnFileEvent(const FilePath: String; 
                                            const EventType: TDirectoryEventType);
var
  EventTypeString: String;
begin
  WriteLn('======NEW EVENT======');
  WriteLn('File: ' + FilePath);

  case EventType of
    detAdded: EventTypeString := 'ADDED';
    detRemoved: EventTypeString := 'REMOVED';
    detModified: EventTypeString := 'MODIFIED';
  end;

  WriteLn('Type: ' + EventTypeString);
end;  
You can’t perform that action at this time.