diff --git a/kstars/ekos/capture/placeholderpath.cpp b/kstars/ekos/capture/placeholderpath.cpp index 97e3fa002..49dac220b 100644 --- a/kstars/ekos/capture/placeholderpath.cpp +++ b/kstars/ekos/capture/placeholderpath.cpp @@ -302,6 +302,9 @@ QString PlaceholderPath::generateFilename(const QString &directory, QString tempFormat = currentDir + format + "_%s" + QString::number(formatSuffix); +#if defined(Q_OS_WIN) + tempFormat.replace("\\", "/"); +#endif QRegularExpressionMatch match; QRegularExpression // This is the original regex with %p & %d tags - disabled for now to simply diff --git a/kstars/ekos/scheduler/scheduler.cpp b/kstars/ekos/scheduler/scheduler.cpp index 41aaee892..e00276a3e 100644 --- a/kstars/ekos/scheduler/scheduler.cpp +++ b/kstars/ekos/scheduler/scheduler.cpp @@ -7525,9 +7525,36 @@ SequenceJob * Scheduler::processJobInfo(XMLEle *root, SchedulerJob *schedJob) int Scheduler::getCompletedFiles(const QString &path) { int seqFileCount = 0; +#ifdef Q_OS_WIN + // Splitting directory and baseName in QFileInfo does not distinguish regular expression backslash from directory separator on Windows. + // So do not use QFileInfo for the code that separates directory and basename for Windows. + // Conditions for calling this function: + // - Directory separators must always be "/". + // - Directory separators must not contain backslash. + QString sig_dir; + QString sig_file; + int index = path.lastIndexOf('/'); + if (0 <= index) + { // found '/'. path has both dir and filename + sig_dir = path.left(index); + sig_file = path.mid(index+1); + } // not found '/'. path has only filename + else + { + sig_file = path; + } + // remove extension + index = sig_file.lastIndexOf('.'); + if (0 <= index) + { // found '.', then remove extension + sig_file = sig_file.left(index); + } + qCDebug(KSTARS_EKOS_SCHEDULER) << "Scheduler::getCompletedFiles path:" << path << " sig_dir:" << sig_dir << " sig_file:" << sig_file; +#else QFileInfo const path_info(path); QString const sig_dir(path_info.dir().path()); QString const sig_file(path_info.completeBaseName()); +#endif QRegularExpression re(sig_file); QDirIterator it(sig_dir, QDir::Files);