int _rename_r(struct _reent *r, const char *from, const char *to) { int res = SPIFFS_rename(&fs, get_fixed_filename(from), get_fixed_filename(to)); (void) r; set_errno(res); return res; }
int _unlink_r(struct _reent *r, const char *filename) { int res = SPIFFS_remove(&fs, get_fixed_filename(filename)); (void) r; set_errno(res); return res; }
int _rename_r(struct _reent *r, const char *from, const char *to) { /* * POSIX rename requires that in case "to" exists, it be atomically replaced * with "from". The atomic part we can't do, but at least we can do replace. */ int res; { spiffs_stat ss; res = SPIFFS_stat(&fs, (char *) to, &ss); if (res == 0) { SPIFFS_remove(&fs, (char *) to); } } res = SPIFFS_rename(&fs, get_fixed_filename(from), get_fixed_filename(to)); (void) r; set_errno(res); return res; }
int _open_r(struct _reent *r, const char *filename, int flags, int mode) { spiffs_mode sm = 0; int res; int rw = (flags & 3); (void) r; (void) mode; if (rw == O_RDONLY || rw == O_RDWR) sm |= SPIFFS_RDONLY; if (rw == O_WRONLY || rw == O_RDWR) sm |= SPIFFS_WRONLY | SPIFFS_CREAT; if (flags & O_CREAT) sm |= SPIFFS_CREAT; if (flags & O_TRUNC) sm |= SPIFFS_TRUNC; if (flags & O_APPEND) sm |= SPIFFS_APPEND | SPIFFS_CREAT; /* Supported in newer versions of SPIFFS. */ /* if (flags && O_EXCL) sm |= SPIFFS_EXCL; */ /* if (flags && O_DIRECT) sm |= SPIFFS_DIRECT; */ res = SPIFFS_open(&fs, get_fixed_filename(filename), sm, 0); if (res >= 0) { res += NUM_SYS_FD; } set_errno(res); return res; }