1 /* 2 This product contains certain software code or other information 3 ("AT&T Software") proprietary to AT&T Corp. ("AT&T"). The AT&T 4 Software is provided to you "AS IS". YOU ASSUME TOTAL RESPONSIBILITY 5 AND RISK FOR USE OF THE AT&T SOFTWARE. AT&T DOES NOT MAKE, AND 6 EXPRESSLY DISCLAIMS, ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND 7 WHATSOEVER, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 8 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, WARRANTIES OF 9 TITLE OR NON-INFRINGEMENT OF ANY INTELLECTUAL PROPERTY RIGHTS, ANY 10 WARRANTIES ARISING BY USAGE OF TRADE, COURSE OF DEALING OR COURSE OF 11 PERFORMANCE, OR ANY WARRANTY THAT THE AT&T SOFTWARE IS "ERROR FREE" OR 12 WILL MEET YOUR REQUIREMENTS. 13 14 Unless you accept a license to use the AT&T Software, you shall not 15 reverse compile, disassemble or otherwise reverse engineer this 16 product to ascertain the source code for any AT&T Software. 17 18 (c) AT&T Corp. All rights reserved. AT&T is a registered trademark of AT&T Corp. 19 20 *********************************************************************** 21 22 History: 23 24 24/11/99 - initial release by Hartmut Liefke, liefke@seas.upenn.edu 25 Dan Suciu, suciu@research.att.com 26 */ 27 28 //************************************************************************** 29 //************************************************************************** 30 31 // This module contains the main functions for reading a file 32 33 #pragma once 34 35 #include <stdio.h> 36 #include <stdlib.h> 37 38 #include "Error.hpp" 39 40 41 class CFile 42 { 43 FILE *file; // The file handle 44 char *savefilename; // We save the file name 45 46 protected: 47 unsigned filepos; // Current file position 48 char iseof; // Did we reach the end of the file? 49 50 51 public: 52 CFile(); 53 54 /* extra method because Input no longer is a subclass */ 55 char IsEof(); 56 57 virtual char OpenFile(char *filename); 58 // Opens a file (if filename==NULL, then the standard input is opened) 59 // Returns 1, if okay, otherwise 0 60 61 unsigned GetFilePos(); 62 // Returns the current position in the file 63 64 virtual unsigned ReadBlock(char *dest,unsigned bytecount); 65 // Reads a data block into the memory at 'dest'. The maximum size is 'bytecount' 66 // The function returns the number of bytes read or -1, if something fails 67 // If the result is smaller than bytecount, the end of the file has been reached 68 // and flag eof is set to 1. 69 70 virtual void CloseFile(); 71 // Closes the file 72 }; 73