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-2017, 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 #ifndef CDirectoryExplorer_H
10 #define CDirectoryExplorer_H
11 
12 #include <mrpt/utils/utils_defs.h>
13 #include <mrpt/system/os.h>
14 #include <deque>
15 
16 namespace mrpt
17 {
18 namespace system
19 {
20 #define FILE_ATTRIB_ARCHIVE 0x0020
21 #define FILE_ATTRIB_DIRECTORY 0x0010
22 
23 /** This class allows the enumeration of the files/directories that exist into a
24  * given path.
25  * The only existing method is "explore" and returns the list of found files &
26  * directories.
27  * Refer to the example in /samples/UTILS/directoryExplorer
28  *
29  * \sa CFileSystemWatcher
30  * \ingroup mrpt_base_grp
31  */
33 {
34  public:
35  /** This represents the information about each file.
36  * \sa
37  */
38  struct TFileInfo
39  {
40  /** The file name (without the whole path).
41  */
43 
44  /** The whole file path.
45  */
47 
48  /** Access and modification times.
49  */
51 
53 
54  /** The size of the file in bytes.
55  */
57  };
58 
59  /** The list type used in "explore".
60  * \sa explore
61  */
62  typedef std::deque<TFileInfo> TFileInfoList;
63 
64  public:
65  /** The path of the directory to examine must be passed to this constructor,
66  * among the
67  * According to the following parameters, the object will collect the list
68  * of files, which
69  * can be modified later through other methods in this class.
70  * \param path The path to examine (IT MUST BE A DIRECTORY), e.g
71  * "d:\temp\", or "/usr/include/"
72  * \param mask One or the OR'ed combination of the values
73  * "FILE_ATTRIB_ARCHIVE" and "FILE_ATTRIB_DIRECTORY", depending on what file
74  * types do you want in the list (These values are platform-independent).
75  * \param outList The list of found files/directories is stored here.
76  * \sa sortByName
77  */
78  static void explore(
79  const std::string& path, const unsigned long mask,
80  TFileInfoList& outList);
81 
82  /** Sort the file entries by name, in ascending or descending order
83  */
84  static void sortByName(TFileInfoList& lstFiles, bool ascendingOrder = true);
85 
86  /** Remove from the list of files those whose extension does not coincide
87  * (without case) with the given one.
88  * Example: filterByExtension(lst,"txt");
89  */
90  static void filterByExtension(
91  TFileInfoList& lstFiles, const std::string& extension);
92 
93 }; // End of class def.
94 
95 } // End of namespace
96 } // End of namespace
97 
98 #endif
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...
GLenum GLint GLuint mask
Definition: glext.h:4050
std::string wholePath
The whole file path.
This class allows the enumeration of the files/directories that exist into a given path...
This represents the information about each file.
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".
GLsizei const GLchar ** string
Definition: glext.h:4101
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
Definition: rptypes.h:50
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019