[-] de-bug

This commit is contained in:
Reece Wilson 2022-04-03 03:26:23 +01:00
parent a1ec806773
commit 603c68f3ca

View File

@ -57,7 +57,6 @@ namespace Aurora::IO::FS
}
struct NTWatchObject
{
OVERLAPPED ntOverlapped {};
@ -89,22 +88,35 @@ namespace Aurora::IO::FS
AuString strTheCakeIsALie;
AuSPtr<UserWatchData> userData;
AuSPtr<NTWatchObject> watcher;
HANDLE hFile;
FILETIME lastFileTime {};
bool CheckRun()
{
FILETIME curFileTime {};
if (!GetFileTime(this->hFile, NULL, NULL, &lastFileTime))
auto handle = CreateFileW(AuLocale::ConvertFromUTF8(strNormalizedPath).c_str(),
GENERIC_READ,
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | (AuIOFS::DirExists(strNormalizedPath) ? FILE_FLAG_BACKUP_SEMANTICS : 0),
NULL);
if (handle == INVALID_HANDLE_VALUE)
{
return false;
}
if (!GetFileTime(handle, NULL, NULL, &curFileTime))
{
CloseHandle(handle);
return true;
}
bool ret = !((this->lastFileTime.dwLowDateTime == curFileTime.dwLowDateTime) && (this->lastFileTime.dwHighDateTime == curFileTime.dwHighDateTime));
this->lastFileTime = curFileTime;
CloseHandle(handle);
return ret;
}
};
@ -170,7 +182,6 @@ namespace Aurora::IO::FS
return ret;
}
bool NTWatcher::GoBrr()
{
AU_LOCK_GUARD(this->spinlock_);
@ -339,20 +350,7 @@ namespace Aurora::IO::FS
translated = file.path;
}
if (AuIOFS::FileExists(translated))
{
AuIOFS::GetDirectoryFromPath(translated, translated);
}
for (const auto &[base, wptr] : this->daObjects_)
{
if (AuStartsWith(translated, base))
{
watcher = wptr.lock();
break;
}
}
// Create the NT path in the midst of path normalization
NTCachedPath cached;
cached.strNormalizedPath = AuTryConstruct<AuString>(code, translated);
if (!code)
@ -368,21 +366,27 @@ namespace Aurora::IO::FS
cached.userData = file.userData;
cached.hFile = CreateFileW(AuLocale::ConvertFromUTF8(cached.strNormalizedPath).c_str(),
GENERIC_READ,
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED | (AuIOFS::DirExists(cached.strNormalizedPath) ? FILE_FLAG_BACKUP_SEMANTICS : 0),
NULL);
if (cached.hFile == INVALID_HANDLE_VALUE)
{
return false;
}
// update the last edited timestamp
cached.CheckRun();
// Continue normalizing the parent path
if (AuIOFS::FileExists(translated))
{
AuIOFS::GetDirectoryFromPath(translated, translated);
}
//
for (const auto &[base, wptr] : this->daObjects_)
{
if (AuStartsWith(translated, base))
{
watcher = wptr.lock();
break;
}
}
if (!watcher)
{