Skip to content

Add file watcher API and Linux implementation#15342

Open
meyraud705 wants to merge 1 commit intolibsdl-org:mainfrom
meyraud705:file_watcher
Open

Add file watcher API and Linux implementation#15342
meyraud705 wants to merge 1 commit intolibsdl-org:mainfrom
meyraud705:file_watcher

Conversation

@meyraud705
Copy link
Copy Markdown
Contributor

Description

Add 1 public function: bool SDL_WatchFileForChanges(const char *path) and 2 event types: SDL_EVENT_FILE_WATCH_ERROR and SDL_EVENT_FILE_CHANGED.

SDL_UpdateFileWatch() is called when pumping event to update file watch. Resources are cleared in SDL_QuitFilesystem(void).

Implement this API for Linux using inotify. I put it in SDL_sysfsops.c, I don't know how other platforms work so that may not be the correct place.

Existing Issue(s)

Implement #15070 for Linux.

@Semphriss
Copy link
Copy Markdown
Contributor

A design consideration: would it be possible to use a callback instead of an event? If a given program listens to different paths at different places in the code, events can make it difficult to transfer the signal from the event loop down to the specific part of the code that needs that event. That was my reasoning when developing the file dialog subsystem; using events would've split the part of the code that invokes the dialog from the part that handles the subsequent file operations, which can make a repo quite messy if not carefully managed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants