From 8ea2dbd4738bd9d86376715bdb32452feea43f68 Mon Sep 17 00:00:00 2001 From: Rahix <rahix@rahix.de> Date: Fri, 26 Jul 2019 18:54:18 +0200 Subject: [PATCH] feat(api): Rename file functions to epic_file_* Signed-off-by: Rahix <rahix@rahix.de> --- epicardium/epicardium.h | 16 ++++++++-------- epicardium/modules/fatfs.c | 12 ++++++------ pycardium/modules/fat_file.c | 10 +++++----- pycardium/modules/fat_reader_import.c | 12 ++++++------ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index 32d9044c1..ece91dec7 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -451,8 +451,8 @@ API(API_LIGHT_SENSOR_STOP, int epic_light_sensor_stop()); /** * File * ==== - * Except for :c:func:`epic_open`, which models C stdio's ``fopen`` function, - * ``close``, ``read`` and ``write`` model `close(2)`_, `read(2)`_ and + * Except for :c:func:`epic_file_open`, which models C stdio's ``fopen`` + * function, ``close``, ``read`` and ``write`` model `close(2)`_, `read(2)`_ and * `write(2)`_. All file-related functions return >= ``0`` on success and * ``-Exyz`` on failure, with error codes from errno.h (``EIO``, ``EINVAL`` * etc.) @@ -465,23 +465,23 @@ API(API_LIGHT_SENSOR_STOP, int epic_light_sensor_stop()); /** */ API( API_FILE_OPEN, - int32_t epic_open(const char* filename, const char* modeString) + int32_t epic_file_open(const char* filename, const char* modeString) ); /** */ -API(API_FILE_CLOSE, int32_t epic_close(int32_t fd)); +API(API_FILE_CLOSE, int32_t epic_file_close(int32_t fd)); /** */ -API(API_FILE_READ, int32_t epic_read(int32_t fd, void* buf, uint32_t nbytes)); +API(API_FILE_READ, int32_t epic_file_read(int32_t fd, void* buf, uint32_t nbytes)); /** */ API( API_FILE_WRITE, - int32_t epic_write(int32_t fd, const void* buf, uint32_t nbytes) + int32_t epic_file_write(int32_t fd, const void* buf, uint32_t nbytes) ); /** */ -API(API_FILE_FLUSH, int32_t epic_flush(int32_t fd)); +API(API_FILE_FLUSH, int32_t epic_file_flush(int32_t fd)); /** */ enum epic_stat_type { @@ -510,6 +510,6 @@ typedef struct epic_stat_t { * * :return: `0` on success, negative on error */ -API(API_FILE_STAT, int32_t epic_stat(const char* path, epic_stat_t* stat)); +API(API_FILE_STAT, int32_t epic_file_stat(const char* path, epic_stat_t* stat)); #endif /* _EPICARDIUM_H */ diff --git a/epicardium/modules/fatfs.c b/epicardium/modules/fatfs.c index 922d3197a..8be070c33 100644 --- a/epicardium/modules/fatfs.c +++ b/epicardium/modules/fatfs.c @@ -203,7 +203,7 @@ int get_fat_object(int i, enum FatObjectType expected, struct FatObject **res) return 0; } -int32_t epic_open(const char *filename, const char *modeString) +int32_t epic_file_open(const char *filename, const char *modeString) { struct FatObject *o = NULL; const char *mode_s = modeString; @@ -255,7 +255,7 @@ int32_t epic_open(const char *filename, const char *modeString) return i; } -int32_t epic_close(int32_t fd) +int32_t epic_file_close(int32_t fd) { int res; struct FatObject *o; @@ -273,7 +273,7 @@ int32_t epic_close(int32_t fd) return 0; } -int32_t epic_read(int32_t fd, void *buf, uint32_t nbytes) +int32_t epic_file_read(int32_t fd, void *buf, uint32_t nbytes) { unsigned int nread = 0; @@ -292,7 +292,7 @@ int32_t epic_read(int32_t fd, void *buf, uint32_t nbytes) return nread; } -int32_t epic_write(int32_t fd, const void *buf, uint32_t nbytes) +int32_t epic_file_write(int32_t fd, const void *buf, uint32_t nbytes) { unsigned int nwritten = 0; @@ -310,7 +310,7 @@ int32_t epic_write(int32_t fd, const void *buf, uint32_t nbytes) return nwritten; } -int32_t epic_flush(int32_t fd) +int32_t epic_file_flush(int32_t fd) { int res; struct FatObject *o; @@ -326,7 +326,7 @@ int32_t epic_flush(int32_t fd) return 0; } -int32_t epic_stat(const char *filename, epic_stat_t *stat) +int32_t epic_file_stat(const char *filename, epic_stat_t *stat) { int res; FILINFO finfo; diff --git a/pycardium/modules/fat_file.c b/pycardium/modules/fat_file.c index 949e34fd2..e1d42f3ef 100644 --- a/pycardium/modules/fat_file.c +++ b/pycardium/modules/fat_file.c @@ -60,7 +60,7 @@ STATIC mp_uint_t file_obj_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) { pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); - int res = epic_read(self->fd, buf, size); + int res = epic_file_read(self->fd, buf, size); if (res < 0) { *errcode = -res; return MP_STREAM_ERROR; @@ -72,7 +72,7 @@ STATIC mp_uint_t file_obj_write(mp_obj_t self_in, const void *buf, mp_uint_t size, int *errcode) { pyb_file_obj_t *self = MP_OBJ_TO_PTR(self_in); - int res = epic_write(self->fd, buf, size); + int res = epic_file_write(self->fd, buf, size); if (res < 0) { *errcode = -res; return MP_STREAM_ERROR; @@ -96,14 +96,14 @@ file_obj_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) int res; switch (request) { case MP_STREAM_FLUSH: - res = epic_flush(self->fd); + res = epic_file_flush(self->fd); if (res < 0) { *errcode = -res; return MP_STREAM_ERROR; } return 0; case MP_STREAM_CLOSE: - res = epic_close(self->fd); + res = epic_file_close(self->fd); if (res < 0) { *errcode = -res; return MP_STREAM_ERROR; @@ -170,7 +170,7 @@ STATIC mp_obj_t file_open(const mp_obj_type_t *type, mp_arg_val_t *args) o->base.type = type; const char *fname = mp_obj_str_get_str(args[0].u_obj); - int res = epic_open(fname, modeString); + int res = epic_file_open(fname, modeString); if (res < 0) { m_del_obj(pyb_file_obj_t, o); mp_raise_OSError(-res); diff --git a/pycardium/modules/fat_reader_import.c b/pycardium/modules/fat_reader_import.c index 0bcebd339..bb35aec22 100644 --- a/pycardium/modules/fat_reader_import.c +++ b/pycardium/modules/fat_reader_import.c @@ -21,7 +21,7 @@ STATIC mp_uint_t mp_reader_epicfat_readbyte(void *data) if (reader->len == 0) { return MP_READER_EOF; } else { - int n = epic_read( + int n = epic_file_read( reader->fd, reader->buf, sizeof(reader->buf) ); if (n <= 0) { @@ -38,21 +38,21 @@ STATIC mp_uint_t mp_reader_epicfat_readbyte(void *data) STATIC void mp_reader_epicfat_close(void *data) { mp_reader_epicfat_t *reader = (mp_reader_epicfat_t *)data; - epic_close(reader->fd); + epic_file_close(reader->fd); m_del_obj(mp_reader_epicfat_t, reader); } void mp_reader_new_file(mp_reader_t *reader, const char *filename) { - int fd = epic_open(filename, "r"); + int fd = epic_file_open(filename, "r"); if (fd < 0) { mp_raise_OSError(-fd); } mp_reader_epicfat_t *rp = m_new_obj(mp_reader_epicfat_t); rp->fd = fd; - int n = epic_read(rp->fd, rp->buf, sizeof(rp->buf)); + int n = epic_file_read(rp->fd, rp->buf, sizeof(rp->buf)); if (n < 0) { - epic_close(fd); + epic_file_close(fd); } rp->len = n; rp->pos = 0; @@ -72,7 +72,7 @@ mp_import_stat_t mp_import_stat(const char *path) { struct epic_stat_t stat; - if (epic_stat(path, &stat) == 0) { + if (epic_file_stat(path, &stat) == 0) { if (stat.type == EPICSTAT_FILE) { return MP_IMPORT_STAT_FILE; } else { -- GitLab