dev/handes trailing / in filepath (#1391)
Some checks failed
Build on RHEL9 / build (push) Successful in 3m22s
Run Simulator Tests on local RHEL9 / build (push) Failing after 3m49s
Build on local RHEL9 / build (push) Successful in 1m26s
Build on RHEL8 / build (push) Successful in 5m13s
Run Simulator Tests on local RHEL8 / build (push) Failing after 5m30s
Build on local RHEL8 / build (push) Successful in 3m33s

* member filePath in Implementation is std::filesystem::path, some refactoring

* PR Review

* adapted function signature - compiled with hdf5 on
This commit is contained in:
2026-02-17 17:11:33 +01:00
committed by GitHub
parent 26729b06cb
commit 65c8f2c7d8
11 changed files with 100 additions and 75 deletions

View File

@@ -483,10 +483,14 @@ void Implementation::setFileFormat(const fileFormat f) {
LOG(logINFO) << "File Format: " << ToString(fileFormatType);
}
std::string Implementation::getFilePath() const { return filePath; }
std::string Implementation::getFilePath() const { return filePath.string(); }
void Implementation::setFilePath(const std::string &c) {
filePath = c;
// check if filePath empty and throw error
if (c.empty()) {
throw ReceiverError("File path cannot be empty");
}
filePath = std::filesystem::path(c);
LOG(logINFO) << "File path: " << filePath;
}
@@ -651,7 +655,7 @@ void Implementation::startReceiver() {
generalData->dynamicRange,
numPorts,
static_cast<size_t>(generalData->imageSize),
filePath,
filePath.string(),
fileName,
fileIndex,
quadEnable,
@@ -851,9 +855,7 @@ void Implementation::ResetParametersforNewAcquisition() {
it->ResetParametersforNewAcquisition();
if (dataStreamEnable) {
std::ostringstream os;
os << filePath << '/' << fileName;
std::string fnametostream = os.str();
std::string fnametostream = (filePath / fileName).string();
for (const auto &it : dataStreamer)
it->ResetParametersforNewAcquisition(fnametostream);
}
@@ -874,21 +876,28 @@ void Implementation::CreateUDPSockets() {
void Implementation::SetupWriter() {
try {
// check if filePath empty and throw error
if (filePath.empty()) {
throw ReceiverError("File path cannot be empty");
}
// check if folder exists and throw if it cant create
mkdir_p(filePath);
if (filePath.empty()) {
throw RuntimeError("File path cannot be empty. Please set file "
"path before starting acquisition.");
}
if (!std::filesystem::exists(filePath)) {
try {
std::filesystem::create_directories(filePath);
} catch (const std::filesystem::filesystem_error &e) {
throw RuntimeError("Could not create directory: " +
filePath.string() + ". Error: " + e.what());
}
}
// create first files
for (unsigned int i = 0; i < dataProcessor.size(); ++i) {
std::ostringstream os;
os << filePath << "/" << fileName << "_d"
<< (modulePos * generalData->numUDPInterfaces + i);
std::string fileNamePrefix = os.str();
dataProcessor[i]->CreateFirstFiles(fileNamePrefix, fileIndex,
overwriteEnable, silentMode,
detectorDataStream[i]);
std::string fileNamePrefix =
fileName + "_d" +
std::to_string(modulePos * generalData->numUDPInterfaces + i);
dataProcessor[i]->CreateFirstFiles(
filePath, fileNamePrefix, fileIndex, overwriteEnable,
silentMode, detectorDataStream[i]);
}
} catch (const RuntimeError &e) {
shutDownUDPSockets();