Skip to content

Commit

Permalink
Exclude folders and hidden and system files
Browse files Browse the repository at this point in the history
  • Loading branch information
elishacloud committed Apr 30, 2019
1 parent 6778ee1 commit 93d7666
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Encryption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,17 @@ void ReadDirectory(const std::wstring& name, const std::wstring& ext, wstringvec
std::wstring pattern(name + L"\\*" + ext);

WIN32_FIND_DATA data;
HANDLE hFind;
HANDLE hFind = FindFirstFile(pattern.c_str(), &data);

if ((hFind = FindFirstFile(pattern.c_str(), &data)) != INVALID_HANDLE_VALUE)
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (data.cFileName[0] != L'.' &&
wcscmp(data.cFileName, processName) != 0)
if ((data.dwFileAttributes & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM)) == 0)
{
v.push_back(data.cFileName);
}
} while (FindNextFile(hFind, &data) != 0);
} while (FindNextFile(hFind, &data));

FindClose(hFind);
}
Expand Down

0 comments on commit 93d7666

Please sign in to comment.