Changeset View
Changeset View
Standalone View
Standalone View
source/lib/sysdep/os/win/wdir_watch.cpp
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | public: | ||||
* (call when completion port indicates data is available) | * (call when completion port indicates data is available) | ||||
**/ | **/ | ||||
void RetrieveNotifications(DirWatchNotifications& notifications) const | void RetrieveNotifications(DirWatchNotifications& notifications) const | ||||
{ | { | ||||
const FILE_NOTIFY_INFORMATION* fni = (const FILE_NOTIFY_INFORMATION*)m_data; | const FILE_NOTIFY_INFORMATION* fni = (const FILE_NOTIFY_INFORMATION*)m_data; | ||||
for(;;) | for(;;) | ||||
{ | { | ||||
// convert (non-zero-terminated) BSTR to Path::String | // convert (non-zero-terminated) BSTR to Path::String | ||||
cassert(sizeof(wchar_t) == sizeof(WCHAR)); | static_assert(sizeof(wchar_t) == sizeof(WCHAR)); | ||||
const size_t length = fni->FileNameLength / sizeof(WCHAR); | const size_t length = fni->FileNameLength / sizeof(WCHAR); | ||||
Path::String name(fni->FileName, length); | Path::String name(fni->FileName, length); | ||||
// (NB: name is actually a relative path since we watch entire subtrees) | // (NB: name is actually a relative path since we watch entire subtrees) | ||||
const OsPath pathname = m_path / name; | const OsPath pathname = m_path / name; | ||||
const DirWatchNotification::EType type = TypeFromAction(fni->Action); | const DirWatchNotification::EType type = TypeFromAction(fni->Action); | ||||
notifications.push_back(DirWatchNotification(pathname, type)); | notifications.push_back(DirWatchNotification(pathname, type)); | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator