FileChangeEvent
Package: Libraries.System · Inherits from: Libraries.Language.Object
This class describes one change on disk, reported by a FileWatcher. It says which file changed, what kind of change it was, and which watched folder it was found under. A rename is reported as two events: DELETED for the old name and CREATED for the new name.
Example Code
use Libraries.System.FileChangeEvent
use Libraries.System.FileChangeListener
use Libraries.System.File
class ChangePrinter is FileChangeListener
action FileChanged(FileChangeEvent event)
File changed = event:GetFile()
if event:IsCreated()
output "Created: " + changed:GetAbsolutePath()
elseif event:IsModified()
output "Changed: " + changed:GetAbsolutePath()
elseif event:IsDeleted()
output "Deleted: " + changed:GetAbsolutePath()
elseif event:IsOverflow()
File folder = event:GetWatchedFolder()
output "Some changes were lost. Look again at " + folder:GetAbsolutePath()
end
end
end
Variables
integer OVERFLOW: Some changes were lost, for example because too many happened at once. The file is the watched folder. Look at the folder again to find out what changed.integer MODIFIED: The file was changed.integer DELETED: The file or folder was deleted.integer CREATED: The file or folder was created.
Actions
GetFile()
Returns the file or folder that changed.
Returns
Libraries.System.File: the changed file or folder.
GetKind()
Returns the kind of change: CREATED, MODIFIED, DELETED or OVERFLOW.
Returns
integer: the kind of change.
GetWatchedFolder()
Returns the folder that was passed to Watch and that contains the changed file.
Returns
Libraries.System.File: the watched folder.
IsCreated()
Returns true if the file or folder was created.
Returns
boolean: true for a CREATED change.
IsDeleted()
Returns true if the file or folder was deleted.
Returns
boolean: true for a DELETED change.
IsModified()
Returns true if the file was changed.
Returns
boolean: true for a MODIFIED change.
IsOverflow()
Returns true if changes were lost and the watched folder should be looked at again.
Returns
boolean: true for an OVERFLOW change.
SetFile(Libraries.System.File file)
Sets the file or folder that changed. Used by FileWatcher.
Parameters
fileLibraries.System.File: the changed file or folder.
SetKind(integer kind)
Sets the kind of change. Used by FileWatcher.
Parameters
kindinteger: CREATED, MODIFIED, DELETED or OVERFLOW.
SetWatchedFolder(Libraries.System.File folder)
Sets the watched folder. Used by FileWatcher.
Parameters
folderLibraries.System.File: the watched folder.