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

Method forEachFile

Tools/SC-format.h:18–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16struct FileSystemFinder
17{
18 [[nodiscard]] static Result forEachFile(StringView libraryDirectory, Span<const StringView> includeFilesEndingWith,
19 Span<const StringView> excludeDirectories,
20 Function<Result(StringView)>&& forEachFunc)
21 {
22 FileSystemIterator::FolderState entries[16];
23
24 FileSystemIterator iterator;
25 SC_TRY(iterator.init(libraryDirectory, entries));
26
27 while (iterator.enumerateNext())
28 {
29 const StringView name = iterator.get().name;
30 if (iterator.get().isDirectory())
31 {
32 if (not Algorithms::contains(excludeDirectories, name))
33 {
34 SC_TRY(iterator.recurseSubdirectory());
35 }
36 }
37 else
38 {
39 for (auto extension : includeFilesEndingWith)
40 {
41 if (name.endsWith(extension))
42 {
43 SC_TRY(forEachFunc(iterator.get().path));
44 break;
45 }
46 }
47 }
48 }
49 return Result(true);
50 }
51};
52
53/// @brief Launch processes obeying to a maximum predefined concurrency passed during create

Callers

nothing calls this directly

Calls 8

enumerateNextMethod · 0.80
isDirectoryMethod · 0.80
recurseSubdirectoryMethod · 0.80
endsWithMethod · 0.80
containsFunction · 0.50
ResultClass · 0.50
initMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected