int __sclose (void* cookie) { FILE *fp = (FILE *) cookie; return _close_r (fp->_data, fp->_file); }
FILE * _tmpfile_r (struct _reent *ptr) { FILE *fp; int e; char *f; char buf[L_tmpnam]; int fd; do { if ((f = _tmpnam_r (ptr, buf)) == NULL) return NULL; fd = _open_r (ptr, f, O_RDWR | O_CREAT | O_EXCL | O_BINARY, S_IRUSR | S_IWUSR); } while (fd < 0 && __errno_r(ptr) == EEXIST); if (fd < 0) return NULL; fp = _fdopen_r (ptr, fd, "wb+"); e = __errno_r(ptr); if (!fp) _close_r (ptr, fd); (void) _remove_r (ptr, f); __errno_r(ptr) = e; return fp; }
void _ioatexit(void) { int i; WCETRACE(WCE_IO, "_ioatexit: STARTED"); for (i = 0; i < MAXFDS; i++) { if (_fdtab[i].fd != -1) { if (_fdtab[i].type == IO_FILE_TYPE_FIFO) { _close_r(NULL, i); } } } }
int _stat_r(struct _reent *r, const char *path, struct stat *s) { int ret, fd; /* * spiffs has no directories, simulating statting root directory; * required for mg_send_http_file. */ if ((strcmp(path, "./") == 0) || (strcmp(path, "/") == 0)) { memset(s, 0, sizeof(*s)); s->st_mode = S_IFDIR; return 0; } fd = _open_r(NULL, path, O_RDONLY, 0); if (fd == -1) return -1; ret = _fstat_r(NULL, fd, s); _close_r(NULL, fd); return ret; }
int devo_fclose(FILE *fp) { long fd = (long)fp - 1; return _close_r(NULL, fd); }
int close (int fd) { return _close_r (_REENT, fd); }
int close( int file ) { return _close_r( _REENT, file ); }