#include <File.hpp>
Inheritance diagram for CFile::

Public Methods | |
| CFile () | |
| char | OpenFile (char *filename) |
| unsigned | GetFilePos () |
| unsigned | ReadBlock (char *dest, unsigned bytecount) |
| void | CloseFile () |
Protected Attributes | |
| unsigned | filepos |
| char | iseof |
|
|
Definition at line 57 of file File.hpp. 00058 {
00059 file=NULL;
00060 }
|
|
|
Definition at line 128 of file File.hpp. 00130 {
00131 if((file==NULL)||(file==stdout))
00132 return;
00133
00134 fclose(file);
00135 file=NULL;
00136 }
|
|
|
Definition at line 90 of file File.hpp. 00090 { return filepos;}
|
|
|
Reimplemented in FileParser, and Input. Definition at line 62 of file File.hpp. 00065 {
00066 if(filename==NULL)
00067 {
00068 file=stdin;
00069 #ifdef WIN32
00070 _setmode(_fileno(stdin),_O_BINARY);
00071 #endif
00072 }
00073 else
00074 {
00075 if(*filename==0) // Empty file name ?
00076 return 0;
00077
00078 file=fopen(filename,"rb");
00079
00080 if(file==NULL) // We couldn't open the file?
00081 return 0;
00082 }
00083 filepos=0;
00084 iseof=0;
00085
00086 savefilename=filename;
00087 return 1;
00088 }
|
|
||||||||||||
|
Definition at line 93 of file File.hpp. 00098 {
00099 if(iseof)
00100 return 0;
00101
00102 // let's try to reach 'bytecount' bytes
00103 unsigned bytesread=(unsigned)fread(dest,1,bytecount,file);
00104
00105 if(bytesread<bytecount)
00106 // We didn't read all of them?
00107 {
00108 if(feof(file))
00109 iseof=1;
00110 else
00111 {
00112 if(ferror(file))
00113 {
00114 char tmpstr[300];
00115 if(savefilename!=NULL)
00116 sprintf(tmpstr,"Could not read from file '%s' (Error %lu)!",savefilename,errno);
00117 else
00118 sprintf(tmpstr,"Could not read from standard input (Error %lu)!",errno);
00119 Error(tmpstr);
00120 Exit();
00121 }
00122 }
00123 }
00124 filepos+=bytesread;
00125 return bytesread;
00126 }
|
|
|
|
|
|
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001