12 #include <mrpt/config.h> 14 #ifdef MRPT_OS_WINDOWS 16 #include <sys/utime.h> 22 #include <sys/types.h> 36 #include <sys/types.h> 51 const unsigned long in_mask,
56 unsigned long mask = in_mask;
61 string searchPath( path );
62 if (searchPath.size())
63 if ( searchPath[searchPath.size()-1]!=
'\\' && searchPath[searchPath.size()-1]!=
'/')
65 #ifdef MRPT_OS_WINDOWS 68 searchPath.push_back(
'/');
74 #ifdef MRPT_OS_WINDOWS 81 string searchPath_mask=searchPath +
string(
"*.*");
83 HANDLE h = FindFirstFileA( searchPath_mask.c_str(), &f);
84 if (h==INVALID_HANDLE_VALUE)
91 if ( (
mask & f.dwFileAttributes)!=0 )
105 if (stat( newEntry.
wholePath.c_str(),&statDat ))
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() );
139 while((ent = readdir(dir)) != NULL)
141 if ( strcmp(ent->d_name,
".") && strcmp(ent->d_name,
"..") )
151 struct stat statDat, lstatDat;
152 if (stat( newEntry.
wholePath.c_str(),&statDat ))
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);
178 outList.push_back( newEntry );
195 return a.wholePath <
b.wholePath;
199 return a.wholePath >
b.wholePath;
216 int i,
n=(int)lstFiles.size();
222 lstFiles.erase( lstFiles.begin()+i );
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 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...
#define THROW_EXCEPTION(msg)
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
bool cmpFileEntriesName_Desc(const CDirectoryExplorer::TFileInfo &a, const CDirectoryExplorer::TFileInfo &b)
This represents the information about each file.
#define FILE_ATTRIB_ARCHIVE
time_t accessTime
Access and modification times.
uint64_t fileSize
The size of the file in bytes.
std::deque< TFileInfo > TFileInfoList
The list type used in "explore".
std::string BASE_IMPEXP extractFileExtension(const std::string &filePath, bool ignore_gz=false)
Extract the extension of a filename.
GLsizei const GLchar ** string
static void sortByName(TFileInfoList &lstFiles, bool ascendingOrder=true)
Sort the file entries by name, in ascending or descending order.
std::string name
The file name (without the whole path).
unsigned __int64 uint64_t
#define FILE_ATTRIB_DIRECTORY
int BASE_IMPEXP _strcmpi(const char *str1, const char *str2) MRPT_NO_THROWS
An OS-independent version of strcmpi.
GLuint const GLchar * name
GLubyte GLubyte GLubyte a
bool cmpFileEntriesName_Asc(const CDirectoryExplorer::TFileInfo &a, const CDirectoryExplorer::TFileInfo &b)