Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84933 - in trunk/tools/quickbook: doc src
From: dnljms_at_[hidden]
Date: 2013-07-01 15:34:33


Author: danieljames
Date: 2013-07-01 15:34:33 EDT (Mon, 01 Jul 2013)
New Revision: 84933
URL: http://svn.boost.org/trac/boost/changeset/84933

Log:
Check for errors when writing dependencies.

Text files modified:
   trunk/tools/quickbook/doc/change_log.qbk | 1 +
   trunk/tools/quickbook/src/dependency_tracker.cpp | 18 +++++++++++++++++-
   trunk/tools/quickbook/src/dependency_tracker.hpp | 1 +
   trunk/tools/quickbook/src/quickbook.cpp | 9 ++++++---
   4 files changed, 25 insertions(+), 4 deletions(-)

Modified: trunk/tools/quickbook/doc/change_log.qbk
==============================================================================
--- trunk/tools/quickbook/doc/change_log.qbk Mon Jul 1 15:34:07 2013 (r84932)
+++ trunk/tools/quickbook/doc/change_log.qbk 2013-07-01 15:34:33 EDT (Mon, 01 Jul 2013) (r84933)
@@ -301,3 +301,4 @@
 
 * Remove nested blocks in lists from 1.6, move to 1.7.
   (Can still nest block elements in lists though).
+* Check for errors when writing dependency files.

Modified: trunk/tools/quickbook/src/dependency_tracker.cpp
==============================================================================
--- trunk/tools/quickbook/src/dependency_tracker.cpp Mon Jul 1 15:34:07 2013 (r84932)
+++ trunk/tools/quickbook/src/dependency_tracker.cpp 2013-07-01 15:34:33 EDT (Mon, 01 Jul 2013) (r84933)
@@ -9,6 +9,7 @@
 #include "dependency_tracker.hpp"
 #include "input_path.hpp"
 #include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/fstream.hpp>
 #include <boost/foreach.hpp>
 
 namespace quickbook
@@ -90,7 +91,7 @@
     static std::string get_path(fs::path const& path,
             dependency_tracker::flags f)
     {
- std::string generic = detail::path_to_generic(path);
+ std::string generic = quickbook::detail::path_to_generic(path);
 
         if (f & dependency_tracker::escaped) {
             generic = escaped_path(generic);
@@ -105,6 +106,21 @@
         return found;
     }
 
+ void dependency_tracker::write_dependencies(fs::path const& file_out,
+ flags f)
+ {
+ fs::ofstream out(file_out);
+
+ if (out.fail()) {
+ throw std::runtime_error(
+ "Error opening dependency file " +
+ quickbook::detail::path_to_generic(file_out));
+ }
+
+ out.exceptions(std::ios::badbit);
+ write_dependencies(out, f);
+ }
+
     void dependency_tracker::write_dependencies(std::ostream& out,
             flags f)
     {

Modified: trunk/tools/quickbook/src/dependency_tracker.hpp
==============================================================================
--- trunk/tools/quickbook/src/dependency_tracker.hpp Mon Jul 1 15:34:07 2013 (r84932)
+++ trunk/tools/quickbook/src/dependency_tracker.hpp 2013-07-01 15:34:33 EDT (Mon, 01 Jul 2013) (r84933)
@@ -35,6 +35,7 @@
         // list of dependencies. Returns true if file exists.
         bool add_dependency(fs::path const&);
 
+ void write_dependencies(fs::path const&, flags = default_);
         void write_dependencies(std::ostream&, flags = default_);
     };
 }

Modified: trunk/tools/quickbook/src/quickbook.cpp
==============================================================================
--- trunk/tools/quickbook/src/quickbook.cpp Mon Jul 1 15:34:07 2013 (r84932)
+++ trunk/tools/quickbook/src/quickbook.cpp 2013-07-01 15:34:33 EDT (Mon, 01 Jul 2013) (r84933)
@@ -162,15 +162,14 @@
 
             if (!options_.deps_out.empty())
             {
- fs::ofstream out(options_.deps_out);
- state.dependencies.write_dependencies(out,
+ state.dependencies.write_dependencies(options_.deps_out,
                         options_.deps_out_flags);
             }
 
             if (!options_.locations_out.empty())
             {
                 fs::ofstream out(options_.locations_out);
- state.dependencies.write_dependencies(out,
+ state.dependencies.write_dependencies(options_.locations_out,
                         dependency_tracker::checked);
             }
         }
@@ -178,6 +177,10 @@
             detail::outerr(filein_) << e.what() << std::endl;
             result = 1;
         }
+ catch (std::runtime_error& e) {
+ detail::outerr() << e.what() << std::endl;
+ result = 1;
+ }
 
         if (!fileout_.empty() && result == 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