From 7e11b462e60a42a6378a4dfc837953bf07709888 Mon Sep 17 00:00:00 2001 From: Tobias Badertscher Date: Mon, 2 Mar 2015 13:46:23 +0100 Subject: [PATCH] Changed name in spiffs from "errno" to "err_code" due to conflicts compiling in mingw. Added #defines toe spiffs.h in C++ code. --- src/spiffs.h | 12 +++++++++--- src/spiffs_hydrogen.c | 14 +++++++------- src/spiffs_nucleus.h | 6 +++--- src/test/test_spiffs.c | 2 +- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/spiffs.h b/src/spiffs.h index 17f3d77..f42c76a 100644 --- a/src/spiffs.h +++ b/src/spiffs.h @@ -9,6 +9,9 @@ #ifndef SPIFFS_H_ #define SPIFFS_H_ +#if defined(__cplusplus) +extern "C" { +#endif #include "spiffs_config.h" @@ -181,7 +184,7 @@ typedef struct { u32_t fd_count; // last error - s32_t errno; + s32_t err_code; // current number of free blocks u32_t free_blocks; @@ -375,9 +378,9 @@ void SPIFFS_close(spiffs *fs, spiffs_file fh); * Renames a file * @param fs the file system struct * @param old path of file to rename - * @param new new path of file + * @param newPath new path of file */ -s32_t SPIFFS_rename(spiffs *fs, char *old, char *new); +s32_t SPIFFS_rename(spiffs *fs, char *old, char *newPath); /** * Returns last error of last file operation. @@ -442,5 +445,8 @@ u32_t SPIFFS_buffer_bytes_for_cache(spiffs *fs, u32_t num_pages); #if SPIFFS_CHACHE #endif +#if defined(__cplusplus) +} +#endif #endif /* SPIFFS_H_ */ diff --git a/src/spiffs_hydrogen.c b/src/spiffs_hydrogen.c index 760d776..f6a3a1f 100644 --- a/src/spiffs_hydrogen.c +++ b/src/spiffs_hydrogen.c @@ -103,7 +103,7 @@ void SPIFFS_unmount(spiffs *fs) { } s32_t SPIFFS_errno(spiffs *fs) { - return fs->errno; + return fs->err_code; } s32_t SPIFFS_creat(spiffs *fs, char *path, spiffs_mode mode) { @@ -580,7 +580,7 @@ static s32_t spiffs_fflush_cache(spiffs *fs, spiffs_file fh) { spiffs_get_cache_page(fs, spiffs_get_cache(fs), fd->cache_page->ix), fd->cache_page->offset, fd->cache_page->size); if (res < SPIFFS_OK) { - fs->errno = res; + fs->err_code = res; } spiffs_cache_fd_release(fs, fd->cache_page); } @@ -605,7 +605,7 @@ s32_t SPIFFS_fflush(spiffs *fs, spiffs_file fh) { void SPIFFS_close(spiffs *fs, spiffs_file fh) { if (!SPIFFS_CHECK_MOUNT(fs)) { - fs->errno = SPIFFS_ERR_NOT_MOUNTED; + fs->err_code = SPIFFS_ERR_NOT_MOUNTED; return; } SPIFFS_LOCK(fs); @@ -661,7 +661,7 @@ s32_t SPIFFS_rename(spiffs *fs, char *old, char *new) { spiffs_DIR *SPIFFS_opendir(spiffs *fs, char *name, spiffs_DIR *d) { (void)name; if (!SPIFFS_CHECK_MOUNT(fs)) { - fs->errno = SPIFFS_ERR_NOT_MOUNTED; + fs->err_code = SPIFFS_ERR_NOT_MOUNTED; return 0; } d->fs = fs; @@ -707,7 +707,7 @@ static s32_t spiffs_read_dir_v( struct spiffs_dirent *SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) { if (!SPIFFS_CHECK_MOUNT(d->fs)) { - d->fs->errno = SPIFFS_ERR_NOT_MOUNTED; + d->fs->err_code = SPIFFS_ERR_NOT_MOUNTED; return 0; } SPIFFS_LOCK(fs); @@ -732,7 +732,7 @@ struct spiffs_dirent *SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) { d->entry = entry + 1; ret = e; } else { - d->fs->errno = res; + d->fs->err_code = res; } SPIFFS_UNLOCK(fs); return ret; @@ -821,7 +821,7 @@ s32_t SPIFFS_vis(spiffs *fs) { } // per block spiffs_printf("era_cnt_max: %i\n", fs->max_erase_count); - spiffs_printf("last_errno: %i\n", fs->errno); + spiffs_printf("last_errno: %i\n", fs->err_code); spiffs_printf("blocks: %i\n", fs->block_count); spiffs_printf("free_blocks: %i\n", fs->free_blocks); spiffs_printf("page_alloc: %i\n", fs->stats_p_allocated); diff --git a/src/spiffs_nucleus.h b/src/spiffs_nucleus.h index fb1b3e4..01a1f05 100644 --- a/src/spiffs_nucleus.h +++ b/src/spiffs_nucleus.h @@ -247,19 +247,19 @@ #define SPIFFS_API_CHECK_MOUNT(fs) \ if (!SPIFFS_CHECK_MOUNT((fs))) { \ - (fs)->errno = SPIFFS_ERR_NOT_MOUNTED; \ + (fs)->err_code = SPIFFS_ERR_NOT_MOUNTED; \ return -1; \ } #define SPIFFS_API_CHECK_RES(fs, res) \ if ((res) < SPIFFS_OK) { \ - (fs)->errno = (res); \ + (fs)->err_code = (res); \ return -1; \ } #define SPIFFS_API_CHECK_RES_UNLOCK(fs, res) \ if ((res) < SPIFFS_OK) { \ - (fs)->errno = (res); \ + (fs)->err_code = (res); \ SPIFFS_UNLOCK(fs); \ return -1; \ } diff --git a/src/test/test_spiffs.c b/src/test/test_spiffs.c index bedc487..478eea2 100644 --- a/src/test/test_spiffs.c +++ b/src/test/test_spiffs.c @@ -370,7 +370,7 @@ void fs_set_validate_flashing(int i) { void real_assert(int c, const char *n, const char *file, int l) { if (c == 0) { printf("ASSERT: %s %s @ %i\n", (n ? n : ""), file, l); - printf("fs errno:%i\n", __fs.errno); + printf("fs errno:%i\n", __fs.err_code); exit(0); } }