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 TypeMethodDescriptionvoidrun(@Nullable File file, @Nullable File otherFile, FileMonitorEvent eventType) Emitted whenfilehas been changed.default MemorySegmenttoCallback(Arena arena) Creates a native function pointer to theupcall(java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, java.lang.foreign.MemorySegment, int)method.default voidupcall(MemorySegment sourceFileMonitor, MemorySegment file, MemorySegment otherFile, int eventType) Theupcallmethod is called from native code.
-
Method Details
-
run
Emitted whenfilehas been changed.If using
FileMonitorFlags.WATCH_MOVESon a directory monitor, and the information is available (and if supported by the backend),eventTypemay beFileMonitorEvent.RENAMED,FileMonitorEvent.MOVED_INorFileMonitorEvent.MOVED_OUT.In all cases
filewill be a child of the monitored directory. For renames,filewill be the old name andotherFileis the new name. For "moved in" events,fileis the name of the file that appeared andotherFileis the old name that it was moved from (in another directory). For "moved out" events,fileis the name of the file that used to be in this directory andotherFileis the name of the file at its new location.It makes sense to treat
FileMonitorEvent.MOVED_INas equivalent toFileMonitorEvent.CREATEDandFileMonitorEvent.MOVED_OUTas equivalent toFileMonitorEvent.DELETED, with extra information.FileMonitorEvent.RENAMEDis equivalent to a delete/create pair. This is exactly how the events will be reported in the case that theFileMonitorFlags.WATCH_MOVESflag is not in use.If using the deprecated flag
FileMonitorFlags.SEND_MOVEDflag andeventTypeisFileMonitorEvent.MOVED,filewill be set to aGFilecontaining the old path, andotherFilewill be set to aGFilecontaining the new path.In all the other cases,
otherFilewill be set toNULL. -
upcall
default void upcall(MemorySegment sourceFileMonitor, MemorySegment file, MemorySegment otherFile, int eventType) Theupcallmethod 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:
toCallbackin interfaceFunctionPointer- Parameters:
arena- the arena in which the function pointer is allocated- Returns:
- the native function pointer
-