Main MRPT website > C++ reference for MRPT 1.5.6
List of all members | Classes | Public Types | Static Public Member Functions
mrpt::system::CDirectoryExplorer Class Reference

Detailed Description

This class allows the enumeration of the files/directories that exist into a given path.

The only existing method is "explore" and returns the list of found files & directories. Refer to the example in /samples/UTILS/directoryExplorer

See Also
CFileSystemWatcher

Definition at line 30 of file CDirectoryExplorer.h.

#include <mrpt/system/CDirectoryExplorer.h>

Classes

struct  TFileInfo
 This represents the information about each file. More...
 

Public Types

typedef std::deque< TFileInfoTFileInfoList
 The list type used in "explore". More...
 

Static Public Member Functions

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 following parameters, the object will collect the list of files, which can be modified later through other methods in this class. More...
 
static void sortByName (TFileInfoList &lstFiles, bool ascendingOrder=true)
 Sort the file entries by name, in ascending or descending order. More...
 
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 one. More...
 

Member Typedef Documentation

The list type used in "explore".

See Also
explore

Definition at line 60 of file CDirectoryExplorer.h.

Member Function Documentation

void CDirectoryExplorer::explore ( const std::string path,
const unsigned long  mask,
TFileInfoList outList 
)
static

The path of the directory to examine must be passed to this constructor, among the According to the following parameters, the object will collect the list of files, which can be modified later through other methods in this class.

Parameters
pathThe path to examine (IT MUST BE A DIRECTORY), e.g "d:\temp\", or "/usr/include/"
maskOne or the OR'ed combination of the values "FILE_ATTRIB_ARCHIVE" and "FILE_ATTRIB_DIRECTORY", depending on what file types do you want in the list (These values are platform-independent).
outListThe list of found files/directories is stored here.
See Also
sortByName

Definition at line 49 of file CDirectoryExplorer.cpp.

References mrpt::system::CDirectoryExplorer::TFileInfo::accessTime, FILE_ATTRIB_ARCHIVE, FILE_ATTRIB_DIRECTORY, mrpt::system::CDirectoryExplorer::TFileInfo::fileSize, HANDLE(), mrpt::system::CDirectoryExplorer::TFileInfo::isDir, mrpt::system::CDirectoryExplorer::TFileInfo::isSymLink, mrpt::system::CDirectoryExplorer::TFileInfo::modTime, MRPT_END, MRPT_START, mrpt::system::CDirectoryExplorer::TFileInfo::name, THROW_EXCEPTION, THROW_EXCEPTION_FMT, and mrpt::system::CDirectoryExplorer::TFileInfo::wholePath.

void CDirectoryExplorer::filterByExtension ( TFileInfoList lstFiles,
const std::string extension 
)
static

Remove from the list of files those whose extension does not coincide (without case) with the given one.

Example: filterByExtension(lst,"txt");

Definition at line 214 of file CDirectoryExplorer.cpp.

References mrpt::system::os::_strcmpi(), mrpt::system::extractFileExtension(), and int().

void CDirectoryExplorer::sortByName ( TFileInfoList lstFiles,
bool  ascendingOrder = true 
)
static

Sort the file entries by name, in ascending or descending order.

Definition at line 205 of file CDirectoryExplorer.cpp.

References cmpFileEntriesName_Asc(), and cmpFileEntriesName_Desc().




Page generated by Doxygen 1.8.6 for MRPT 1.5.6 Git: 4c65e84 Tue Apr 24 08:18:17 2018 +0200 at mar abr 24 08:26:17 CEST 2018