14 #include <sys/utime.h>
22 #include <sys/types.h>
31 #include <sys/types.h>
48 const string& path,
const unsigned long in_mask,
TFileInfoList& outList)
52 unsigned long mask = in_mask;
57 string searchPath(path);
58 if (searchPath.size())
59 if (searchPath[searchPath.size() - 1] !=
'\\' &&
60 searchPath[searchPath.size() - 1] !=
'/')
65 searchPath.push_back(
'/');
78 string searchPath_mask = searchPath + string(
"*.*");
80 HANDLE h = FindFirstFileA(searchPath_mask.c_str(), &f);
81 if (h == INVALID_HANDLE_VALUE)
88 if ((mask & f.dwFileAttributes) != 0)
91 newEntry.
name = string(f.cFileName);
98 newEntry.
fileSize = ((uint64_t)f.nFileSizeLow) +
99 (((uint64_t)f.nFileSizeHigh) << 32);
103 if (stat(newEntry.
wholePath.c_str(), &statDat))
107 "Cannot get stat for file: '%s'",
111 newEntry.
modTime = statDat.st_mtime;
115 newEntry.
isDir = 0 != (statDat.st_mode & _S_IFDIR);
120 outList.push_back(newEntry);
122 }
while (FindNextFileA(h, &f));
134 DIR*
dir = opendir(searchPath.c_str());
137 while ((ent = readdir(
dir)) !=
nullptr)
139 if (strcmp(ent->d_name,
".") != 0 && strcmp(ent->d_name,
"..") != 0)
142 newEntry.
name = string(ent->d_name);
152 if (stat(newEntry.
wholePath.c_str(), &statDat))
156 "Cannot get stat for file: '%s'",
160 newEntry.
modTime = statDat.st_mtime;
164 newEntry.
isDir = S_ISDIR(statDat.st_mode);
170 newEntry.
fileSize = (intmax_t)statDat.st_size;
173 if (!lstat(newEntry.
wholePath.c_str(), &lstatDat))
175 newEntry.
isSymLink = S_ISLNK(lstatDat.st_mode);
181 outList.push_back(newEntry);
215 lstFiles.begin(), lstFiles.end(),
225 int i, n = (int)lstFiles.size();
226 for (i = n - 1; i >= 0; i--)
234 lstFiles.erase(lstFiles.begin() + i);