forked from boostorg/filesystem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SVN r77558]
- Loading branch information
Showing
3 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |