[+] FIO Watcher

This commit is contained in:
Reece Wilson 2022-04-03 03:35:27 +01:00
parent d575087487
commit c54cf7f329
3 changed files with 27 additions and 2 deletions

@ -1 +1 @@
Subproject commit 3d14595d87eab4b056c39e54228df9cb694a0912 Subproject commit 4fa7f61b8f57e1c55b69661f75356beeb289f63c

@ -1 +1 @@
Subproject commit 5599da3ab06885d365bab1234459c76f623a7c45 Subproject commit 603c68f3cac297fa2a32c2209f4f327e7fa3de94

View File

@ -96,6 +96,31 @@ TEST(FS, MkDir)
ASSERT_FALSE(AuIOFS::DirExists("./test_dir")); ASSERT_FALSE(AuIOFS::DirExists("./test_dir"));
} }
TEST(FS, Watcher)
{
ASSERT_TRUE(AuIOFS::WriteString("~/Watcher.txt", "testing"));
auto watcher = AuIOFS::NewWatcherUnique();
ASSERT_TRUE(watcher);
AuIOFS::WatchedFile file;
file.path = "~/Watcher.txt";
ASSERT_TRUE(watcher->AddWatch(file));
ASSERT_FALSE(watcher->AsLoopSource()->IsSignaled());
ASSERT_TRUE(AuIOFS::WriteString("~/Watcher.txt", "testing2"));
ASSERT_TRUE(watcher->AsLoopSource()->IsSignaled());
ASSERT_TRUE(watcher->AsLoopSource()->IsSignaled());
ASSERT_TRUE(watcher->QueryUpdates().size());
ASSERT_FALSE(watcher->AsLoopSource()->IsSignaled());
ASSERT_TRUE(AuIOFS::WriteString("~/Watcher.txt", "testing2"));
ASSERT_TRUE(watcher->AsLoopSource()->IsSignaled());
ASSERT_TRUE(watcher->QueryUpdates().size());
ASSERT_TRUE(AuIOFS::WriteString("~/Watcher2.txt", "testing2"));
ASSERT_FALSE(watcher->AsLoopSource()->IsSignaled());
}
static void PrintSystemRoot() static void PrintSystemRoot()
{ {
AuString path; AuString path;