FileWatcher

abstract class FileWatcher

A helper class to simplify WatchService, by creating a (private) background thread, which polls the WatchService, and forwards the messages to created and deleted on the glok thread.

Designed to work with PlacesDock, so that the view remains current when files are created/deleted for any expanded folders in the TreeView.

Typical Usage

Create a concrete subclass, implementing created and deleted. Watch folders using watch and later stop watching it using unwatch.

close ends the background thread, which polls for changes.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun clear()

Stops watching all folders.

Link copied to clipboard
fun close()
Link copied to clipboard
abstract fun created(file: File)

Called on the glok thread when a file is created within a watched folder.

Link copied to clipboard
abstract fun deleted(file: File)

Called on the glok thread when a file is deleted from a watched folder.

Link copied to clipboard
fun unwatch(folder: File)
Link copied to clipboard
fun watch(folder: File)