]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/filesystem/example/tut4.cpp
1 // filesystem tut4.cpp ---------------------------------------------------------------//
3 // Copyright Beman Dawes 2009
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
8 // Library home page: http://www.boost.org/libs/filesystem
13 #include <boost/filesystem.hpp>
15 using namespace boost::filesystem
;
17 int main(int argc
, char* argv
[])
21 cout
<< "Usage: tut4 path\n";
31 if (is_regular_file(p
))
32 cout
<< p
<< " size is " << file_size(p
) << '\n';
34 else if (is_directory(p
))
36 cout
<< p
<< " is a directory containing:\n";
40 for (auto&& x
: directory_iterator(p
))
41 v
.push_back(x
.path());
43 std::sort(v
.begin(), v
.end());
46 cout
<< " " << x
.filename() << '\n';
49 cout
<< p
<< " exists, but is not a regular file or directory\n";
52 cout
<< p
<< " does not exist\n";
55 catch (const filesystem_error
& ex
)
57 cout
<< ex
.what() << '\n';