Main MRPT website > C++ reference for MRPT 1.9.9
CDirectoryExplorer.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <mrpt/system/os.h>
12 #include <deque>
13 
14 namespace mrpt
15 {
16 namespace system
17 {
18 #define FILE_ATTRIB_ARCHIVE 0x0020
19 #define FILE_ATTRIB_DIRECTORY 0x0010
20 
21 /** This class allows the enumeration of the files/directories that exist into a
22  * given path.
23  * The only existing method is "explore" and returns the list of found files &
24  * directories.
25  * Refer to the example in /samples/UTILS/directoryExplorer
26  *
27  * \sa CFileSystemWatcher
28  * \ingroup mrpt_system_grp
29  */
31 {
32  public:
33  /** This represents the information about each file.
34  * \sa
35  */
36  struct TFileInfo
37  {
38  /** The file name (without the whole path).
39  */
41 
42  /** The whole file path.
43  */
45 
46  /** Access and modification times.
47  */
49 
51 
52  /** The size of the file in bytes.
53  */
55  };
56 
57  /** The list type used in "explore".
58  * \sa explore
59  */
60  using TFileInfoList = std::deque<TFileInfo>;
61 
62  public:
63  /** The path of the directory to examine must be passed to this constructor,
64  * among the
65  * According to the following parameters, the object will collect the list
66  * of files, which
67  * can be modified later through other methods in this class.
68  * \param path The path to examine (IT MUST BE A DIRECTORY), e.g
69  * "d:\temp\", or "/usr/include/"
70  * \param mask One or the OR'ed combination of the values
71  * "FILE_ATTRIB_ARCHIVE" and "FILE_ATTRIB_DIRECTORY", depending on what file
72  * types do you want in the list (These values are platform-independent).
73  * \param outList The list of found files/directories is stored here.
74  * \sa sortByName
75  */
76  static void explore(
77  const std::string& path, const unsigned long mask,
78  TFileInfoList& outList);
79 
80  /** Sort the file entries by name, in ascending or descending order
81  */
82  static void sortByName(TFileInfoList& lstFiles, bool ascendingOrder = true);
83 
84  /** Remove from the list of files those whose extension does not coincide
85  * (without case) with the given one.
86  * Example: filterByExtension(lst,"txt");
87  */
88  static void filterByExtension(
89  TFileInfoList& lstFiles, const std::string& extension);
90 
91 }; // End of class def.
92 
93 } // End of namespace
94 } // End of namespace
os.h
mrpt::system::CDirectoryExplorer::TFileInfo::accessTime
time_t accessTime
Access and modification times.
Definition: CDirectoryExplorer.h:48
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::system::CDirectoryExplorer::TFileInfo::fileSize
uint64_t fileSize
The size of the file in bytes.
Definition: CDirectoryExplorer.h:54
mrpt::system::CDirectoryExplorer::TFileInfoList
std::deque< TFileInfo > TFileInfoList
The list type used in "explore".
Definition: CDirectoryExplorer.h:60
mrpt::system::CDirectoryExplorer
This class allows the enumeration of the files/directories that exist into a given path.
Definition: CDirectoryExplorer.h:30
uint64_t
unsigned __int64 uint64_t
Definition: rptypes.h:50
mrpt::system::CDirectoryExplorer::TFileInfo::name
std::string name
The file name (without the whole path).
Definition: CDirectoryExplorer.h:40
mask
GLenum GLint GLuint mask
Definition: glext.h:4050
mrpt::system::CDirectoryExplorer::TFileInfo::modTime
time_t modTime
Definition: CDirectoryExplorer.h:48
mrpt::system::CDirectoryExplorer::TFileInfo::isSymLink
bool isSymLink
Definition: CDirectoryExplorer.h:50
mrpt::system::CDirectoryExplorer::TFileInfo::isDir
bool isDir
Definition: CDirectoryExplorer.h:50
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::system::CDirectoryExplorer::TFileInfo
This represents the information about each file.
Definition: CDirectoryExplorer.h:36
mrpt::system::CDirectoryExplorer::filterByExtension
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...
Definition: CDirectoryExplorer.cpp:220
mrpt::system::CDirectoryExplorer::sortByName
static void sortByName(TFileInfoList &lstFiles, bool ascendingOrder=true)
Sort the file entries by name, in ascending or descending order.
Definition: CDirectoryExplorer.cpp:209
mrpt::system::CDirectoryExplorer::explore
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...
Definition: CDirectoryExplorer.cpp:47
mrpt::system::CDirectoryExplorer::TFileInfo::wholePath
std::string wholePath
The whole file path.
Definition: CDirectoryExplorer.h:44



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