Example #1
0
int
__sclose (void* cookie)
{
  FILE *fp = (FILE *) cookie;

  return _close_r (fp->_data, fp->_file);
}
Example #2
0
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;
}
Example #3
0
File: io.c Project: mmcx/cegcc
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);
   	  }
    }
  }
}
Example #4
0
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;
}
Example #5
0
int devo_fclose(FILE *fp)
{
    long fd = (long)fp - 1;
    return _close_r(NULL, fd);
}
Example #6
0
int
close (int fd)
{
  return _close_r (_REENT, fd);
}
Example #7
0
int close( int file )
{
    return _close_r( _REENT, file );
}