mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:37:34 +00:00
LibCore+ConfigServer: Add FileWatcherFlags to replace InodeWatcherFlags
InodeWatcherFlags is an enumeration from the Kernel. To avoid using it outside of Serenity, add a FileWatcherFlags for FileWatcher, much like we already have FileWatcherEvent::Type.
This commit is contained in:
parent
98e6dbf50a
commit
142abc0b2e
5 changed files with 33 additions and 17 deletions
|
@ -13,8 +13,6 @@
|
|||
#include <AK/Noncopyable.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <Kernel/API/InodeWatcherEvent.h>
|
||||
#include <Kernel/API/InodeWatcherFlags.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
|
||||
namespace Core {
|
||||
|
@ -34,6 +32,14 @@ struct FileWatcherEvent {
|
|||
|
||||
AK_ENUM_BITWISE_OPERATORS(FileWatcherEvent::Type);
|
||||
|
||||
enum class FileWatcherFlags : u32 {
|
||||
None = 0,
|
||||
Nonblock = 1 << 0,
|
||||
CloseOnExec = 1 << 1,
|
||||
};
|
||||
|
||||
AK_ENUM_BITWISE_OPERATORS(FileWatcherFlags);
|
||||
|
||||
class FileWatcherBase {
|
||||
public:
|
||||
virtual ~FileWatcherBase() = default;
|
||||
|
@ -57,7 +63,7 @@ class BlockingFileWatcher final : public FileWatcherBase {
|
|||
AK_MAKE_NONCOPYABLE(BlockingFileWatcher);
|
||||
|
||||
public:
|
||||
explicit BlockingFileWatcher(InodeWatcherFlags = InodeWatcherFlags::None);
|
||||
explicit BlockingFileWatcher(FileWatcherFlags = FileWatcherFlags::None);
|
||||
~BlockingFileWatcher();
|
||||
|
||||
Optional<FileWatcherEvent> wait_for_event();
|
||||
|
@ -68,7 +74,7 @@ class FileWatcher final : public FileWatcherBase
|
|||
AK_MAKE_NONCOPYABLE(FileWatcher);
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullRefPtr<FileWatcher>> create(InodeWatcherFlags = InodeWatcherFlags::None);
|
||||
static ErrorOr<NonnullRefPtr<FileWatcher>> create(FileWatcherFlags = FileWatcherFlags::None);
|
||||
~FileWatcher();
|
||||
|
||||
Function<void(FileWatcherEvent const&)> on_change;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue