moduos_file.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2017 SummerGift <zhangyuan@rt-thread.com>
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #ifndef MICROPY_INCLUDED_PY_MODUOS_FILE_H
  27. #define MICROPY_INCLUDED_PY_MODUOS_FILE_H
  28. #include "py/lexer.h"
  29. #include "py/obj.h"
  30. // MicroPython's port-standardized versions of stat constants
  31. #define MP_S_IFDIR (0x4000)
  32. #define MP_S_IFREG (0x8000)
  33. // constants for block protocol ioctl
  34. #define BP_IOCTL_INIT (1)
  35. #define BP_IOCTL_DEINIT (2)
  36. #define BP_IOCTL_SYNC (3)
  37. #define BP_IOCTL_SEC_COUNT (4)
  38. #define BP_IOCTL_SEC_SIZE (5)
  39. mp_obj_t mp_posix_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
  40. mp_obj_t mp_posix_umount(mp_obj_t mnt_in);
  41. mp_obj_t mp_posix_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
  42. mp_obj_t mp_posix_chdir(mp_obj_t path_in);
  43. mp_obj_t mp_posix_getcwd(void);
  44. mp_obj_t mp_posix_listdir(size_t n_args, const mp_obj_t *args);
  45. mp_obj_t mp_posix_mkdir(mp_obj_t path_in);
  46. mp_obj_t mp_posix_remove(uint n_args, const mp_obj_t *arg);
  47. mp_obj_t mp_posix_rename(mp_obj_t old_path_in, mp_obj_t new_path_in);
  48. mp_obj_t mp_posix_rmdir(uint n_args, const mp_obj_t *arg);
  49. mp_obj_t mp_posix_stat(mp_obj_t path_in);
  50. mp_obj_t mp_posix_statvfs(mp_obj_t path_in);
  51. MP_DECLARE_CONST_FUN_OBJ_KW(mp_posix_mount_obj);
  52. MP_DECLARE_CONST_FUN_OBJ_1(mp_posix_umount_obj);
  53. MP_DECLARE_CONST_FUN_OBJ_KW(mp_posix_open_obj);
  54. MP_DECLARE_CONST_FUN_OBJ_1(mp_posix_chdir_obj);
  55. MP_DECLARE_CONST_FUN_OBJ_0(mp_posix_getcwd_obj);
  56. MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_posix_listdir_obj);
  57. MP_DECLARE_CONST_FUN_OBJ_1(mp_posix_mkdir_obj);
  58. MP_DECLARE_CONST_FUN_OBJ_VAR(mp_posix_remove_obj);
  59. MP_DECLARE_CONST_FUN_OBJ_2(mp_posix_rename_obj);
  60. MP_DECLARE_CONST_FUN_OBJ_VAR(mp_posix_rmdir_obj);
  61. MP_DECLARE_CONST_FUN_OBJ_1(mp_posix_stat_obj);
  62. MP_DECLARE_CONST_FUN_OBJ_1(mp_posix_statvfs_obj);
  63. #endif // MICROPY_INCLUDED_PY_MODUOS_FILE_H