aboutsummaryrefslogtreecommitdiff
path: root/bpkg/cfg-create.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2016-07-22 12:43:22 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2016-07-23 20:06:50 +0300
commit1d9f410810de6fbb9c974735e5e14dbebe1c0718 (patch)
treef44b04d9e0a13a21deb7f59f1a2ae8334daf7f94 /bpkg/cfg-create.cxx
parent7ea82c5013ab3c3d44b4b85cf767559e7019854f (diff)
Adapt to fdstream extension
Diffstat (limited to 'bpkg/cfg-create.cxx')
-rw-r--r--bpkg/cfg-create.cxx32
1 files changed, 16 insertions, 16 deletions
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 <bpkg/cfg-create>
-#include <fstream>
+#include <butl/fdstream>
#include <bpkg/package>
#include <bpkg/package-odb>
@@ -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.