Main MRPT website > C++ reference for MRPT 1.9.9
test.cpp
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 
11 #include <mrpt/system/filesystem.h>
12 #include <iostream>
13 #include <string>
14 
15 using namespace mrpt;
16 using namespace mrpt::system;
17 using namespace std;
18 
19 // ------------------------------------------------------
20 // TestDirExplorer
21 // ------------------------------------------------------
22 void TestDirExplorer()
23 {
25 
26  string path(mrpt::system::getcwd());
27  printf("Exploring path: %s\n", path.c_str());
28 
31 
32  printf("Found %i files:\n", (unsigned int)lst.size());
33 
34  for (CDirectoryExplorer::TFileInfoList::iterator it = lst.begin();
35  it != lst.end(); ++it)
36  {
37  printf("name: %s\n", it->name.c_str());
38  printf("wholePath: %s\n", it->wholePath.c_str());
39  printf("isDir: %c\n", it->isDir ? 'Y' : 'N');
40  printf("size: %lu bytes\n", (unsigned long)it->fileSize);
41  printf("-----------------------\n");
42  }
43 }
44 
45 // ------------------------------------------------------
46 // TestFileNames
47 // ------------------------------------------------------
48 void TestFileNames()
49 {
50  // Test extractFileName
51  string S;
52 
53  S = "foo.bar";
54  cout << "file: " << S
55  << " -> extractFileName : " << mrpt::system::extractFileName(S)
56  << endl;
57 
58  S = "foo.b";
59  cout << "file: " << S
60  << " -> extractFileName : " << mrpt::system::extractFileName(S)
61  << endl;
62 
63  S = "foo.bardotbar.too";
64  cout << "file: " << S
65  << " -> extractFileName : " << mrpt::system::extractFileName(S)
66  << endl;
67 
68  S = "foo";
69  cout << "file: " << S
70  << " -> extractFileName : " << mrpt::system::extractFileName(S)
71  << endl;
72 
73  S = "foo.";
74  cout << "file: " << S
75  << " -> extractFileName : " << mrpt::system::extractFileName(S)
76  << endl;
77 }
78 
79 // ------------------------------------------------------
80 // MAIN
81 // ------------------------------------------------------
82 int main()
83 {
84  try
85  {
87  TestFileNames();
88 
89  return 0;
90  }
91  catch (std::exception& e)
92  {
93  std::cout << "MRPT exception caught: " << e.what() << std::endl;
94  return -1;
95  }
96  catch (...)
97  {
98  printf("Untyped exception!!");
99  return -1;
100  }
101 }
filesystem.h
TestDirExplorer
void TestDirExplorer()
Definition: vision_stereo_rectify/test.cpp:22
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
FILE_ATTRIB_ARCHIVE
#define FILE_ATTRIB_ARCHIVE
Definition: CDirectoryExplorer.h:18
FILE_ATTRIB_DIRECTORY
#define FILE_ATTRIB_DIRECTORY
Definition: CDirectoryExplorer.h:19
main
int main()
Definition: vision_stereo_rectify/test.cpp:78
mrpt::system::CDirectoryExplorer::TFileInfoList
std::deque< TFileInfo > TFileInfoList
The list type used in "explore".
Definition: CDirectoryExplorer.h:60
mrpt::system::getcwd
std::string getcwd()
Returns the current working directory
Definition: filesystem.cpp:248
TestFileNames
void TestFileNames()
Definition: vision_stereo_rectify/test.cpp:48
CDirectoryExplorer.h
mrpt::system::extractFileName
std::string extractFileName(const std::string &filePath)
Extract just the name (without extension) of a filename from a complete path plus name plus extension...
Definition: filesystem.cpp:61
iterator
Scalar * iterator
Definition: eigen_plugins.h:26
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
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Definition: math_frwds.h:25



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