made a bit more robust

This commit is contained in:
ceriel 1989-06-30 14:46:27 +00:00
parent 7d131a2cd5
commit 46b57440a0
4 changed files with 8 additions and 3 deletions

View file

@ -9,7 +9,9 @@
sys_close(fp)
register File *fp;
{
fp->o_flags = 0;
close(fp->o_fd);
fp->o_fd = -1;
if (fp) {
fp->o_flags = 0;
close(fp->o_fd);
fp->o_fd = -1;
}
}

View file

@ -12,5 +12,6 @@ sys_read(fp, bufptr, bufsiz, pnbytes)
char *bufptr;
int bufsiz, *pnbytes;
{
if (! fp) return 0;
return (*pnbytes = read(fp->o_fd, bufptr, bufsiz)) >= 0;
}

View file

@ -14,5 +14,6 @@ sys_seek(fp, off, whence, poff)
long off;
long *poff;
{
if (! fp) return 0;
return (*poff = lseek(fp->o_fd, off, whence)) >= 0;
}

View file

@ -12,5 +12,6 @@ sys_write(fp, bufptr, nbytes)
char *bufptr;
int nbytes;
{
if (! fp) return 0;
return write(fp->o_fd, bufptr, nbytes) == nbytes;
}