BBjFileSystem::watchDirectory

Description

In BBj 17.0 and higher, this method watches the specified directory for changes (create, modify, delete), periodically reporting any changes through the specified callback.

Syntax

Return Value

Method

String

watchDirectory(String directory, string label)

String

watchDirectory(String directory, UserObject obj, string methodName)

Parameters

Variable

Description

directory

The directory to be watched.

label

The subroutine to be invoked to report any directory changes.

obj

A UserObject containing the method to be called to report any directory changes.

methodName

The name of the method that is to be called to report any directory changes.

Return Value

Returns the full directory path.

Remarks

When registering a UserObject method as the target of the callback, the method must conform to the following constraints:

  • The method must be declared as public with a return type of void.

  • The method must accept a single parameter.

The type of the method parameter must be either BBjDirectoryChangeEvent or BBjEvent or Object.

To stop watching a directory, see unwatchDirectory or unwatchAllDirectories.

Example

rem ' BBjFileSystem::watchDirectory

setesc eoj
fs! = bbjapi().getFileSystem()
print "watchDirectory ",fs!.watchDirectory(".","watch")
print "watchDirectory ",fs!.watchDirectory("..","watch")
process_events

eoj:
    rem ' unwatch individual directories
    fs!.unwatchDirectory(".")
    fs!.unwatchDirectory("..")

    rem ' or unwatch all of them at once
    fs!.unwatchAllDirectories()
release

watch:
    event! = bbjapi().getLastEvent()
    print event!.getEventName()," ",
    print event!.getDirectory()," ",
    print event!.getFilename()," ",
    print event!.getAction(),
    print event!.getChange()
return

See Also

BBjDirectoryChangeEvent

BBjFileSystem

BBjFileSystem::unwatchDirectory

BBjFileSystem::unwatchAllDirectories

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.