Go to the documentation of this file.
14 #include <sys/utime.h>
20 #include <sys/types.h>
34 #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)
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());
135 if (!dir)
THROW_EXCEPTION(
"Error starting exploration! (does path exist?)");
137 while ((ent = readdir(dir)) !=
nullptr)
139 if (strcmp(ent->d_name,
".") && strcmp(ent->d_name,
".."))
149 struct stat statDat, lstatDat;
150 if (stat(newEntry.
wholePath.c_str(), &statDat))
154 "Cannot get stat for file: '%s'",
158 newEntry.
modTime = statDat.st_mtime;
162 newEntry.
isDir = S_ISDIR(statDat.st_mode);
171 if (!lstat(newEntry.
wholePath.c_str(), &lstatDat))
173 newEntry.
isSymLink = S_ISLNK(lstatDat.st_mode);
179 outList.push_back(newEntry);
197 return a.wholePath <
b.wholePath;
203 return a.wholePath >
b.wholePath;
213 lstFiles.begin(), lstFiles.end(),
223 int i,
n = (int)lstFiles.size();
224 for (i =
n - 1; i >= 0; i--)
232 lstFiles.erase(lstFiles.begin() + i);
time_t accessTime
Access and modification times.
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
bool cmpFileEntriesName_Asc(const CDirectoryExplorer::TFileInfo &a, const CDirectoryExplorer::TFileInfo &b)
#define THROW_EXCEPTION(msg)
#define FILE_ATTRIB_ARCHIVE
#define FILE_ATTRIB_DIRECTORY
GLuint const GLchar * name
uint64_t fileSize
The size of the file in bytes.
std::deque< TFileInfo > TFileInfoList
The list type used in "explore".
bool cmpFileEntriesName_Desc(const CDirectoryExplorer::TFileInfo &a, const CDirectoryExplorer::TFileInfo &b)
unsigned __int64 uint64_t
std::string name
The file name (without the whole path).
std::string extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
GLsizei const GLchar ** string
This represents the information about each file.
static void filterByExtension(TFileInfoList &lstFiles, const std::string &extension)
Remove from the list of files those whose extension does not coincide (without case) with the given o...
static void sortByName(TFileInfoList &lstFiles, bool ascendingOrder=true)
Sort the file entries by name, in ascending or descending order.
int _strcmpi(const char *str1, const char *str2) noexcept
An OS-independent version of strcmpi.
static void explore(const std::string &path, const unsigned long mask, TFileInfoList &outList)
The path of the directory to examine must be passed to this constructor, among the According to the f...
std::string wholePath
The whole file path.
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
GLubyte GLubyte GLubyte a
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |