1 /* 2 * File: xfile.h 3 * Purpose: General Purpose File Class 4 */ 5 /* === C R E D I T S & D I S C L A I M E R S ============== 6 * Permission is given by the author to freely redistribute and include 7 * this code in any program as long as this credit is given where due. 8 * 9 * CxFile (c) 11/May/2002 Davide Pizzolato - www.xdp.it 10 * CxFile version 2.00 23/Aug/2002 11 * See the file history.htm for the complete bugfix and news report. 12 * 13 * Special thanks to Chris Shearer Cooper for new features, enhancements and bugfixes 14 * 15 * COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY 16 * OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES 17 * THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE 18 * OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED 19 * CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT 20 * THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY 21 * SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL 22 * PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER 23 * THIS DISCLAIMER. 24 * 25 * Use at your own risk! 26 * ========================================================== 27 */ 28 #if !defined(__xfile_h) 29 #define __xfile_h 30 31 #ifdef WIN32 32 #include <windows.h> 33 #endif 34 35 #include <stdio.h> 36 #include <stdlib.h> 37 38 #include "ximadefs.h" 39 40 class DLL_EXP CxFile 41 { 42 public: CxFile(void)43 CxFile(void) { }; ~CxFile()44 virtual ~CxFile() { }; 45 46 virtual bool Close() = 0; 47 virtual size_t Read(void *buffer, size_t size, size_t count) = 0; 48 virtual size_t Write(const void *buffer, size_t size, size_t count) = 0; 49 virtual bool Seek(long offset, int origin) = 0; 50 virtual long Tell() = 0; 51 virtual long Size() = 0; 52 virtual bool Flush() = 0; 53 virtual bool Eof() = 0; 54 virtual long Error() = 0; PutC(unsigned char c)55 virtual bool PutC(unsigned char c) 56 { 57 // Default implementation 58 size_t nWrote = Write(&c, 1, 1); 59 return (bool)(nWrote == 1); 60 } 61 virtual long GetC() = 0; 62 }; 63 64 #endif //__xfile_h 65