Skip to content

Commit

Permalink
Add missing files
Browse files Browse the repository at this point in the history
[SVN r77558]
  • Loading branch information
Beman committed Mar 26, 2012
1 parent 008d2c5 commit dec6c71
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 0 deletions.
48 changes: 48 additions & 0 deletions example/tut6a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// filesystem tut6a.cpp --------------------------------------------------------------//

// Copyright Beman Dawes 2010

// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt

// Library home page: http://www.boost.org/libs/filesystem

#include <iostream>
#include <exception>
#include <boost/filesystem.hpp>
using namespace boost::filesystem;

int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cout << "Usage: tut6a path\n";
return 1;
}

try
{
for (recursive_directory_iterator it (argv[1]);
it != recursive_directory_iterator();
++it)
{
if (it.level() > 1)
it.pop();
else
{
for (int i = 0; i <= it.level(); ++i)
std::cout << " ";

std::cout << it->path() << '\n';
}
}
}

catch (const std::exception& ex)
{
std::cout << "************* exception *****************\n";
std::cout << ex.what() << '\n';
}

return 0;
}
50 changes: 50 additions & 0 deletions example/tut6b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// filesystem tut6b.cpp --------------------------------------------------------------//

// Copyright Beman Dawes 2010

// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt

// Library home page: http://www.boost.org/libs/filesystem

#include <iostream>
#include <exception>
#include <boost/filesystem.hpp>
using namespace boost::filesystem;

int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cout << "Usage: tut6b path\n";
return 1;
}

try
{
for (recursive_directory_iterator it (argv[1]);
it != recursive_directory_iterator();
)
{
for (int i = 0; i <= it.level(); ++i)
std::cout << " ";

std::cout << it->path() << '\n';

try { ++it; }
catch (const filesystem_error& ex)
{
std::cout << "************* filesystem_error *****************\n";
std::cout << ex.what() << '\n';
}
}
}

catch (const std::exception& ex)
{
std::cout << "************* exception *****************\n";
std::cout << ex.what() << '\n';
}

return 0;
}
40 changes: 40 additions & 0 deletions example/tut6c.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// filesystem tut6c.cpp --------------------------------------------------------------//

// Copyright Beman Dawes 2010

// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt

// Library home page: http://www.boost.org/libs/filesystem

#include <iostream>
#include <exception>
#include <boost/filesystem.hpp>
#include <boost/system/error_code.hpp>

using namespace boost::filesystem;
using namespace boost::system;

int main(int argc, char* argv[])
{
if (argc < 2)
{
std::cout << "Usage: tut6c path\n";
return 1;
}

error_code ec;
for (recursive_directory_iterator it (argv[1], ec);
it != recursive_directory_iterator();
)
{
for (int i = 0; i <= it.level(); ++i)
std::cout << " ";

std::cout << it->path() << '\n';

it.increment(ec);
}

return 0;
}

0 comments on commit dec6c71

Please sign in to comment.