From 2d9579da2144b2a8d67ea1d05fde96ec9d365944 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 22 Jul 2016 12:47:21 +0300 Subject: Adapt to fdstream extension --- build2/config/operation.cxx | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'build2/config') 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 #include -#include #include #include @@ -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 (); } } -- cgit v1.1