MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / LinuxAddFileStack

Function LinuxAddFileStack

plugins/plugin_utils/plugin_files.cpp:207–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207bool LinuxAddFileStack(const char* szPathName, const char* fileMask,
208 bool bRecursive, std::vector<std::string> &list,
209 bool justDirs = false) {
210 DIR* directory;
211 dirent* fileInfo;
212 struct stat statbuf;
213 char searchstr[1024];
214 std::string FilePath;
215
216 strcpy(searchstr, szPathName);
217 if (searchstr[strlen(searchstr) - 1] != '/') {
218 strcat(searchstr, "/");
219 }
220 directory = opendir(searchstr);
221 if (!directory) {
222 return false;
223 }
224
225 // TODO: make it use the filemask
226 while ((fileInfo = readdir(directory))) {
227 if (!((strcmp(fileInfo->d_name, ".") == 0) ||
228 (strcmp(fileInfo->d_name, "..") == 0))) {
229 FilePath = searchstr;
230 FilePath += fileInfo->d_name;
231
232
233 stat(FilePath.c_str(), &statbuf);
234
235 if (justDirs && S_ISDIR(statbuf.st_mode)) {
236 // we never do just dirs recrusively
237 list.push_back(FilePath);
238 }
239 else if (!justDirs) {
240 if (S_ISDIR(statbuf.st_mode) && bRecursive) {
241 LinuxAddFileStack(FilePath.c_str(), fileMask, bRecursive, list);
242 }
243 else if (match_mask(fileMask, fileInfo->d_name)) {
244 list.push_back(FilePath);
245 }
246 }
247 }
248 }
249 closedir(directory);
250 return true;
251}
252#endif
253
254// ensures all the delims are constant

Callers 2

getFilesInDirFunction · 0.85
getDirsInDirFunction · 0.85

Calls 4

c_strMethod · 0.80
statClass · 0.70
match_maskFunction · 0.70
push_backMethod · 0.45

Tested by

no test coverage detected