|
@@ -66,11 +66,19 @@ void GcodeSuite::M502() {
|
|
|
|
|
|
#if ENABLED(CONFIGURATION_EMBEDDING)
|
|
|
if (parser.seen_test('C')) {
|
|
|
- SdBaseFile file;
|
|
|
- const uint16_t size = sizeof(mc_zip);
|
|
|
+ MediaFile file;
|
|
|
|
|
|
- if (file.open(card.getroot(), "mc.zip", O_WRITE|O_CREAT) && file.write(pgm_read_ptr(mc_zip), size) != -1 && file.close())
|
|
|
- SERIAL_ECHO_MSG("Configuration saved as 'mc.zip'");
|
|
|
+ MediaFile root = card.getroot();
|
|
|
+ if (file.open(&root, "mc.zip", O_WRITE|O_CREAT)) {
|
|
|
+ bool success = true;
|
|
|
+ for (uint16_t i = 0; success && i < sizeof(mc_zip); ++i) {
|
|
|
+ const uint8_t c = pgm_read_byte(&mc_zip[i]);
|
|
|
+ file.write(c);
|
|
|
+ }
|
|
|
+ success = file.close() && success;
|
|
|
+
|
|
|
+ if (success) SERIAL_ECHO_MSG("Configuration saved as 'mc.zip'");
|
|
|
+ }
|
|
|
}
|
|
|
#endif
|
|
|
}
|