]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/filesystem/example/tut3.cpp
f930e1018cb3e15a0e29a1844840f5f95b99d8fe
1 // filesystem tut3.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
11 #include <boost/filesystem.hpp>
13 using namespace boost::filesystem
;
15 int main(int argc
, char* argv
[])
19 cout
<< "Usage: tut3 path\n";
29 if (is_regular_file(p
))
30 cout
<< p
<< " size is " << file_size(p
) << '\n';
32 else if (is_directory(p
))
34 cout
<< p
<< " is a directory containing:\n";
36 for (const directory_entry
& x
: directory_iterator(p
))
37 cout
<< " " << x
.path() << '\n';
40 cout
<< p
<< " exists, but is not a regular file or directory\n";
43 cout
<< p
<< " does not exist\n";
46 catch (const filesystem_error
& ex
)
48 cout
<< ex
.what() << '\n';