FileSystemWatcher Object

Top  Previous  Next

File FileSystemWatcher object allows lua to receive notifications when a directory or file changes.

Methods

Return

Signature

Flags


add( string )



remove( string )


table of strings

files()

[const]

table of strings

paths()

[const]

 

callback( function( string, string ) )

 

 

close()

 

FileSystemWatcher::add( path )

Adds the path ( either a directory or a file ) to the list of watched items.

FileSystemWatcher::remove( path )

Removes the path from the list of watched items.

FileSystemWatcher::files()

Returns the list of watched files as a table.

FileSystemWatcher::paths()

Returns the list of watched folders as a table.

FileSystemWatcher::callback( function ( event, path ) )

Sets the function to call when a change occurs. The event parameter will either be "fileChanged" or "directoryChanged". Note only one callback can be active at a time. Setting a new callback on the object will remove the old callback.

FileSystemWatcher::close()

Stops watching for changes and unregisters the callback.

Example

fw = os.newFileSystemWatcher()

 

fw:add("c:\\")

fw:callback( function( event, path ) 

 

  print("File System Watcher ", event, path)

 

end)