micropython 273 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. commit 29091048ae9a613070da21b373062a450f7ecd08
  2. Author: Oliver Fabel <28701799+ofabel@users.noreply.github.com>
  3. Date: Sun Oct 6 14:27:03 2024 +0200
  4. library update
  5. diff --git a/mp_flipper_fileio.c b/mp_flipper_fileio.c
  6. index d726e4394..345f4655a 100644
  7. --- a/mp_flipper_fileio.c
  8. +++ b/mp_flipper_fileio.c
  9. @@ -126,16 +126,29 @@ static mp_uint_t mp_flipper_fileio_ioctl(mp_obj_t self, mp_uint_t request, uintp
  10. static void fileio_attr(mp_obj_t self_in, qstr attr, mp_obj_t* dest) {
  11. mp_flipper_fileio_file_descriptor_t* fd = MP_OBJ_TO_PTR(self_in);
  12. +
  13. if(dest[0] == MP_OBJ_NULL) {
  14. if(attr == MP_QSTR_name) {
  15. dest[0] = fd->name;
  16. - } else if(attr == MP_QSTR_readable) {
  17. +
  18. + return;
  19. + }
  20. +
  21. + if(attr == MP_QSTR_readable) {
  22. dest[0] = (fd->access_mode & MP_FLIPPER_FILE_ACCESS_MODE_READ) ? mp_const_true : mp_const_false;
  23. - } else if(attr == MP_QSTR_writable) {
  24. +
  25. + return;
  26. + }
  27. +
  28. + if(attr == MP_QSTR_writable) {
  29. dest[0] = (fd->access_mode & MP_FLIPPER_FILE_ACCESS_MODE_WRITE) ? mp_const_true : mp_const_false;
  30. - } else {
  31. - dest[1] = MP_OBJ_SENTINEL;
  32. +
  33. + return;
  34. }
  35. +
  36. + dest[1] = MP_OBJ_SENTINEL;
  37. + } else {
  38. + return;
  39. }
  40. }
  41. @@ -167,10 +180,10 @@ MP_DEFINE_CONST_OBJ_TYPE(
  42. MP_TYPE_FLAG_ITER_IS_STREAM,
  43. protocol,
  44. &mp_flipper_binary_fileio_stream_p,
  45. - locals_dict,
  46. - &mp_flipper_file_locals_dict,
  47. attr,
  48. - fileio_attr);
  49. + fileio_attr,
  50. + locals_dict,
  51. + &mp_flipper_file_locals_dict);
  52. static const mp_stream_p_t mp_flipper_text_fileio_stream_p = {
  53. .read = mp_flipper_fileio_read,
  54. @@ -185,10 +198,10 @@ MP_DEFINE_CONST_OBJ_TYPE(
  55. MP_TYPE_FLAG_ITER_IS_STREAM,
  56. protocol,
  57. &mp_flipper_text_fileio_stream_p,
  58. - locals_dict,
  59. - &mp_flipper_file_locals_dict,
  60. attr,
  61. - fileio_attr);
  62. + fileio_attr,
  63. + locals_dict,
  64. + &mp_flipper_file_locals_dict);
  65. mp_obj_t mp_flipper_builtin_open(size_t n_args, const mp_obj_t* args, mp_map_t* kwargs) {
  66. const char* file_name = mp_obj_str_get_str(args[0]);