Changed name in spiffs from "errno" to "err_code" due to conflicts compiling in mingw.

Added #defines toe spiffs.h in C++ code.
This commit is contained in:
Tobias Badertscher
2015-03-02 21:24:43 +01:00
committed by Peter Andersson
parent aab5cbf33d
commit 7e11b462e6
4 changed files with 20 additions and 14 deletions
+9 -3
View File
@@ -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_ */
+7 -7
View File
@@ -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);
+3 -3
View File
@@ -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; \
}
+1 -1
View File
@@ -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);
}
}