|
|
@ -547,6 +547,7 @@ void CardReader::release() { |
|
|
|
#if ALL(SDCARD_SORT_ALPHA, SDSORT_USES_RAM, SDSORT_CACHE_NAMES) |
|
|
|
nrFiles = 0; |
|
|
|
#endif |
|
|
|
SERIAL_ECHO_MSG(STR_SD_CARD_RELEASED); |
|
|
|
} |
|
|
|
|
|
|
|
/**
|
|
|
@ -642,7 +643,7 @@ void announceOpen(const uint8_t doing, const char * const path) { |
|
|
|
// - 2 : Resuming from a sub-procedure
|
|
|
|
//
|
|
|
|
void CardReader::openFileRead(const char * const path, const uint8_t subcall_type/*=0*/) { |
|
|
|
if (!isMounted()) return; |
|
|
|
if (!isMounted()) return openFailed(path); |
|
|
|
|
|
|
|
switch (subcall_type) { |
|
|
|
case 0: // Starting a new print. "Now fresh file: ..."
|
|
|
@ -684,7 +685,7 @@ void CardReader::openFileRead(const char * const path, const uint8_t subcall_typ |
|
|
|
|
|
|
|
SdFile *diveDir; |
|
|
|
const char * const fname = diveToFile(true, diveDir, path); |
|
|
|
if (!fname) return; |
|
|
|
if (!fname) return openFailed(path); |
|
|
|
|
|
|
|
if (file.open(diveDir, fname, O_READ)) { |
|
|
|
filesize = file.fileSize(); |
|
|
@ -720,21 +721,20 @@ void CardReader::openFileWrite(const char * const path) { |
|
|
|
|
|
|
|
SdFile *diveDir; |
|
|
|
const char * const fname = diveToFile(false, diveDir, path); |
|
|
|
if (!fname) return; |
|
|
|
if (!fname) return openFailed(path); |
|
|
|
|
|
|
|
#if ENABLED(SDCARD_READONLY) |
|
|
|
openFailed(fname); |
|
|
|
#else |
|
|
|
#if DISABLED(SDCARD_READONLY) |
|
|
|
if (file.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { |
|
|
|
flag.saving = true; |
|
|
|
selectFileByName(fname); |
|
|
|
TERN_(EMERGENCY_PARSER, emergency_parser.disable()); |
|
|
|
echo_write_to_file(fname); |
|
|
|
ui.set_status(fname); |
|
|
|
return; |
|
|
|
} |
|
|
|
else |
|
|
|
openFailed(fname); |
|
|
|
#endif |
|
|
|
|
|
|
|
openFailed(fname); |
|
|
|
} |
|
|
|
|
|
|
|
//
|
|
|
|