Skip to content

Commit

Permalink
Refactoring of FilesystemPathImplWindows
Browse files Browse the repository at this point in the history
Instances of reinterpret_cast<HANDLE>(-1) in
FilesystemPathImplWindows have been replaced with
INVALID_HANDLE_VALUE for readability. GetFileAttributes was
utilized in place of FindFirstFile to check for file existance
and file attributes.
  • Loading branch information
astrelsky committed Feb 7, 2019
1 parent 88bf9a2 commit ae163f3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/utils/filesystem_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class FilesystemPathImplWindows : public FilesystemPathImpl

subpaths.clear();
HANDLE hFnd = FindFirstFile(examineDir.c_str(), &ffd);
if (hFnd == reinterpret_cast<HANDLE>(-1))
if (hFnd == INVALID_HANDLE_VALUE)
return false;

do
Expand All @@ -141,20 +141,20 @@ class FilesystemPathImplWindows : public FilesystemPathImpl

virtual bool isFile() override
{
WIN32_FIND_DATA ffd;
if (FindFirstFile(_path.c_str(), &ffd) == reinterpret_cast<HANDLE>(-1))
DWORD attributes = GetFileAttributes(_path.c_str());
if (attributes == INVALID_FILE_ATTRIBUTES)
return false;

return !(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
else
return !(attributes & FILE_ATTRIBUTE_DIRECTORY);
}

virtual bool isDirectory() override
{
WIN32_FIND_DATA ffd;
if (FindFirstFile(_path.c_str(), &ffd) == reinterpret_cast<HANDLE>(-1))
DWORD attributes = GetFileAttributes(_path.c_str());
if (attributes == INVALID_FILE_ATTRIBUTES)
return false;

return ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
else
return (attributes & FILE_ATTRIBUTE_DIRECTORY);
}

virtual bool isAbsolute() override
Expand Down

0 comments on commit ae163f3

Please sign in to comment.