4747#include "supervisor/shared/reload.h"
4848#include "supervisor/shared/bluetooth/file_transfer.h"
4949#include "supervisor/shared/bluetooth/file_transfer_protocol.h"
50+ #include "supervisor/shared/workflow.h"
5051#include "supervisor/shared/tick.h"
5152#include "supervisor/usb.h"
5253
5354#include "py/mpstate.h"
54- #include "py/stackctrl.h"
5555
5656STATIC bleio_service_obj_t supervisor_ble_service ;
5757STATIC bleio_uuid_obj_t supervisor_ble_service_uuid ;
@@ -387,39 +387,6 @@ STATIC uint8_t _process_write_data(const uint8_t *raw_buf, size_t command_len) {
387387 return WRITE_DATA ;
388388}
389389
390- STATIC FRESULT _delete_directory_contents (FATFS * fs , const TCHAR * path ) {
391- FF_DIR dir ;
392- FRESULT res = f_opendir (fs , & dir , path );
393- FILINFO file_info ;
394- // Check the stack since we're putting paths on it.
395- if (mp_stack_usage () >= MP_STATE_THREAD (stack_limit )) {
396- return FR_INT_ERR ;
397- }
398- while (res == FR_OK ) {
399- res = f_readdir (& dir , & file_info );
400- if (res != FR_OK || file_info .fname [0 ] == '\0' ) {
401- break ;
402- }
403- size_t pathlen = strlen (path );
404- size_t fnlen = strlen (file_info .fname );
405- TCHAR full_path [pathlen + 1 + fnlen ];
406- memcpy (full_path , path , pathlen );
407- full_path [pathlen ] = '/' ;
408- size_t full_pathlen = pathlen + 1 + fnlen ;
409- memcpy (full_path + pathlen + 1 , file_info .fname , fnlen );
410- full_path [full_pathlen ] = '\0' ;
411- if ((file_info .fattrib & AM_DIR ) != 0 ) {
412- res = _delete_directory_contents (fs , full_path );
413- }
414- if (res != FR_OK ) {
415- break ;
416- }
417- res = f_unlink (fs , full_path );
418- }
419- f_closedir (& dir );
420- return res ;
421- }
422-
423390STATIC uint8_t _process_delete (const uint8_t * raw_buf , size_t command_len ) {
424391 const struct delete_command * command = (struct delete_command * )raw_buf ;
425392 size_t header_size = sizeof (struct delete_command );
@@ -446,7 +413,7 @@ STATIC uint8_t _process_delete(const uint8_t *raw_buf, size_t command_len) {
446413 FRESULT result = f_stat (fs , path , & file );
447414 if (result == FR_OK ) {
448415 if ((file .fattrib & AM_DIR ) != 0 ) {
449- result = _delete_directory_contents (fs , path );
416+ result = supervisor_workflow_delete_directory_contents (fs , path );
450417 }
451418 if (result == FR_OK ) {
452419 result = f_unlink (fs , path );
@@ -503,7 +470,7 @@ STATIC uint8_t _process_mkdir(const uint8_t *raw_buf, size_t command_len) {
503470 DWORD fattime ;
504471 response .truncated_time = truncate_time (command -> modification_time , & fattime );
505472 override_fattime (fattime );
506- FRESULT result = f_mkdir (fs , path );
473+ FRESULT result = supervisor_workflow_mkdir_parents (fs , path );
507474 override_fattime (0 );
508475 #if CIRCUITPY_USB_MSC
509476 usb_msc_unlock ();
0 commit comments