From 0990595474ce0a1a2760ed61675126e2db95a0f1 Mon Sep 17 00:00:00 2001 From: Anmol Singh Jaggi Date: Tue, 28 Apr 2015 09:12:29 +0530 Subject: [PATCH 1/3] Update tut4.cpp The source code is inconsistent with the corresponding documentation. In fact, the [explanation provided along with this example](http://www.boost.org/doc/libs/1_58_0/libs/filesystem/doc/tutorial.html#Using-path-decomposition) does not make much sense at all. Therefore, I have created a pull request for that too. --- example/tut4.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/tut4.cpp b/example/tut4.cpp index 5888c3ac..17c2ab04 100644 --- a/example/tut4.cpp +++ b/example/tut4.cpp @@ -46,7 +46,7 @@ int main(int argc, char* argv[]) for (vec::const_iterator it(v.begin()), it_end(v.end()); it != it_end; ++it) { - cout << " " << *it << '\n'; + cout << " " << it->filename() << '\n'; } } else From d5005160bbf4ce11b81d0a4ca3ce0a67df971b35 Mon Sep 17 00:00:00 2001 From: Anmol Singh Jaggi Date: Tue, 28 Apr 2015 09:22:20 +0530 Subject: [PATCH 2/3] Update tutorial.html Made it consistent with the source code. For details, refer [this](https://github.com/jaggi1234/filesystem/commit/0990595474ce0a1a2760ed61675126e2db95a0f1) --- doc/tutorial.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/tutorial.html b/doc/tutorial.html index 72db485e..c05efd34 100644 --- a/doc/tutorial.html +++ b/doc/tutorial.html @@ -542,7 +542,7 @@ for (vec::const_iterator it (v.begin()); it != v.end(); ++it) { - cout << " " << *it << '\n'; + cout << " " << it->filename() << '\n'; } } @@ -572,8 +572,7 @@

to:

-
path fn = it->path().filename();   // extract the filename from the path
-v.push_back(fn);                   // push into vector for later sorting
+
cout << "   " << it->filename() << '\n';

path() is a directory_entry observer function. @@ -1127,4 +1126,4 @@ - \ No newline at end of file + From 066f96fa62cca4f21ffdfba49f3e0db2d1f459c2 Mon Sep 17 00:00:00 2001 From: Anmol Singh Jaggi Date: Tue, 28 Apr 2015 09:30:05 +0530 Subject: [PATCH 3/3] Update tutorial.html Removed inconsistent documentation. Refer [this](https://github.com/jaggi1234/filesystem/commit/0990595474ce0a1a2760ed61675126e2db95a0f1) for more info. --- doc/tutorial.html | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/doc/tutorial.html b/doc/tutorial.html index c05efd34..9520ab06 100644 --- a/doc/tutorial.html +++ b/doc/tutorial.html @@ -565,27 +565,11 @@ -

The key difference between tut3.cpp and tut4.cpp is - what happens in the directory iteration loop. We changed:

-
-
cout << " " << *it << '\n';   // *it returns a directory_entry,
-
-

to:

-
-
cout << "   " << it->filename() << '\n';
-
-

path() - is a directory_entry observer function. - filename() is one of +

filename() is one of several path decomposition functions. It extracts the filename portion ("index.html") from a path ("/home/beman/boost/trunk/index.html"). These decomposition functions are more fully explored in the Path iterators, observers, composition, decomposition and query portion of this tutorial.

-

The above was written as two lines of code for clarity. It could have - been written more concisely as:

-
-
v.push_back(it->path().filename()); // we only care about the filename
-

Here is the output from a test of tut4.cpp: