Skip to content

Commit

Permalink
Merge #17: Fixed file sharing errors
Browse files Browse the repository at this point in the history
fecd449 Fixed file sharing error in Win32Env::GetFileSize(), Win32SequentialFile::_Init(), Win32RandomAccessFile::_Init() Fixed error checking in Win32SequentialFile::_Init() (pi)

Tree-SHA512: d97ee419e6aa519260589ed5db04b013b87090daee1b14f054a2125ebd8f6bfd7fb069aeb2455a622dcfabad1a210e7c68c3ce43f000760aa1ae689b0129e599
  • Loading branch information
laanwj committed Mar 25, 2017
2 parents 5b7510f + fecd449 commit d31721e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions util/env_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,13 @@ BOOL Win32SequentialFile::_Init()
ToWidePath(_filename, path);
_hFile = CreateFileW(path.c_str(),
GENERIC_READ,
FILE_SHARE_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
if (_hFile == INVALID_HANDLE_VALUE)
_hFile = NULL;
return _hFile ? TRUE : FALSE;
}

Expand Down Expand Up @@ -403,7 +405,7 @@ BOOL Win32RandomAccessFile::_Init( LPCWSTR path )
{
BOOL bRet = FALSE;
if(!_hFile)
_hFile = ::CreateFileW(path,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
_hFile = ::CreateFileW(path,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,NULL);
if(!_hFile || _hFile == INVALID_HANDLE_VALUE )
_hFile = NULL;
Expand Down Expand Up @@ -669,7 +671,7 @@ Status Win32Env::GetFileSize( const std::string& fname, uint64_t* file_size )
ToWidePath(ModifyPath(path), wpath);

HANDLE file = ::CreateFileW(wpath.c_str(),
GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
LARGE_INTEGER li;
if(::GetFileSizeEx(file,&li)){
*file_size = (uint64_t)li.QuadPart;
Expand Down

0 comments on commit d31721e

Please sign in to comment.