This commit is contained in:
Timur A. Fatkhullin 2024-12-20 11:07:29 +03:00
parent 610d09ee98
commit 66e0b6c71e
2 changed files with 38 additions and 25 deletions

View File

@ -1,5 +1,6 @@
#include <fitsio.h>
#include <cmath>
#include <filesystem>
#include "raptor_eagle_ccd.h"
@ -241,7 +242,9 @@ void RaptorEagleCCD::AcquisitionProcess::start(const std::shared_ptr<acq_params_
fits_update_key_str(fitsFilePtr, "ORIGIN", "SAO RAS", NULL, &status);
fits_update_key_str(fitsFilePtr, "CREATOR", "RaptorEagleV control software", NULL, &status);
fits_update_key_str(fitsFilePtr, "FILE", _acqParams->filename.c_str(), "Original filename", &status);
// fits_update_key_str(fitsFilePtr, "FILE", _acqParams->filename.c_str(), "Original filename", &status);
std::filesystem::path pt = _acqParams->filename;
fits_update_key_str(fitsFilePtr, "FILE", pt.filename().c_str(), "Original filename", &status);
fits_write_date(fitsFilePtr, &status);

View File

@ -965,6 +965,35 @@ void RaptorEagleCCD::startAquisition()
throw std::system_error(RaptorEagleCCDError::ERROR_EXT_TRIGGER_MODE);
}
// check filesystem permissions
std::string fname = (*this)[CAMERA_ATTR_FITS_FILENAME];
std::error_code ec;
std::filesystem::path pt(fname);
if (pt.filename().empty()) {
fname = "";
} else {
pt = pt.parent_path();
if (pt.empty()) {
pt = ".";
}
auto pt_cn = std::filesystem::canonical(pt, ec);
if (ec) {
logError("Invalid FITS-image filename path: {}", pt.c_str());
throw std::system_error(RaptorEagleCCDError::ERROR_INVALID_PATH);
}
// still only for POSIX OSes
int res = access(pt_cn.c_str(), W_OK | X_OK);
if (res == -1) {
logError("Invalid FITS-image path! Insufficient filesystem permissions!");
throw std::system_error(RaptorEagleCCDError::ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS);
}
fname = pt_cn; // use canonical file path
}
logInfo("Start acquisition process ...");
@ -988,32 +1017,13 @@ void RaptorEagleCCD::startAquisition()
.tecSetPoint = (*this)[CAMERA_ATTR_TECPOINT],
.tecState = (*this)[CAMERA_ATTR_TECSTATE] == CAMERA_ATTR_TECSTATE_ON ? true : false,
.pcbTemp = (*this)[CAMERA_ATTR_PCB_TEMP],
.filename = (*this)[CAMERA_ATTR_FITS_FILENAME],
// .filename = (*this)[CAMERA_ATTR_FITS_FILENAME],
.filename = fname,
.templateFilename = (*this)[CAMERA_ATTR_FITS_TEMPLATE],
.permanentKeywords = _permanentFitsKeywords, // copy
.currentKeywords = std::move(_currentFitsKeywords) // move!!!
}));
// check filesystem permissions
std::error_code ec;
std::filesystem::path pt(acq_pars->filename);
pt = pt.parent_path();
if (pt.empty()) {
pt = ".";
}
auto pt_cn = std::filesystem::canonical(pt, ec);
if (ec) {
logError("Invalid FITS-image filename path: {}", pt.c_str());
throw std::system_error(RaptorEagleCCDError::ERROR_INVALID_PATH);
}
int res = access(pt_cn.c_str(), W_OK | X_OK);
if (res == -1) {
logError("Invalid FITS-image path! Insufficient filesystem permissions!");
throw std::system_error(RaptorEagleCCDError::ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS);
}
// adjust geometry
@ -1235,7 +1245,7 @@ void RaptorEagleCCD::initAttrComm()
if (!s.empty() || !s_head.empty()) {
s = s_head + s;
if (_acqProcesses.size() == 1) {
s.resize(s.size() - 2); // delete trailing ", "
s.resize(s.size() - 1); // delete trailing ","
}
} else {
s = std::string{CAMERA_ATTR_CAMERA_STATUS_IDLE.begin(), CAMERA_ATTR_CAMERA_STATUS_IDLE.end()};