MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / getSubDirectories

Method getSubDirectories

source/MaterialXFormat/File.cpp:219–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219FilePathVec FilePath::getSubDirectories() const
220{
221 if (!isDirectory())
222 {
223 return FilePathVec();
224 }
225
226 FilePathVec dirs{ *this };
227
228#if defined(_WIN32)
229 WIN32_FIND_DATAA fd;
230 string wildcard = "*";
231 HANDLE hFind = FindFirstFileA((*this / wildcard).asString().c_str(), &fd);
232 if (hFind != INVALID_HANDLE_VALUE)
233 {
234 do
235 {
236 string path = fd.cFileName;
237 if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (path != "." && path != ".."))
238 {
239 FilePath newDir = *this / path;
240 FilePathVec newDirs = newDir.getSubDirectories();
241 dirs.insert(dirs.end(), newDirs.begin(), newDirs.end());
242 }
243 } while (FindNextFileA(hFind, &fd));
244 FindClose(hFind);
245 }
246#else
247 DIR* dir = opendir(asString().c_str());
248 if (dir)
249 {
250 while (struct dirent* entry = readdir(dir))
251 {
252 string path = entry->d_name;
253 if (path == "." || path == "..")
254 {
255 continue;
256 }
257
258 auto d_type = entry->d_type;
259 FilePath newDir = *this / path;
260
261 if (d_type == DT_UNKNOWN)
262 {
263 if (newDir.isDirectory())
264 {
265 d_type = DT_DIR;
266 }
267 }
268 if (d_type == DT_DIR)
269 {
270 FilePathVec newDirs = newDir.getSubDirectories();
271 dirs.insert(dirs.end(), newDirs.begin(), newDirs.end());
272 }
273 }
274 closedir(dir);
275 }
276#endif

Callers 5

collectTestFilesMethod · 0.80
XmlIo.cppFile · 0.80
getSubdirectoriesFunction · 0.80
loadDocumentsFunction · 0.80
loadLibrariesFunction · 0.80

Calls 7

asStringFunction · 0.85
c_strMethod · 0.80
insertMethod · 0.80
isDirectoryMethod · 0.80
asStringMethod · 0.45
endMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected