From 1d9f410810de6fbb9c974735e5e14dbebe1c0718 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 22 Jul 2016 12:43:22 +0300 Subject: Adapt to fdstream extension --- bpkg/cfg-create.cxx | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'bpkg/cfg-create.cxx') diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx index 3d2121e..b5b1f41 100644 --- a/bpkg/cfg-create.cxx +++ b/bpkg/cfg-create.cxx @@ -4,7 +4,7 @@ #include -#include +#include #include #include @@ -72,9 +72,7 @@ namespace bpkg path f (b / path ("bootstrap.build")); try { - ofstream ofs; - ofs.exceptions (ofstream::badbit | ofstream::failbit); - ofs.open (f.string ()); + ofdstream ofs (f); ofs << "# Maintained automatically by bpkg. Edit if you know what " << "you are doing." << endl @@ -85,10 +83,12 @@ namespace bpkg << "using config" << endl << "using test" << endl << "using install" << endl; + + ofs.close (); } - catch (const ofstream::failure&) + catch (const ofdstream::failure& e) { - fail << "unable to write to " << f; + fail << "unable to write to " << f << ": " << e.what (); } // Write build/root.build. @@ -96,9 +96,7 @@ namespace bpkg f = b / path ("root.build"); try { - ofstream ofs; - ofs.exceptions (ofstream::badbit | ofstream::failbit); - ofs.open (f.string ()); + ofdstream ofs (f); ofs << "# Maintained automatically by bpkg. Edit if you know what " << "you are doing." << endl @@ -109,10 +107,12 @@ namespace bpkg // for (const string& m: mods) ofs << "using " << m << endl; + + ofs.close (); } - catch (const ofstream::failure&) + catch (const ofdstream::failure& e) { - fail << "unable to write to " << f; + fail << "unable to write to " << f << ": " << e.what (); } // Write root buildfile. @@ -120,18 +120,18 @@ namespace bpkg f = c / path ("buildfile"); try { - ofstream ofs; - ofs.exceptions (ofstream::badbit | ofstream::failbit); - ofs.open (f.string ()); + ofdstream ofs (f); ofs << "# Maintained automatically by bpkg. Edit if you know what " << "you are doing." << endl << "#" << endl << "./:" << endl; + + ofs.close (); } - catch (const ofstream::failure&) + catch (const ofdstream::failure& e) { - fail << "unable to write to " << f; + fail << "unable to write to " << f << ": " << e.what (); } // Configure. -- cgit v1.1