MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / dirList

Method dirList

source/core/StarFile_windows.cpp:93–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93List<std::pair<String, bool>> File::dirList(const String& dirName, bool skipDots) {
94 List<std::pair<String, bool>> fileList;
95 WIN32_FIND_DATAW findFileData;
96 HANDLE hFind;
97
98 hFind = FindFirstFileW(stringToUtf16(File::relativeTo(dirName, "*")).get(), &findFileData);
99 if (hFind == INVALID_HANDLE_VALUE)
100 throw IOException(strf("Invalid file handle in dirList of '{}', error is %u", dirName, GetLastError()));
101
102 while (true) {
103 String entry = utf16ToString(findFileData.cFileName);
104 if (!skipDots || (entry != "." && entry != ".."))
105 fileList.append({entry, (FILE_ATTRIBUTE_DIRECTORY & findFileData.dwFileAttributes) != 0});
106 if (!FindNextFileW(hFind, &findFileData))
107 break;
108 }
109
110 DWORD dwError = GetLastError();
111 FindClose(hFind);
112
113 if ((dwError != ERROR_NO_MORE_FILES) && (dwError != NO_ERROR))
114 throw IOException(strf("FindNextFile error in dirList of '{}'. Error is %u", dirName, dwError));
115
116 return fileList;
117}
118
119String File::baseName(const String& fileName) {
120 return String(fileName).rextract("\\/");

Callers

nothing calls this directly

Calls 5

stringToUtf16Function · 0.85
strfFunction · 0.85
utf16ToStringFunction · 0.85
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected