From bb28f0aa0337510fc631d40089dc93af3b3fd629 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Thu, 19 Dec 2024 19:43:09 +0300 Subject: [PATCH] ... --- raptor_eagle_ccd.cpp | 19 ++++++++++++------- raptor_eagle_exception.h | 3 +++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/raptor_eagle_ccd.cpp b/raptor_eagle_ccd.cpp index 9802b60..8cde2d9 100644 --- a/raptor_eagle_ccd.cpp +++ b/raptor_eagle_ccd.cpp @@ -997,15 +997,20 @@ void RaptorEagleCCD::startAquisition() // check filesystem permissions std::error_code ec; std::filesystem::path pt(acq_pars->filename); - pt = std::filesystem::canonical(pt.parent_path(), ec); - if (ec) { - logError("Invalid FITS-image filename path!"); - throw std::system_error(ec); + pt = pt.parent_path(); + if (pt.empty()) { + pt = "."; } - int res = access(pt.c_str(), W_OK | X_OK); - if (!res) { - logError("Invalid FITS-image filename! Insufficient filesystem permissions!"); + 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); } diff --git a/raptor_eagle_exception.h b/raptor_eagle_exception.h index 448b156..f613f40 100644 --- a/raptor_eagle_exception.h +++ b/raptor_eagle_exception.h @@ -16,6 +16,7 @@ enum class RaptorEagleCCDError : int { ERROR_CANNOT_RESET_FPGA, ERROR_EXT_TRIGGER_MODE, ERROR_ACQUISITION_IN_PROGRESS, + ERROR_INVALID_PATH, ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS }; @@ -63,6 +64,8 @@ struct RaptorEagleCCDErrorCategory : std::error_category { return "try to use software trigger while external trigger mode is enabled"; case RaptorEagleCCDError::ERROR_ACQUISITION_IN_PROGRESS: return "acquisition is in progress"; + case RaptorEagleCCDError::ERROR_INVALID_PATH: + return "invalid filesystem path"; case RaptorEagleCCDError::ERROR_INSUFFICIENT_FILESYSTEM_PERMISSIONS: return "insufficient filesystem permissions"; default: