Call write(fileno(fp), ...) instead of fwrite for LARGE writes.

This commit is contained in:
Guido van Rossum 1991-11-12 15:42:49 +00:00
parent 19f1b8261e
commit 8aff84a100
1 changed files with 11 additions and 1 deletions

View File

@ -441,6 +441,7 @@ file_write(f, args)
object *args; object *args;
{ {
int n, n2; int n, n2;
char *s;
if (f->f_fp == NULL) { if (f->f_fp == NULL) {
err_badarg(); err_badarg();
return NULL; return NULL;
@ -451,7 +452,16 @@ file_write(f, args)
} }
f->f_softspace = 0; f->f_softspace = 0;
errno = 0; errno = 0;
n2 = fwrite(getstringvalue(args), 1, n = getstringsize(args), f->f_fp); n = getstringsize(args);
s = getstringvalue(args);
if (n > BUFSIZ) {
fflush(f->f_fp);
n2 = write(fileno(f->f_fp), s, n);
fflush(f->f_fp);
}
else {
n2 = fwrite(s, 1, n, f->f_fp);
}
if (n2 != n) { if (n2 != n) {
if (errno == 0) if (errno == 0)
errno = EIO; errno = EIO;