diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:31:50 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:31:50 +0200 |
commit | 570916ddc376b09205125eaaab517561dfead9f0 (patch) | |
tree | 309a94f040707c402623e4f9f887346d1b561df7 /zen/file_io.cpp | |
parent | 6.2 (diff) | |
download | FreeFileSync-570916ddc376b09205125eaaab517561dfead9f0.tar.gz FreeFileSync-570916ddc376b09205125eaaab517561dfead9f0.tar.bz2 FreeFileSync-570916ddc376b09205125eaaab517561dfead9f0.zip |
6.3
Diffstat (limited to 'zen/file_io.cpp')
-rw-r--r-- | zen/file_io.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/zen/file_io.cpp b/zen/file_io.cpp index fbca9089..5eab476a 100644 --- a/zen/file_io.cpp +++ b/zen/file_io.cpp @@ -33,14 +33,11 @@ Zstring getLockingProcessNames(const Zstring& filename) //throw(), empty string const DllFun<FunType_freeString> freeString (getDllName(), funName_freeString); if (getLockingProcesses && freeString) - { - const wchar_t* procList = nullptr; - if (getLockingProcesses(filename.c_str(), procList)) + if (const wchar_t* procList = getLockingProcesses(filename.c_str())) { ZEN_ON_SCOPE_EXIT(freeString(procList)); return procList; } - } } return Zstring(); } @@ -81,12 +78,12 @@ FileInput::FileInput(const Zstring& filename) : FileInputBase(filename) //throw { #ifdef ZEN_WIN const wchar_t functionName[] = L"CreateFile"; - fileHandle = ::CreateFile(applyLongPathPrefix(filename).c_str(), - GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_DELETE, - nullptr, - OPEN_EXISTING, - FILE_FLAG_SEQUENTIAL_SCAN, + fileHandle = ::CreateFile(applyLongPathPrefix(filename).c_str(), //_In_ LPCTSTR lpFileName, + GENERIC_READ, //_In_ DWORD dwDesiredAccess, + FILE_SHARE_READ | FILE_SHARE_DELETE, //_In_ DWORD dwShareMode, + nullptr, //_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + OPEN_EXISTING, //_In_ DWORD dwCreationDisposition, + FILE_FLAG_SEQUENTIAL_SCAN, //_In_ DWORD dwFlagsAndAttributes, /* possible values: (Reference http://msdn.microsoft.com/en-us/library/aa363858(VS.85).aspx#caching_behavior) FILE_FLAG_NO_BUFFERING FILE_FLAG_RANDOM_ACCESS @@ -111,7 +108,7 @@ FileInput::FileInput(const Zstring& filename) : FileInputBase(filename) //throw for FFS most comparisons are probably between different disks => let's use FILE_FLAG_SEQUENTIAL_SCAN */ - nullptr); + nullptr); //_In_opt_ HANDLE hTemplateFile if (fileHandle == INVALID_HANDLE_VALUE) #elif defined ZEN_LINUX || defined ZEN_MAC checkForUnsupportedType(filename); //throw FileError; reading a named pipe would block forever! @@ -198,18 +195,20 @@ FileOutput::FileOutput(const Zstring& filename, AccessFlag access) : //throw Fil auto getHandle = [&](DWORD dwFlagsAndAttributes) { - return ::CreateFile(applyLongPathPrefix(filename).c_str(), - GENERIC_READ | GENERIC_WRITE, + return ::CreateFile(applyLongPathPrefix(filename).c_str(), //_In_ LPCTSTR lpFileName, + GENERIC_READ | GENERIC_WRITE, //_In_ DWORD dwDesiredAccess, /* http://msdn.microsoft.com/en-us/library/aa363858(v=vs.85).aspx quote: When an application creates a file across a network, it is better to use GENERIC_READ | GENERIC_WRITE for dwDesiredAccess than to use GENERIC_WRITE alone. The resulting code is faster, because the redirector can use the cache manager and send fewer SMBs with more data. This combination also avoids an issue where writing to a file across a network can occasionally return ERROR_ACCESS_DENIED. */ - FILE_SHARE_DELETE, //FILE_SHARE_DELETE is required to rename file while handle is open! - nullptr, - dwCreationDisposition, - dwFlagsAndAttributes | FILE_FLAG_SEQUENTIAL_SCAN, - nullptr); + FILE_SHARE_DELETE, //_In_ DWORD dwShareMode, + //FILE_SHARE_DELETE is required to rename file while handle is open! + nullptr, //_In_opt_ LPSECURITY_ATTRIBUTES lpSecurityAttributes, + dwCreationDisposition, //_In_ DWORD dwCreationDisposition, + dwFlagsAndAttributes | + FILE_FLAG_SEQUENTIAL_SCAN, //_In_ DWORD dwFlagsAndAttributes, + nullptr); //_In_opt_ HANDLE hTemplateFile }; fileHandle = getHandle(FILE_ATTRIBUTE_NORMAL); |