microbitfs.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * This file is part of the Micro Python project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2016 Mark Shannon
  7. * Copyright (c) 2017 Ayke van Laethem
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. */
  27. #ifndef __MICROPY_INCLUDED_FILESYSTEM_H__
  28. #define __MICROPY_INCLUDED_FILESYSTEM_H__
  29. #include "py/obj.h"
  30. #include "py/lexer.h"
  31. #ifndef MBFS_LOG_CHUNK_SIZE
  32. // This property can be tuned to make the filesystem bigger (while keeping
  33. // the max number of blocks). Note that it cannot (currently) be increased
  34. // beyond 8 or uint8_t integers will overflow.
  35. // 2^7 == 128 bytes
  36. // (128-2) bytes/block * 252 blocks = 31752 usable bytes
  37. #define MBFS_LOG_CHUNK_SIZE 7
  38. #endif
  39. mp_obj_t uos_mbfs_open(size_t n_args, const mp_obj_t *args);
  40. void microbit_filesystem_init(void);
  41. mp_lexer_t *uos_mbfs_new_reader(const char *filename);
  42. mp_import_stat_t uos_mbfs_import_stat(const char *path);
  43. MP_DECLARE_CONST_FUN_OBJ_0(uos_mbfs_listdir_obj);
  44. MP_DECLARE_CONST_FUN_OBJ_0(uos_mbfs_ilistdir_obj);
  45. MP_DECLARE_CONST_FUN_OBJ_1(uos_mbfs_remove_obj);
  46. MP_DECLARE_CONST_FUN_OBJ_1(uos_mbfs_stat_obj);
  47. #endif // __MICROPY_INCLUDED_FILESYSTEM_H__