reference monoe.system.fswatcher

Lua API Reference

Observes changes of files in a directory, and fires events when changes happen, built on top of System.IO.FileSystemWatcher in C#, it runs on another thread, but fires events on the main thread, meaning that the code is totaly safe.

Properties

NameTypeDescription
uidintegerInternal unique indentifier.
eventstringEvent's base name. This string is random, and unpredictible. You can add '_changed', '_created', ... at the end of this in order to get the event's name. But prefer using the given method, as it will be more stable through versions.

monoe.system.fswatcher.new

Creates a new file system watcher.

Parameters

NameTypeDescription
pathstringThe path of the directory that should be watched.
filterstringFile filters. Use '*.*' to watch all files, and '*.txt' to watch all files that ends with '.txt' extension.

Returns


monoe.system.fswatcher:set

Calls the callback when the event is fired.

Parameters

NameTypeDescription
oncebooleanIf the callback should be called once.
funcfunctionThe callback.

monoe.system.fswatcher:free

Frees the resource.