int fdclose(FILE *fp, int *fdp) { int r, err; if (fdp != NULL) *fdp = -1; if (fp->_flags == 0) { /* not open! */ errno = EBADF; return (EOF); } FLOCKFILE(fp); r = 0; if (fp->_close != __sclose) { r = EOF; errno = EOPNOTSUPP; } else if (fp->_file < 0) { r = EOF; errno = EBADF; } if (r == EOF) { err = errno; (void)cleanfile(fp, true); errno = err; } else { if (fdp != NULL) *fdp = fp->_file; r = cleanfile(fp, false); } FUNLOCKFILE(fp); return (r); }
ustring shell_clean_filename(const ustring & filename) // Replace characters like ' and / occur in the filename with _. { ustring cleanfile(filename); replace_text(cleanfile, "'", "_"); replace_text(cleanfile, "/", "_"); return cleanfile; }
int fclose(FILE *fp) { int r; if (fp->_flags == 0) { /* not open! */ errno = EBADF; return (EOF); } FLOCKFILE(fp); r = cleanfile(fp, true); FUNLOCKFILE(fp); return (r); }