FileChangeListener

Package: Libraries.System · Inherits from: Libraries.Language.Object

A FileChangeListener is told about changes on disk found by a FileWatcher. Add it with FileWatcher:AddListener. FileChanged is called from FileWatcher:DispatchChanges, on the thread that calls it. In a Game that adds the watcher with AddFileWatcher, that is the main thread, so it is safe to change the interface here.

Example Code

use Libraries.System.File
use Libraries.System.FileWatcher
use Libraries.System.FileChangeEvent
use Libraries.System.FileChangeListener
use Libraries.Game.Game

class Main is Game, FileChangeListener
FileWatcher watcher

action Main
    StartGame()
end

action CreateGame
    File folder
    folder:SetAbsolutePath("/Users/me/Documents/Notes")
    watcher:AddListener(me)
    watcher:Watch(folder, true)
    AddFileWatcher(watcher)
end

action FileChanged(FileChangeEvent event)
    File changed = event:GetFile()
    output "Something changed: " + changed:GetAbsolutePath()
end
end

Actions

FileChanged(Libraries.System.FileChangeEvent event)

Called once for each change.

Parameters

Inherited Actions

3 actions from Libraries.Language.Object