AuroraRuntime/Source/IO/FS/Watcher.Linux.hpp

46 lines
1.1 KiB
C++
Raw Normal View History

/***
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};
bool bIsDir {};
};
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};
};
}