diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-07-22 12:47:21 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-07-23 20:13:21 +0300 |
commit | 2d9579da2144b2a8d67ea1d05fde96ec9d365944 (patch) | |
tree | b4e033f0e8284309efeecd68ba1e9cd70dc75220 /build2/config/operation.cxx | |
parent | 3425432752d362341b8e39cd319d7f3c56aef169 (diff) |
Adapt to fdstream extension
Diffstat (limited to 'build2/config/operation.cxx')
-rw-r--r-- | build2/config/operation.cxx | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx index 1b40832..617e74c 100644 --- a/build2/config/operation.cxx +++ b/build2/config/operation.cxx @@ -5,7 +5,6 @@ #include <build2/config/operation> #include <set> -#include <fstream> #include <build2/file> #include <build2/scope> @@ -48,21 +47,19 @@ namespace build2 try { - ofstream ofs (f.string ()); - if (!ofs.is_open ()) - fail << "unable to open " << f; - - ofs.exceptions (ofstream::failbit | ofstream::badbit); + ofdstream ofs (f); ofs << "# Created automatically by the config module." << endl << "#" << endl << "src_root = "; to_stream (ofs, name (src_root), true, '@'); // Quote. ofs << endl; + + ofs.close (); } - catch (const ofstream::failure&) + catch (const ofdstream::failure& e) { - fail << "unable to write " << f; + fail << "unable to write " << f << ": " << e.what (); } } @@ -79,11 +76,7 @@ namespace build2 try { - ofstream ofs (f.string ()); - if (!ofs.is_open ()) - fail << "unable to open " << f; - - ofs.exceptions (ofstream::failbit | ofstream::badbit); + ofdstream ofs (f); ofs << "# Created automatically by the config module, but feel " << "free to edit." << endl @@ -248,10 +241,12 @@ namespace build2 ofs << n << " = [null]" << endl; } } + + ofs.close (); } - catch (const ofstream::failure&) + catch (const ofdstream::failure& e) { - fail << "unable to write " << f; + fail << "unable to write " << f << ": " << e.what (); } } |