mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Truncate the file used for the region mapping
This commit is contained in:
parent
960b612d80
commit
5a49c5b9b1
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <ios>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -49,7 +50,17 @@ Region::Region(Manager& manager, uint64_t id, uint64_t size, bool remote, Region
|
||||||
if (path != "") {
|
if (path != "") {
|
||||||
fName = string(path + fName);
|
fName = string(path + fName);
|
||||||
|
|
||||||
fFile = fopen(fName.c_str(), fRemote ? "r+" : "w+");
|
if (!fRemote) {
|
||||||
|
// create a file
|
||||||
|
filebuf fbuf;
|
||||||
|
if (fbuf.open(fName, ios_base::in | ios_base::out | ios_base::trunc | ios_base::binary)) {
|
||||||
|
// set the size
|
||||||
|
fbuf.pubseekoff(size - 1, ios_base::beg);
|
||||||
|
fbuf.sputc(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fFile = fopen(fName.c_str(), "r+");
|
||||||
|
|
||||||
if (!fFile) {
|
if (!fFile) {
|
||||||
LOG(error) << "Failed to initialize file: " << fName;
|
LOG(error) << "Failed to initialize file: " << fName;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user