[SF 2835206] File_WIN32 not checking against INVALID_HANDLE_VALUE

This commit is contained in:
Aleksandar Fabijanic 2009-08-12 11:34:44 +00:00
parent 49101951a2
commit 1bd3511e89
2 changed files with 11 additions and 5 deletions

View File

@ -48,13 +48,16 @@ class FileHandle
public:
FileHandle(const std::string& path, DWORD access, DWORD share, DWORD disp)
{
_h = CreateFileA(path.c_str(), access, share, 0, disp, 0, 0);
if (!_h) FileImpl::handleLastErrorImpl(path);
_h = CreateFileA(upath.c_str(), access, share, 0, disp, 0, 0);
if (_h == INVALID_HANDLE_VALUE)
{
FileImpl::handleLastErrorImpl(path);
}
}
~FileHandle()
{
if (_h) CloseHandle(_h);
if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
}
HANDLE get() const

View File

@ -50,12 +50,15 @@ public:
FileHandle(const std::string& path, const std::wstring& upath, DWORD access, DWORD share, DWORD disp)
{
_h = CreateFileW(upath.c_str(), access, share, 0, disp, 0, 0);
if (!_h) FileImpl::handleLastErrorImpl(path);
if (_h == INVALID_HANDLE_VALUE)
{
FileImpl::handleLastErrorImpl(path);
}
}
~FileHandle()
{
if (_h) CloseHandle(_h);
if (_h != INVALID_HANDLE_VALUE) CloseHandle(_h);
}
HANDLE get() const