Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77558 - trunk/libs/filesystem/example
From: bdawes_at_[hidden]
Date: 2012-03-26 09:21:36


Author: bemandawes
Date: 2012-03-26 09:21:35 EDT (Mon, 26 Mar 2012)
New Revision: 77558
URL: http://svn.boost.org/trac/boost/changeset/77558

Log:
Add missing files
Added:
   trunk/libs/filesystem/example/tut6a.cpp (contents, props changed)
   trunk/libs/filesystem/example/tut6b.cpp (contents, props changed)
   trunk/libs/filesystem/example/tut6c.cpp (contents, props changed)

Added: trunk/libs/filesystem/example/tut6a.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/filesystem/example/tut6a.cpp 2012-03-26 09:21:35 EDT (Mon, 26 Mar 2012)
@@ -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;
+}

Added: trunk/libs/filesystem/example/tut6b.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/filesystem/example/tut6b.cpp 2012-03-26 09:21:35 EDT (Mon, 26 Mar 2012)
@@ -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;
+}

Added: trunk/libs/filesystem/example/tut6c.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/filesystem/example/tut6c.cpp 2012-03-26 09:21:35 EDT (Mon, 26 Mar 2012)
@@ -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;
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk