From 941797c807312e8ec3f667fb3662a0995050257b Mon Sep 17 00:00:00 2001 From: Undefine Date: Tue, 30 Dec 2025 00:04:13 +0100 Subject: [PATCH] LibCore: Implement FileWatcher for any systems with inotify FreeBSD 15 added support for inotify so let's just allow this file to be used there too as it's needed for watching the time zone file. --- Libraries/LibCore/CMakeLists.txt | 16 +++++++++++----- ...leWatcherLinux.cpp => FileWatcherInotify.cpp} | 4 ---- 2 files changed, 11 insertions(+), 9 deletions(-) rename Libraries/LibCore/{FileWatcherLinux.cpp => FileWatcherInotify.cpp} (98%) diff --git a/Libraries/LibCore/CMakeLists.txt b/Libraries/LibCore/CMakeLists.txt index 0ba2a5a721..8ede062c1f 100644 --- a/Libraries/LibCore/CMakeLists.txt +++ b/Libraries/LibCore/CMakeLists.txt @@ -80,28 +80,34 @@ else() list(APPEND SOURCES LocalServerWindows.cpp) endif() -# FIXME: Implement these for other systems. +include(CheckIncludeFile) + +check_include_file(sys/inotify.h HAVE_INOTIFY) + +if (HAVE_INOTIFY) + list(APPEND SOURCES FileWatcherInotify.cpp) +else() + list(APPEND SOURCES FileWatcherUnimplemented.cpp) +endif() + +# FIXME: Implement ProcessStatistics for Windows and *BSD if (LINUX) list(APPEND SOURCES - FileWatcherLinux.cpp Platform/ProcessStatisticsLinux.cpp TimeZoneWatcherLinux.cpp ) elseif (APPLE AND NOT IOS) list(APPEND SOURCES - FileWatcherUnimplemented.cpp Platform/ProcessStatisticsMach.cpp TimeZoneWatcherMacOS.mm ) elseif (WIN32) list(APPEND SOURCES - FileWatcherUnimplemented.cpp Platform/ProcessStatisticsUnimplemented.cpp TimeZoneWatcherWindows.cpp ) else() list(APPEND SOURCES - FileWatcherUnimplemented.cpp Platform/ProcessStatisticsUnimplemented.cpp TimeZoneWatcherUnimplemented.cpp ) diff --git a/Libraries/LibCore/FileWatcherLinux.cpp b/Libraries/LibCore/FileWatcherInotify.cpp similarity index 98% rename from Libraries/LibCore/FileWatcherLinux.cpp rename to Libraries/LibCore/FileWatcherInotify.cpp index 923c2ce07e..2f0cb555b5 100644 --- a/Libraries/LibCore/FileWatcherLinux.cpp +++ b/Libraries/LibCore/FileWatcherInotify.cpp @@ -16,10 +16,6 @@ #include #include -#if !defined(AK_OS_LINUX) -static_assert(false, "This file must only be used for Linux"); -#endif - namespace Core { static constexpr unsigned file_watcher_flags_to_inotify_flags(FileWatcherFlags flags)