1 #if !defined(__xiofile_h)
7 class DLL_EXP CxIOFile : public CxFile
10 CxIOFile(FILE* fp = NULL)
13 m_bCloseFile = (bool)(fp==0);
20 //////////////////////////////////////////////////////////
21 bool Open(LPCTSTR filename, LPCTSTR mode)
23 if (m_fp) return false; // Can't re-open without closing first
25 m_fp = _tfopen(filename, mode);
26 if (!m_fp) return false;
32 //////////////////////////////////////////////////////////
36 if ( (m_fp) && (m_bCloseFile) ){
40 return (bool)(iErr==0);
42 //////////////////////////////////////////////////////////
43 virtual size_t Read(void *buffer, size_t size, size_t count)
46 return fread(buffer, size, count, m_fp);
48 //////////////////////////////////////////////////////////
49 virtual size_t Write(const void *buffer, size_t size, size_t count)
52 return fwrite(buffer, size, count, m_fp);
54 //////////////////////////////////////////////////////////
55 virtual bool Seek(long offset, int origin)
57 if (!m_fp) return false;
58 return (bool)(fseek(m_fp, offset, origin) == 0);
60 //////////////////////////////////////////////////////////
66 //////////////////////////////////////////////////////////
72 fseek(m_fp, 0, SEEK_END);
74 fseek(m_fp, pos,SEEK_SET);
77 //////////////////////////////////////////////////////////
80 if (!m_fp) return false;
81 return (bool)(fflush(m_fp) == 0);
83 //////////////////////////////////////////////////////////
86 if (!m_fp) return true;
87 return (bool)(feof(m_fp) != 0);
89 //////////////////////////////////////////////////////////
95 //////////////////////////////////////////////////////////
96 virtual bool PutC(unsigned char c)
98 if (!m_fp) return false;
99 return (bool)(fputc(c, m_fp) == c);
101 //////////////////////////////////////////////////////////
104 if (!m_fp) return EOF;
107 //////////////////////////////////////////////////////////
108 virtual char * GetS(char *string, int n)
110 if (!m_fp) return NULL;
111 return fgets(string,n,m_fp);
113 //////////////////////////////////////////////////////////
114 virtual long Scanf(const char *format, void* output)
116 if (!m_fp) return EOF;
117 return fscanf(m_fp, format, output);
119 //////////////////////////////////////////////////////////