summaryrefslogtreecommitdiff
path: root/registry
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2013-02-03 10:29:51 +0100
committerStephan Bergmann <sbergman@redhat.com>2013-02-03 10:31:52 +0100
commit027b5e48329b508bd88616fe9dee8646e354480f (patch)
tree731ba333619bf15e745fbe8a512983ac5c4b685f /registry
parent81a915f98167062707d8c250cabc0483ff67cea9 (diff)
reg2bin: truncate pre-existing output files
Change-Id: If74cccf8657c1b81467ee9c0dea29a749ca07455
Diffstat (limited to 'registry')
-rw-r--r--registry/tools/reg2bin.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/registry/tools/reg2bin.cxx b/registry/tools/reg2bin.cxx
index 959f25d01d44..862289a07033 100644
--- a/registry/tools/reg2bin.cxx
+++ b/registry/tools/reg2bin.cxx
@@ -1395,6 +1395,14 @@ SAL_IMPLEMENT_MAIN() {
write32(f, 0); // root map offset
write32(f, 0); // root map size
sal_uInt64 off = writeMap(f, map, true);
+ e2 = f.setSize(getOffset(f)); // truncate in case it already existed
+ if (e2 != osl::FileBase::E_None) {
+ std::cerr
+ << "Cannot set size of \"" << f.getURL() << "\", error code "
+ << +e2 << "\n";
+ std::exit(EXIT_FAILURE);
+ }
+
e2 = f.setPos(osl_Pos_Absolut, 8);
if (e2 != osl::FileBase::E_None) {
std::cerr