2022-04-10 15:40:49 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: Watcher.Linux.hpp
|
|
|
|
Date: 2022-4-10
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Aurora::IO::FS
|
|
|
|
{
|
|
|
|
struct LinuxWatcherHandle;
|
|
|
|
|
|
|
|
struct UnixCachedPath
|
|
|
|
{
|
|
|
|
AuString strNormalizedPath;
|
|
|
|
AuString strTheCakeIsALie;
|
|
|
|
AuSPtr<UserWatchData> userData;
|
|
|
|
int watcherWd {-1};
|
2022-04-13 08:57:28 +00:00
|
|
|
bool bIsDir {};
|
2022-04-10 15:40:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct LinuxWatcher : IWatcher
|
|
|
|
{
|
|
|
|
~LinuxWatcher();
|
|
|
|
|
|
|
|
virtual bool AddWatch(const WatchRequest &file) override;
|
|
|
|
|
|
|
|
virtual bool RemoveByName(const AuString &path) override;
|
|
|
|
virtual bool RemoveByPrivateContext(const AuSPtr<UserWatchData> &file) override;
|
|
|
|
|
|
|
|
virtual AuSPtr<Loop::ILoopSource> AsLoopSource() override;
|
|
|
|
|
|
|
|
virtual AuList<WatchEvent> QueryUpdates() override;
|
|
|
|
|
|
|
|
bool Init();
|
|
|
|
void Deinit();
|
|
|
|
|
|
|
|
private:
|
|
|
|
AuSPtr<LinuxWatcherHandle> loopSource_;
|
|
|
|
AuThreadPrimitives::SpinLock spinlock_;
|
|
|
|
AuList<UnixCachedPath> paths_;
|
|
|
|
int inotifyHandle_ {-1};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|