generic
FreeBodyEngine.core.files.watcher.generic
#
FILE_CHANGE = 'ENGINE_file_change'
module-attribute
#
FileWatcher(directory)
#
Polls directory for files whose mtime changed since the last check
and emits FILE_CHANGE(relative_path) for each one (a project-relative
path using "/", matching the same path strings load_file()/get_file()
use elsewhere) - dev-mode hot reload's only way of finding out a file
changed at all (see core/files/hot_reload.py for what happens with that
event, and DevFileSystem for how this gets its update() called).
A plain mtime-polling watcher (checked once every POLL_EVERY_N_FRAMES frames, not an OS-level file-events API like inotify/FSEvents/ ReadDirectoryChangesW) - works identically on every platform with no extra dependency, and a project's asset directory is small enough that a full os.walk() a couple of times a second is cheap. Not itself a registered Service - DevFileSystem owns one directly and drives its update() from its own on_initialize(), since a bare directory-watcher has nothing meaningful to depend on or be depended on by.
New files are recorded silently on the pass they're first seen (there's nothing live yet to reload for a file nobody has loaded before) - only a change to an already-known file's mtime fires the event.
Registers the FILE_CHANGE event and takes an initial silent scan
of directory to record every existing file's mtime, so the first
real scan (from update()) only reports genuine changes, not every
file as "new".