MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / scandir

Function scandir

TactilityCore/Source/file/File.cpp:92–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92int scandir(
93 const std::string& path,
94 std::vector<dirent>& outList,
95 ScandirFilter filterMethod,
96 ScandirSort sortMethod
97) {
98 auto lock = getLock(path)->asScopedLock();
99 lock.lock();
100
101 LOGGER.info("scandir start");
102 DIR* dir = opendir(path.c_str());
103 if (dir == nullptr) {
104 LOGGER.error("Failed to open dir {}", path);
105 return -1;
106 }
107
108 dirent* current_entry;
109 while ((current_entry = readdir(dir)) != nullptr) {
110 if (filterMethod == nullptr || filterMethod(current_entry) == 0) {
111 outList.push_back(*current_entry);
112 }
113 }
114
115 closedir(dir);
116
117 if (sortMethod != nullptr) {
118 std::ranges::sort(outList, sortMethod);
119 }
120
121 LOGGER.info("scandir finish");
122 return outList.size();
123}
124
125
126long getSize(FILE* file) {

Callers 7

deleteRecursivelyFunction · 0.85
loadAllFunction · 0.85
handleFsListMethod · 0.85
handleFsTreeMethod · 0.85
setEntriesForPathMethod · 0.85
setEntriesForPathMethod · 0.85

Calls 5

getLockFunction · 0.85
asScopedLockMethod · 0.80
infoMethod · 0.80
errorMethod · 0.80
lockMethod · 0.45

Tested by

no test coverage detected