47
47
#include "supervisor/shared/reload.h"
48
48
#include "supervisor/shared/bluetooth/file_transfer.h"
49
49
#include "supervisor/shared/bluetooth/file_transfer_protocol.h"
50
+ #include "supervisor/shared/workflow.h"
50
51
#include "supervisor/shared/tick.h"
51
52
#include "supervisor/usb.h"
52
53
53
54
#include "py/mpstate.h"
54
- #include "py/stackctrl.h"
55
55
56
56
STATIC bleio_service_obj_t supervisor_ble_service ;
57
57
STATIC 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) {
387
387
return WRITE_DATA ;
388
388
}
389
389
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
-
423
390
STATIC uint8_t _process_delete (const uint8_t * raw_buf , size_t command_len ) {
424
391
const struct delete_command * command = (struct delete_command * )raw_buf ;
425
392
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) {
446
413
FRESULT result = f_stat (fs , path , & file );
447
414
if (result == FR_OK ) {
448
415
if ((file .fattrib & AM_DIR ) != 0 ) {
449
- result = _delete_directory_contents (fs , path );
416
+ result = supervisor_workflow_delete_directory_contents (fs , path );
450
417
}
451
418
if (result == FR_OK ) {
452
419
result = f_unlink (fs , path );
@@ -503,7 +470,7 @@ STATIC uint8_t _process_mkdir(const uint8_t *raw_buf, size_t command_len) {
503
470
DWORD fattime ;
504
471
response .truncated_time = truncate_time (command -> modification_time , & fattime );
505
472
override_fattime (fattime );
506
- FRESULT result = f_mkdir (fs , path );
473
+ FRESULT result = supervisor_workflow_mkdir_parents (fs , path );
507
474
override_fattime (0 );
508
475
#if CIRCUITPY_USB_MSC
509
476
usb_msc_unlock ();
0 commit comments