ack/modules/src/system/read.c
David Given cb37502a23 Make work, mostly, on Windows --- temporary files are now created in the
right place, creat() isn't used because it doesn't work, partial file
read/writes work, etc.
2022-07-17 01:58:16 +02:00

31 lines
529 B
C

/*
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
* See the copyright notice in the ACK home directory, in the file "Copyright".
*/
/* $Id$ */
#include <unistd.h>
#include "system.h"
int sys_read(File* fp, char* bufptr, int bufsiz, int* pnbytes)
{
if (!fp)
return 0;
*pnbytes = 0;
while (bufsiz != 0)
{
int len = read(fp->o_fd, bufptr, bufsiz);
if (len < 0)
return 0;
if (len == 0)
return *pnbytes != 0;
*pnbytes += len;
bufptr += len;
bufsiz -= len;
}
return 1;
}