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 42aecd1
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 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,16 @@ class FilesystemPathImplWindows : public FilesystemPathImpl

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

return !(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
DWORD attributes = GetFileAttributes(_path.c_str());
return (attributes != INVALID_FILE_ATTRIBUTES) &&
(attributes & FILE_ATTRIBUTE_DIRECTORY) == 0;
}

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

return ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY;
DWORD attributes = GetFileAttributes(_path.c_str());
return (attributes != INVALID_FILE_ATTRIBUTES) &&
(attributes & FILE_ATTRIBUTE_DIRECTORY);
}

virtual bool isAbsolute() override
Expand Down

0 comments on commit 42aecd1

Please sign in to comment.