home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
CMDS
/
mtools_3.6.src.lzh
/
MTOOLS_3.6
/
file_read.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-11-12
|
630b
|
38 lines
#include "sysincludes.h"
#include "msdos.h"
#include "mtools.h"
#include "file.h"
/*
* Read the clusters given the beginning FAT entry. Returns 0 on success.
*/
int file_read(FILE *fp, Stream_t *Source, int textmode, int stripmode)
{
char buffer[16384];
int pos;
int ret;
if (!Source){
fprintf(stderr,"Couldn't open source file\n");
return -1;
}
pos = 0;
while(1){
ret = Source->Class->read(Source, buffer, pos, 16384);
if (ret < 0 ){
perror("file read");
return -1;
}
if ( ret == 0)
break;
if(!fwrite(buffer, 1, ret, fp)){
perror("write");
return -1;
}
pos += ret;
}
return 0;
}