Returns the files to act on. If instructed, will be fetched recursively. @param p_Recursively Whether to fetch filenames recursively. @return List of files to act on.
| 1169 | // @return List of files to act on. |
| 1170 | // |
| 1171 | PCC::FilesV CPathCopyCopyContextMenuExt::GetFilesToActOn(const bool p_Recursively) const |
| 1172 | { |
| 1173 | auto vFiles(m_vFiles); |
| 1174 | |
| 1175 | if (p_Recursively) { |
| 1176 | auto vNewFiles(vFiles); |
| 1177 | while (!vNewFiles.empty()) { |
| 1178 | PCC::FilesV vFilesToScan; |
| 1179 | vFilesToScan.swap(vNewFiles); |
| 1180 | for (const auto& fileToScan : vFilesToScan) { |
| 1181 | auto attributes = ::GetFileAttributesW(fileToScan.c_str()); |
| 1182 | if (attributes != INVALID_FILE_ATTRIBUTES && (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0) { |
| 1183 | WIN32_FIND_DATAW findData; |
| 1184 | HANDLE hFind = ::FindFirstFileW((fileToScan + L"\\*").c_str(), &findData); |
| 1185 | if (hFind != INVALID_HANDLE_VALUE) { |
| 1186 | try { |
| 1187 | do { |
| 1188 | const std::wstring fileName = findData.cFileName; |
| 1189 | if (fileName != L"." && fileName != L"..") { |
| 1190 | vNewFiles.emplace_back(fileToScan + L"\\" + fileName); |
| 1191 | } |
| 1192 | } while (::FindNextFileW(hFind, &findData)); |
| 1193 | ::FindClose(hFind); |
| 1194 | } catch (...) { |
| 1195 | ::FindClose(hFind); |
| 1196 | throw; |
| 1197 | } |
| 1198 | } |
| 1199 | } |
| 1200 | } |
| 1201 | vFiles.insert(vFiles.end(), vNewFiles.begin(), vNewFiles.end()); |
| 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | return vFiles; |
| 1206 | } |
| 1207 | |
| 1208 | // |
| 1209 | // Scans the vector keeping tracks of instances modifying menus |