Main MRPT website > C++ reference for MRPT 1.5.6
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 given path.
24  * The only existing method is "explore" and returns the list of found files & directories.
25  * Refer to the example in /samples/UTILS/directoryExplorer
26  *
27  * \sa CFileSystemWatcher
28  * \ingroup mrpt_base_grp
29  */
31  {
32  public:
33  /** This represents the information about each file.
34  * \sa
35  */
37  {
38  /** The file name (without the whole path).
39  */
41 
42  /** The whole file path.
43  */
45 
46  /** Access and modification times.
47  */
48  time_t accessTime,modTime;
49 
50  bool isDir, isSymLink;
51 
52  /** The size of the file in bytes.
53  */
55  };
56 
57  /** The list type used in "explore".
58  * \sa explore
59  */
60  typedef std::deque<TFileInfo> TFileInfoList;
61 
62  public:
63  /** The path of the directory to examine must be passed to this constructor, among the
64  * According to the following parameters, the object will collect the list of files, which
65  * can be modified later through other methods in this class.
66  * \param path The path to examine (IT MUST BE A DIRECTORY), e.g "d:\temp\", or "/usr/include/"
67  * \param mask One 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).
68  * \param outList The list of found files/directories is stored here.
69  * \sa sortByName
70  */
71  static void explore(
72  const std::string &path,
73  const unsigned long mask,
74  TFileInfoList &outList );
75 
76  /** Sort the file entries by name, in ascending or descending order
77  */
78  static void sortByName( TFileInfoList &lstFiles, bool ascendingOrder=true );
79 
80  /** Remove from the list of files those whose extension does not coincide (without case) with the given one.
81  * Example: filterByExtension(lst,"txt");
82  */
83  static void filterByExtension( TFileInfoList &lstFiles, const std::string &extension );
84 
85  }; // End of class def.
86 
87  } // End of namespace
88 } // End of namespace
89 
90 #endif
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.
uint64_t fileSize
The size of the file in bytes.
std::deque< TFileInfo > TFileInfoList
The list type used in "explore".
std::string name
The file name (without the whole path).
unsigned __int64 uint64_t
Definition: rptypes.h:52
GLsizei const GLcharARB ** string
Definition: glew.h:3293
GLenum GLint GLuint mask
Definition: glew.h:1752



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