mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-30 09:45:36 +00:00
Reject empty path for path watch.
Correctly launch and stop file watch thread.
This commit is contained in:
parent
ca00492d61
commit
e74f9df537
2 changed files with 7 additions and 3 deletions
|
|
@ -147,6 +147,9 @@ bool SDL_WatchPathForChanges(const char *path, SDL_FileWatchCallback cb, void *u
|
|||
CHECK_PARAM(!path) {
|
||||
return SDL_InvalidParamError("path");
|
||||
}
|
||||
CHECK_PARAM(path[0] == '\0') {
|
||||
return SDL_InvalidParamError("path");
|
||||
}
|
||||
return SDL_SYS_WatchPathForChanges(path, cb, userdata);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -475,8 +475,8 @@ bool SDL_SYS_WatchPathForChanges(const char *path, SDL_FileWatchCallback cb, voi
|
|||
inotify_fd = -1;
|
||||
return false;
|
||||
}
|
||||
file_watch_thread = SDL_CreateThread(SDL_FileWatchThread, "SDL_FileWatch", NULL);
|
||||
SDL_SetAtomicInt(&quit_watch_file, 0);
|
||||
file_watch_thread = SDL_CreateThread(SDL_FileWatchThread, "SDL_FileWatch", NULL);
|
||||
if (!file_watch_thread) {
|
||||
SDL_DestroyHashTable(watch_descriptor_table);
|
||||
watch_descriptor_table = NULL;
|
||||
|
|
@ -495,7 +495,8 @@ bool SDL_SYS_WatchPathForChanges(const char *path, SDL_FileWatchCallback cb, voi
|
|||
watch_entry->callback = cb;
|
||||
watch_entry->user_data = user_data;
|
||||
SDL_memcpy(watch_entry->path, path, slen + 1);
|
||||
// remove separator at the end of the path
|
||||
// remove separator at the end of the path, it is added back when
|
||||
// concatenating directory path and file name
|
||||
if (watch_entry->path[slen - 1] == '/') {
|
||||
watch_entry->path[slen - 1] = '\0';
|
||||
}
|
||||
|
|
@ -594,7 +595,7 @@ void SDL_SYS_QuitPathWatch(void)
|
|||
{
|
||||
#ifdef HAVE_INOTIFY
|
||||
if (inotify_fd >= 0) {
|
||||
SDL_SetAtomicInt(&quit_watch_file, 0);
|
||||
SDL_SetAtomicInt(&quit_watch_file, 1);
|
||||
SDL_WaitThread(file_watch_thread, NULL);
|
||||
close(inotify_fd);
|
||||
inotify_fd = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue