MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / scanDirectory

Method scanDirectory

Libraries/Plugin/Plugin.cpp:301–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299};
300
301SC::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
354struct SC::PluginCompiler::CompilerFinder
355{

Callers

nothing calls this directly

Calls 10

endsWithFunction · 0.85
tryParseCandidateMethod · 0.80
writeDefinitionsMethod · 0.80
ResultClass · 0.50
assignMethod · 0.45
initMethod · 0.45
nextMethod · 0.45
appendMethod · 0.45
viewMethod · 0.45

Tested by

no test coverage detected