Skip to content

Commit

Permalink
Fixed FilesystemPath::isFile return value.
Browse files Browse the repository at this point in the history
Resolves #490
  • Loading branch information
astrelsky committed Feb 5, 2019
1 parent 1d9bda5 commit 88bf9a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# dev

* Fix: FilesystemPath::isFile ([#490] (https://github.com/avast-tl/retdec/issues/490)).
* New Feature: Added presentation of imported types and TypeRef hashes for .NET binaries ([#363](https://github.com/avast-tl/retdec/issues/363), [#364](https://github.com/avast-tl/retdec/issues/364), [#428](https://github.com/avast-tl/retdec/issues/428)).
* New Feature: Added computation and presentation of icon hashes for exact and also similarity matching in PE files ([#339](https://github.com/avast-tl/retdec/issues/339)).
* Enhancement: Added support for build and run on FreeBSD and potentially on other BSD OSes ([#476](https://github.com/avast-tl/retdec/pull/476)).
Expand Down
12 changes: 10 additions & 2 deletions src/utils/filesystem_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ class FilesystemPathImplWindows : public FilesystemPathImpl

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

return !(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
}

virtual bool isDirectory() override
Expand Down Expand Up @@ -231,7 +235,11 @@ class FilesystemPathImplUnix : public FilesystemPathImpl

virtual bool isFile() override
{
return !isDirectory();
struct stat st;
if (stat(_path.c_str(), &st) != 0)
return false;

return S_ISREG(st.st_mode);
}

virtual bool isDirectory() override
Expand Down

0 comments on commit 88bf9a2

Please sign in to comment.