-
Notifications
You must be signed in to change notification settings - Fork 239
File System Helpers (filesystem.h)
Chris Guzak edited this page Jan 6, 2023
·
3 revisions
Observe changes in a folder system including the specific changes using the Win32 API ReadDirectoryChangesW
#include <wil/filesystem.h>
auto reader = wil::make_folder_change_reader(folder.Path().c_str(), true, wil::FolderChangeEvents::All,
[](wil::FolderChangeEvent event, PCWSTR fileName)
{
switch (event)
{
case wil::FolderChangeEvent::ChangesLost: break;
case wil::FolderChangeEvent::Added: break;
case wil::FolderChangeEvent::Removed: break;
case wil::FolderChangeEvent::Modified: break;
case wil::FolderChangeEvent::RenamedOldName: break;
case wil::FolderChangeEvent::RenamedNewName: break;
});
Observe changes to the file system using the Win32 API FindFirstChangeNotificationW
#include <wil/filesystem.h>
auto watcher = wil::make_folder_watcher(folder.Path().c_str(), true, wil::allChangeEvents, []()
{
// respond
});
Get information about a file from an open handle.
auto fileBasicInfo = wil::GetFileInfo<FileBasicInfo>(fileHandle);
Create a directory including the intermediate path segments.
wil::CreateDirectoryDeepNoThrow(LR"(C:\temp\folder)");
Delete a folder including its contents and sub-folders.
wil::RemoveDirectoryRecursive(LR"(c:\temp)", RemoveDirectoryOptions::RemoveReadOnly);