From 3ed32ccad39bb0e61e869a50d3946939eddacb3e Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Thu, 3 Jul 2014 02:55:38 +1000 Subject: [PATCH] Added simple PRS1 SD card Backup functionality --- .../SleepLib/loader_plugins/prs1_loader.cpp | 28 ++++++++++++++++++- sleepyhead/docs/release_notes.html | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp index e16e0ac4..a5f19bfd 100644 --- a/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/prs1_loader.cpp @@ -356,6 +356,31 @@ bool PRS1Loader::ParseProperties(Machine *m, QString filename) return true; } +void copyPath(QString src, QString dst) +{ + QDir dir(src); + if (!dir.exists()) + return; + + // Recursively handle directories + foreach (QString d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { + QString dst_path = dst + QDir::separator() + d; + dir.mkpath(dst_path); + copyPath(src + QDir::separator() + d, dst_path); + } + + // Files + foreach (QString f, dir.entryList(QDir::Files)) { + QString srcFile = src + QDir::separator() + f; + QString destFile = dst + QDir::separator() + f; + + if (!QFile::exists(destFile)) { + QFile::copy(srcFile, destFile); + } + } +} + + int PRS1Loader::OpenMachine(Machine *m, QString path, Profile *profile) { Q_UNUSED(profile) @@ -366,7 +391,8 @@ int PRS1Loader::OpenMachine(Machine *m, QString path, Profile *profile) if (!dir.exists() || (!dir.isReadable())) { return 0; } - + QString backupPath = p_profile->Get(m->properties[STR_PROP_BackupPath]) + path.section("/", -2); + copyPath(path, backupPath); dir.setFilter(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoSymLinks); dir.setSorting(QDir::Name); diff --git a/sleepyhead/docs/release_notes.html b/sleepyhead/docs/release_notes.html index 057868ab..493c7407 100644 --- a/sleepyhead/docs/release_notes.html +++ b/sleepyhead/docs/release_notes.html @@ -9,6 +9,8 @@

0.9.7 already? Yup.. otherwise I can't tell them apart, and you probably won't be able to either. Before anyone asks, yes, version numbers will go past 0.9.10 before 1.0.0 is reached.

Not a gigantic set of changes this time, but I've been busily working my way through a lot of bugs mentioned on the forums, trying to knock them down one by one. Please don't be offended if yours isn't in here yet.. I have a memory like a goldfish, plus I tried to focus on stability issues first.

A gentle reminder for anyone submitting bug reports (either via message or through sourceforges bug reporting system), please (please please) remember to state the SleepyHead version number, your computers platform and operating system type version (and service packs), and your CPAP machines type and model number. Without this information I pretty much don't have a clue what you are talking about.

+

Known Issues with this build

+There is still a problem with time splits for summary only..
New features & bug fixes in v0.9.7