From 2da20611cb7df617d4b69c1ddcb322c8b7250cf2 Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Wed, 15 Mar 2017 02:32:34 -0500 Subject: [PATCH] More changes --- SiaDrive.Dokan.Api/SiaDokanDrive.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) 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;