]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/filesystem/test/issues/recurse_dir_iter_5403.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / filesystem / test / issues / recurse_dir_iter_5403.cpp
CommitLineData
7c673cae
FG
1// Boost Filesystem recurse_dir_iter_test.cpp ----------------------------------------//
2
3// Copyright Beman Dawes 2014.
4
5// Distributed under the Boost Software License, Version 1.0.
6// See http://www.boost.org/LICENSE_1_0.txt
7
8// Library home page: http://www.boost.org/libs/filesystem
9
10#include <boost/config/warning_disable.hpp>
11
12// See deprecated_test for tests of deprecated features
92f5a8d4 13#ifndef BOOST_FILESYSTEM_NO_DEPRECATED
1e59de90 14#define BOOST_FILESYSTEM_NO_DEPRECATED
7c673cae 15#endif
92f5a8d4 16#ifndef BOOST_SYSTEM_NO_DEPRECATED
1e59de90 17#define BOOST_SYSTEM_NO_DEPRECATED
7c673cae
FG
18#endif
19
20#include <boost/filesystem/operations.hpp>
21
7c673cae 22#include <boost/cerrno.hpp>
1e59de90 23#include <boost/system/error_code.hpp>
f67539c2 24#include <boost/core/lightweight_test.hpp>
7c673cae
FG
25#include <boost/detail/lightweight_main.hpp>
26
27namespace fs = boost::filesystem;
28using boost::system::error_code;
7c673cae
FG
29
30#include <iostream>
31
32using std::cout;
33using std::endl;
34
1e59de90
TL
35namespace {
36typedef int errno_t;
37std::string platform(BOOST_PLATFORM);
38bool report_throws = false;
39bool cleanup = true;
40bool skip_long_windows_tests = false;
7c673cae
FG
41
42} // unnamed namespace
43
44//------------------------------------------------------------------------------------//
45// //
46// main //
47// //
48//------------------------------------------------------------------------------------//
49
50int cpp_main(int argc, char* argv[])
51{
1e59de90 52 // document state of critical macros
7c673cae 53#ifdef BOOST_POSIX_API
1e59de90 54 cout << "BOOST_POSIX_API is defined\n";
7c673cae
FG
55#endif
56#ifdef BOOST_WINDOWS_API
1e59de90 57 cout << "BOOST_WINDOWS_API is defined\n";
7c673cae
FG
58#endif
59
1e59de90
TL
60 for (; argc > 1; --argc, ++argv)
61 {
62 //if (*argv[1]=='-' && *(argv[1]+1)=='t')
63 // report_throws = true;
64 //else if (*argv[1]=='-' && *(argv[1]+1)=='x')
65 // cleanup = false;
66 //else if (*argv[1]=='-' && *(argv[1]+1)=='w')
67 // skip_long_windows_tests = true;
68 }
69
70 // The choice of platform to test is made at runtime rather than compile-time
71 // so that compile errors for all platforms will be detected even though
72 // only the current platform is runtime tested.
73#if defined(BOOST_POSIX_API)
74 platform = "POSIX";
75#elif defined(BOOST_WINDOWS_API)
76 platform = "Windows";
77#else
78#error neither BOOST_POSIX_API nor BOOST_WINDOWS_API is defined. See boost/system/api_config.hpp
79#endif
80 cout << "API is " << platform << endl;
81 cout << "initial_path() is " << fs::initial_path() << endl;
82 fs::path ip = fs::initial_path();
83
84 for (fs::path::const_iterator it = ip.begin(); it != ip.end(); ++it)
85 {
86 if (it != ip.begin())
87 cout << ", ";
88 cout << *it;
89 }
90 cout << endl;
91
92 // From the root, walk the directory tree looking for a permissions error
93
94 fs::recursive_directory_iterator it("/");
95 fs::recursive_directory_iterator end_it;
96
97 // The increment function has an invarient that it always makes progress,
98 // so even if an error occurs this loop will eventually terminate.
99
100 while (it != end_it)
7c673cae 101 {
1e59de90
TL
102 error_code ec;
103 fs::path init_path = it->path();
104 it.increment(ec);
105 if (ec)
106 {
107 cout << "initial path: " << init_path << endl;
108 cout << "error_code: " << ec.value() << " with msg: " << ec.message() << endl;
109 if (it != end_it)
110 cout << "post-increment path: " << it->path() << endl;
111 }
7c673cae 112 }
7c673cae 113
1e59de90
TL
114 cout << "returning from main()" << endl;
115 return ::boost::report_errors();
116}