diff --git a/SiaDrive.Dokan.Api/SiaDokanDrive.cpp b/SiaDrive.Dokan.Api/SiaDokanDrive.cpp index da3631f..cddb3b6 100644 --- a/SiaDrive.Dokan.Api/SiaDokanDrive.cpp +++ b/SiaDrive.Dokan.Api/SiaDokanDrive.cpp @@ -837,6 +837,28 @@ private: } } + + static NTSTATUS DOKAN_CALLBACK Sia_FlushFileBuffers(LPCWSTR FileName, PDOKAN_FILE_INFO DokanFileInfo) + { + String filePath = StdConstructPath(GetCacheLocation(), FileName); + HANDLE handle = reinterpret_cast(DokanFileInfo->Context); + + if (!handle || handle == INVALID_HANDLE_VALUE) + { + return STATUS_SUCCESS; + } + + if (::FlushFileBuffers(handle)) + { + return STATUS_SUCCESS; + } + else + { + DWORD error = GetLastError(); + return DokanNtStatusFromWin32(error); + } + } + public: static void Initialize(CSiaApi* siaApi, CSiaDriveConfig* siaDriveConfig) { @@ -851,7 +873,7 @@ public: _dokanOps.FindFiles = Sia_FindFiles; _dokanOps.FindFilesWithPattern = nullptr; _dokanOps.FindStreams = nullptr; - _dokanOps.FlushFileBuffers = nullptr; + _dokanOps.FlushFileBuffers = Sia_FlushFileBuffers; _dokanOps.GetDiskFreeSpaceW = Sia_GetDiskFreeSpaceW; _dokanOps.GetFileInformation = Sia_GetFileInformation; _dokanOps.GetFileSecurityW = nullptr;