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