MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / FileIsFilteredOut

Method FileIsFilteredOut

source/script2.cpp:9071–9093  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9069
9070
9071bool Line::FileIsFilteredOut(LoopFilesStruct &aCurrentFile, FileLoopModeType aFileLoopMode)
9072{
9073 if (aCurrentFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) // It's a folder.
9074 {
9075 if (aFileLoopMode == FILE_LOOP_FILES_ONLY
9076 || aCurrentFile.cFileName[0] == '.' && (!aCurrentFile.cFileName[1] // Relies on short-circuit boolean order.
9077 || aCurrentFile.cFileName[1] == '.' && !aCurrentFile.cFileName[2])) //
9078 return true; // Exclude this folder by returning true.
9079 }
9080 else // it's not a folder.
9081 if (aFileLoopMode == FILE_LOOP_FOLDERS_ONLY)
9082 return true; // Exclude this file by returning true.
9083
9084 // Since file was found, also append the file's name to its directory for the caller:
9085 // Seems best to check length in advance because it allows a faster move/copy method further below
9086 // (in lieu of sntprintf(), which is probably quite a bit slower than the method here).
9087 size_t name_length = _tcslen(aCurrentFile.cFileName);
9088 if (aCurrentFile.dir_length + name_length >= _countof(aCurrentFile.file_path)) // Should be impossible with current buffer sizes.
9089 return true; // Exclude this file/folder.
9090 tmemcpy(aCurrentFile.file_path + aCurrentFile.dir_length, aCurrentFile.cFileName, name_length + 1); // +1 to include the terminator.
9091 aCurrentFile.file_path_length = aCurrentFile.dir_length + name_length;
9092 return false; // Indicate that this file is not to be filtered out.
9093}
9094
9095
9096

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected