Yet more cleanups in FSNodeWINDOWS.

This commit is contained in:
Stephen Anthony 2022-10-29 16:12:39 -02:30
parent 6cbb06b10a
commit 2c4b98ef7a
1 changed files with 4 additions and 6 deletions

View File

@ -127,10 +127,9 @@ bool FSNodeWINDOWS::getChildren(AbstractFSList& myList, ListMode mode) const
current_drive += _tcslen(current_drive) + 1) current_drive += _tcslen(current_drive) + 1)
{ {
FSNodeWINDOWS entry; FSNodeWINDOWS entry;
char drive_name[2] = { 0, 0 }; char drive_name[2] = { '\0', '\0' };
drive_name[0] = current_drive[0]; drive_name[0] = current_drive[0];
drive_name[1] = '\0';
entry._displayName = drive_name; entry._displayName = drive_name;
entry._isDirectory = true; entry._isDirectory = true;
entry._isFile = false; entry._isFile = false;
@ -142,7 +141,7 @@ bool FSNodeWINDOWS::getChildren(AbstractFSList& myList, ListMode mode) const
else else
{ {
// Files enumeration // Files enumeration
WIN32_FIND_DATA desc; WIN32_FIND_DATA desc{};
HANDLE handle = FindFirstFileEx((_path + "*").c_str(), FindExInfoBasic, HANDLE handle = FindFirstFileEx((_path + "*").c_str(), FindExInfoBasic,
&desc, FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH); &desc, FindExSearchNameMatch, NULL, FIND_FIRST_EX_LARGE_FETCH);
if (handle == INVALID_HANDLE_VALUE) if (handle == INVALID_HANDLE_VALUE)
@ -164,14 +163,13 @@ void FSNodeWINDOWS::addFile(AbstractFSList& list, ListMode mode,
const string& base, const WIN32_FIND_DATA& find_data) const string& base, const WIN32_FIND_DATA& find_data)
{ {
const char* const asciiName = find_data.cFileName; const char* const asciiName = find_data.cFileName;
bool isDirectory = false, isFile = false;
// Skip local directory (.) and parent (..) // Skip local directory (.) and parent (..)
if (!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2)) if (!strncmp(asciiName, ".", 1) || !strncmp(asciiName, "..", 2))
return; return;
isDirectory = static_cast<bool>(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); const bool isDirectory = static_cast<bool>(find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY);
isFile = !isDirectory;//(find_data->dwFileAttributes & FILE_ATTRIBUTE_NORMAL ? true : false); const bool isFile = !isDirectory;//(find_data->dwFileAttributes & FILE_ATTRIBUTE_NORMAL ? true : false);
if ((isFile && mode == FSNode::ListMode::DirectoriesOnly) || if ((isFile && mode == FSNode::ListMode::DirectoriesOnly) ||
(isDirectory && mode == FSNode::ListMode::FilesOnly)) (isDirectory && mode == FSNode::ListMode::FilesOnly))