lexermemzip.c 410 B

12345678910111213141516171819
  1. #include <stdlib.h>
  2. #include "py/lexer.h"
  3. #include "py/runtime.h"
  4. #include "py/mperrno.h"
  5. #include "memzip.h"
  6. mp_lexer_t *mp_lexer_new_from_file(const char *filename)
  7. {
  8. void *data;
  9. size_t len;
  10. if (memzip_locate(filename, &data, &len) != MZ_OK) {
  11. mp_raise_OSError(MP_ENOENT);
  12. }
  13. return mp_lexer_new_from_str_len(qstr_from_str(filename), (const char *)data, (mp_uint_t)len, 0);
  14. }