From 70ce4f5b36a0a9c51e87ec133921e21189a11b28 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 2 Aug 2019 02:22:09 -0500 Subject: [PATCH] Move job recovery filename --- Marlin/src/feature/power_loss_recovery.h | 2 ++ Marlin/src/sd/cardreader.cpp | 12 +++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Marlin/src/feature/power_loss_recovery.h b/Marlin/src/feature/power_loss_recovery.h index 57873df265..993a8dbb33 100644 --- a/Marlin/src/feature/power_loss_recovery.h +++ b/Marlin/src/feature/power_loss_recovery.h @@ -103,6 +103,8 @@ typedef struct { class PrintJobRecovery { public: + static constexpr char filename[5] = "/PLR"; + static SdFile file; static job_recovery_info_t info; diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index d89503963f..76fe43d09b 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -1042,10 +1042,8 @@ void CardReader::printingHasFinished() { #if ENABLED(POWER_LOSS_RECOVERY) - constexpr char job_recovery_file_name[5] = "/PLR"; - bool CardReader::jobRecoverFileExists() { - const bool exists = recovery.file.open(&root, job_recovery_file_name, O_READ); + const bool exists = recovery.file.open(&root, recovery.filename, O_READ); if (exists) recovery.file.close(); return exists; } @@ -1053,10 +1051,10 @@ void CardReader::printingHasFinished() { void CardReader::openJobRecoveryFile(const bool read) { if (!isDetected()) return; if (recovery.file.isOpen()) return; - if (!recovery.file.open(&root, job_recovery_file_name, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC)) - SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, job_recovery_file_name, "."); + if (!recovery.file.open(&root, recovery.filename, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC)) + SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, recovery.filename, "."); else if (!read) - SERIAL_ECHOLNPAIR(MSG_SD_WRITE_TO_FILE, job_recovery_file_name); + SERIAL_ECHOLNPAIR(MSG_SD_WRITE_TO_FILE, recovery.filename); } // Removing the job recovery file currently requires closing @@ -1065,7 +1063,7 @@ void CardReader::printingHasFinished() { void CardReader::removeJobRecoveryFile() { if (jobRecoverFileExists()) { recovery.init(); - removeFile(job_recovery_file_name); + removeFile(recovery.filename); #if ENABLED(DEBUG_POWER_LOSS_RECOVERY) SERIAL_ECHOPGM("Power-loss file delete"); serialprintPGM(jobRecoverFileExists() ? PSTR(" failed.\n") : PSTR("d.\n"));