Open a file by DOS path for write
| 861 | // Open a file by DOS path for write |
| 862 | // |
| 863 | void CardReader::openFileWrite(const char * const path) { |
| 864 | if (!isMounted()) return; |
| 865 | |
| 866 | announceOpen(2, path); |
| 867 | TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0); |
| 868 | |
| 869 | abortFilePrintNow(); |
| 870 | |
| 871 | MediaFile *diveDir; |
| 872 | const char * const fname = diveToFile(false, diveDir, path); |
| 873 | if (!fname) return openFailed(path); |
| 874 | |
| 875 | #if DISABLED(SDCARD_READONLY) |
| 876 | if (myfile.open(diveDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { |
| 877 | flag.saving = true; |
| 878 | selectFileByName(fname); |
| 879 | TERN_(EMERGENCY_PARSER, emergency_parser.disable()); |
| 880 | echo_write_to_file(fname); |
| 881 | ui.set_status(fname); |
| 882 | return; |
| 883 | } |
| 884 | #endif |
| 885 | |
| 886 | openFailed(fname); |
| 887 | } |
| 888 | |
| 889 | /** |
| 890 | * Check if a file exists by absolute or workDir-relative path |
no test coverage detected