| 299 | }; |
| 300 | |
| 301 | SC::Result SC::PluginScanner::scanDirectory(StringSpan directory, Span<PluginDefinition> definitions, |
| 302 | IGrowableBuffer&& tempFileBuffer, Span<PluginDefinition>& foundDefinitions) |
| 303 | { |
| 304 | ScannerState scannerState = {definitions}; |
| 305 | |
| 306 | StringPath pathBuffer; |
| 307 | SC_TRY(pathBuffer.assign(directory)); |
| 308 | |
| 309 | PluginFileSystemIterator iterator; |
| 310 | SC_TRY(iterator.init(directory)); |
| 311 | PluginFileSystemIterator::Entry entry; |
| 312 | while (iterator.next(entry)) |
| 313 | { |
| 314 | if (entry.name == SC_NATIVE_STR(".") or entry.name == SC_NATIVE_STR("..")) |
| 315 | { |
| 316 | continue; // skip . and .. |
| 317 | } |
| 318 | StringPath fullPath = pathBuffer; |
| 319 | SC_TRY(fullPath.append(iterator.pathSeparator)); |
| 320 | SC_TRY(fullPath.append(entry.name)); |
| 321 | if (entry.isDirectory) |
| 322 | { |
| 323 | // Immediately recurse to find candidates |
| 324 | SC_TRY(scannerState.storeTentativePluginFolder(fullPath.view())); |
| 325 | // Scan subdirectory for .cpp files |
| 326 | PluginFileSystemIterator subIterator; |
| 327 | SC_TRY(subIterator.init(fullPath.view())); |
| 328 | PluginFileSystemIterator::Entry subEntry; |
| 329 | while (subIterator.next(subEntry)) |
| 330 | { |
| 331 | if (subEntry.name == SC_NATIVE_STR(".") or subEntry.name == SC_NATIVE_STR("..")) |
| 332 | { |
| 333 | continue; // skip . and .. |
| 334 | } |
| 335 | StringPath subFullPath = fullPath; |
| 336 | SC_TRY(subFullPath.append(subIterator.pathSeparator)); |
| 337 | SC_TRY(subFullPath.append(subEntry.name)); |
| 338 | if (not subEntry.isDirectory and PluginString::endsWith(subEntry.name, SC_NATIVE_STR(".cpp"))) |
| 339 | { |
| 340 | // It's a regular file ending with .cpp |
| 341 | if (scannerState.multipleDefinitions) |
| 342 | { |
| 343 | continue; |
| 344 | } |
| 345 | SC_TRY(scannerState.tryParseCandidate(subFullPath.view(), move(tempFileBuffer))); |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | } |
| 350 | scannerState.writeDefinitions(foundDefinitions); |
| 351 | return Result(true); |
| 352 | } |
| 353 | #if SC_PLATFORM_WINDOWS |
| 354 | struct SC::PluginCompiler::CompilerFinder |
| 355 | { |
nothing calls this directly
no test coverage detected