Interface FileMonitor.ChangedCallback
- All Superinterfaces:
FunctionPointer
- Enclosing class:
FileMonitor
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
ChangedCallback
callback.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
run
(File file, @Nullable File otherFile, FileMonitorEvent eventType) Emitted whenfile
has been changed.default MemorySegment
toCallback
(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int)
method.default void
upcall
(MemorySegment sourceFileMonitor, MemorySegment file, MemorySegment otherFile, int eventType) Theupcall
method is called from native code.
-
Method Details
-
run
Emitted whenfile
has been changed.If using
FileMonitorFlags.WATCH_MOVES
on a directory monitor, and the information is available (and if supported by the backend),eventType
may beFileMonitorEvent.RENAMED
,FileMonitorEvent.MOVED_IN
orFileMonitorEvent.MOVED_OUT
.In all cases
file
will be a child of the monitored directory. For renames,file
will be the old name andotherFile
is the new name. For "moved in" events,file
is the name of the file that appeared andotherFile
is the old name that it was moved from (in another directory). For "moved out" events,file
is the name of the file that used to be in this directory andotherFile
is the name of the file at its new location.It makes sense to treat
FileMonitorEvent.MOVED_IN
as equivalent toFileMonitorEvent.CREATED
andFileMonitorEvent.MOVED_OUT
as equivalent toFileMonitorEvent.DELETED
, with extra information.FileMonitorEvent.RENAMED
is equivalent to a delete/create pair. This is exactly how the events will be reported in the case that theFileMonitorFlags.WATCH_MOVES
flag is not in use.If using the deprecated flag
FileMonitorFlags.SEND_MOVED
flag andeventType
isFileMonitorEvent.MOVED
,file
will be set to aGFile
containing the old path, andotherFile
will be set to aGFile
containing the new path.In all the other cases,
otherFile
will be set toNULL
. -
upcall
default void upcall(MemorySegment sourceFileMonitor, MemorySegment file, MemorySegment otherFile, int eventType) Theupcall
method is called from native code. The parameters are marshaled andrun(org.gnome.gio.File, org.gnome.gio.File, org.gnome.gio.FileMonitorEvent)
is executed. -
toCallback
Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int)
method.- Specified by:
toCallback
in interfaceFunctionPointer
- Parameters:
arena
- the function pointer will be allocated in this arena- Returns:
- the native function pointer
-