fix checking file permissions before start exposure

This commit is contained in:
Timur A. Fatkhullin 2024-12-19 19:22:55 +03:00
parent 6c45f04448
commit 34959c632d

View File

@ -994,35 +994,24 @@ void RaptorEagleCCD::startAquisition()
.currentKeywords = std::move(_currentFitsKeywords) // move!!!
}));
// check filesystem
// check filesystem permissions
std::error_code ec;
std::filesystem::path pt(acq_pars->filename);
auto perms = std::filesystem::status(pt.parent_path()).permissions();
bool good_perm = (std::filesystem::perms::owner_write & perms) != std::filesystem::perms::none;
good_perm &= (std::filesystem::perms::owner_exec & perms) != std::filesystem::perms::none;
pt = std::filesystem::canonical(pt.parent_path(), ec);
if (ec) {
logError("Invalid FITS-image filename path!");
throw std::system_error(ec);
}
if (!good_perm) {
int res = access(pt.c_str(), W_OK | X_OK);
if (!res) {
logError("Invalid FITS-image filename! Insufficient filesystem permissions!");
throw std::system_error(RaptorEagleCCDError::ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS);
}
// adjust geometry
// auto dv = std::div(_dimCCD[0] - acq_pars->roiStartX, acq_pars->binX);
// auto width_max = dv.quot + (dv.rem ? 1 : 0);
// dv = std::div(_dimCCD[1] - acq_pars->roiStartY, acq_pars->binY);
// auto height_max = dv.quot + (dv.rem ? 1 : 0);
// if (acq_pars->roiWidth > width_max) {
// // acq_pars->roiWidth = width_max;
// logDebug("Adjust ROI width to {}", acq_pars->roiWidth);
// // (*this)[CAMERA_ATTR_ROI_WIDTH] = width_max;
// }
// if (acq_pars->roiHeight > height_max) {
// // acq_pars->roiHeight = height_max;
// logDebug("Adjust ROI height to {}", acq_pars->roiHeight);
// // (*this)[CAMERA_ATTR_ROI_HEIGHT] = height_max;
// }
auto xmax = acq_pars->roiStartX + acq_pars->roiWidth;
auto ymax = acq_pars->roiStartY + acq_pars->roiHeight;