From 0ff20017970d4c447d386077b1383acd98d869fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Poizl?= Date: Sun, 26 Jan 2025 15:54:28 +0100 Subject: [PATCH] Handle MAX_PATH every where --- loadrunable.cpp | 27 ++++++++++++++++++++++----- loadrunable.h | 1 + scriptengine.cpp | 14 ++++++++------ space.nouspiro.tenmon.metainfo.xml | 9 +++++++++ 4 files changed, 40 insertions(+), 11 deletions(-) diff --git a/loadrunable.cpp b/loadrunable.cpp index c75a918..50df37e 100644 --- a/loadrunable.cpp +++ b/loadrunable.cpp @@ -15,8 +15,23 @@ #include "starfit.h" #include +QString makeMaxPath(QString path) +{ +#ifdef Q_OS_WIN64 + if(!path.startsWith("\\\\?\\")) + { + QFileInfo info(path); + path = info.absoluteFilePath(); + path = QDir::toNativeSeparators(path); + path.prepend("\\\\?\\"); + qDebug() << path; + } +#endif + return path; +} + LoadRunable::LoadRunable(const QString &file, Image *receiver, AnalyzeLevel level, bool thumbnail) : - m_file(file), + m_file(makeMaxPath(file)), m_receiver(receiver), m_analyzeLevel(level), m_thumbnail(thumbnail) @@ -451,7 +466,8 @@ bool readFITSHeader(const QString &path, ImageInfoData &info) { fitsfile *fr; int status = 0; - fits_open_diskfile(&fr, path.toLocal8Bit().data(), READONLY, &status); + QString path2 = makeMaxPath(path); + fits_open_diskfile(&fr, path2.toLocal8Bit().data(), READONLY, &status); if(fr && status == 0) { @@ -463,10 +479,11 @@ bool readFITSHeader(const QString &path, ImageInfoData &info) bool readXISFHeader(const QString &path, ImageInfoData &info) { + QString path2 = makeMaxPath(path); try { LibXISF::XISFReader xisf; - xisf.open(path.toLocal8Bit().data()); + xisf.open(path2.toLocal8Bit().data()); const LibXISF::Image &image = xisf.getImage(0, false); auto fitskeywords = image.fitsKeywords(); @@ -532,8 +549,8 @@ bool loadImage(const QString &path, ImageInfoData &info, std::shared_ptr &rawImage, bool planar = false); diff --git a/scriptengine.cpp b/scriptengine.cpp index 666e949..f6f1ad8 100644 --- a/scriptengine.cpp +++ b/scriptengine.cpp @@ -519,7 +519,8 @@ bool File::modifyFITSRecords(const FITSRecordModify *modify) { fitsfile *file; int status = 0; - fits_open_diskfile(&file, _path.toLocal8Bit().data(), READWRITE, &status); + QString path = makeMaxPath(_path); + fits_open_diskfile(&file, path.toLocal8Bit().data(), READWRITE, &status); int num = 0; fits_get_num_hdus(file, &num, &status); if(status) @@ -642,9 +643,10 @@ bool File::modifyFITSRecords(const FITSRecordModify *modify) try { LibXISF::XISFModify modifyXISF; - modifyXISF.open(_path.toLocal8Bit().data()); - QFileInfo in(_path); - QFileInfo out(_path + "~"); + QString in = makeMaxPath(absoluteFilePath()); + QString out = in + "~"; + modifyXISF.open(in.toLocal8Bit().data()); + qDebug() << "modify" << in << out; for(auto &remove : modify->_remove) modifyXISF.removeFITSKeyword(0, remove.toStdString()); @@ -655,9 +657,9 @@ bool File::modifyFITSRecords(const FITSRecordModify *modify) for(auto &record : modify->_add) modifyXISF.addFITSKeyword(0, {record.key.toStdString(), record.value.toString().toStdString(), record.comment.toStdString()}); - modifyXISF.save(out.absoluteFilePath().toLocal8Bit().toStdString()); + modifyXISF.save(out.toLocal8Bit().toStdString()); modifyXISF.close(); - std::filesystem::rename(out.filesystemAbsoluteFilePath(), in.filesystemAbsoluteFilePath()); + std::filesystem::rename(out.toLocal8Bit().toStdString(), in.toLocal8Bit().toStdString()); return true; } catch(std::filesystem::filesystem_error &err) diff --git a/space.nouspiro.tenmon.metainfo.xml b/space.nouspiro.tenmon.metainfo.xml index 2cde282..54f6ed3 100644 --- a/space.nouspiro.tenmon.metainfo.xml +++ b/space.nouspiro.tenmon.metainfo.xml @@ -57,6 +57,15 @@ + + +
    +
  • Support for really big images +50000px
  • +
  • Fix handling of MAX_PATH on Windows
  • +
  • Add setting solver profile in scripts
  • +
+
+