mphalport.c 878 B

12345678910111213141516171819202122232425262728293031323334
  1. #include <stdio.h>
  2. #include <furi.h>
  3. #include <storage/storage.h>
  4. #include <py/mphal.h>
  5. #include <py/builtin.h>
  6. #include <mp_flipper_app.h>
  7. const mp_obj_fun_builtin_var_t mp_builtin_open_obj;
  8. void mp_hal_stdout_tx_str(const char* str) {
  9. printf("%s", str);
  10. }
  11. mp_import_stat_t mp_import_stat(const char* path) {
  12. Storage* storage = furi_record_open(RECORD_STORAGE);
  13. FuriString* file_path = furi_string_alloc();
  14. mp_import_stat_t stat = MP_IMPORT_STAT_NO_EXIST;
  15. furi_string_printf(file_path, "%s/%s", root_module_path, path);
  16. FileInfo* info = NULL;
  17. if(storage_common_stat(storage, furi_string_get_cstr(file_path), info) == FSE_OK) {
  18. stat = (info && info->flags & FSF_DIRECTORY) == FSF_DIRECTORY ? MP_IMPORT_STAT_DIR : MP_IMPORT_STAT_FILE;
  19. }
  20. furi_string_free(file_path);
  21. furi_record_close(RECORD_STORAGE);
  22. return stat;
  23. }