1 | /*
|
---|
2 | * File: xfile.h
|
---|
3 | * Purpose: General Purpose File Class
|
---|
4 | */
|
---|
5 | /*
|
---|
6 | --------------------------------------------------------------------------------
|
---|
7 |
|
---|
8 | COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
|
---|
9 |
|
---|
10 | CxFile (c) 11/May/2002 Davide Pizzolato - www.xdp.it
|
---|
11 | CxFile version 2.00 23/Aug/2002
|
---|
12 | CxFile version 2.10 16/Dec/2007
|
---|
13 |
|
---|
14 | Special thanks to Chris Shearer Cooper for new features, enhancements and bugfixes
|
---|
15 |
|
---|
16 | Covered code is provided under this license on an "as is" basis, without warranty
|
---|
17 | of any kind, either expressed or implied, including, without limitation, warranties
|
---|
18 | that the covered code is free of defects, merchantable, fit for a particular purpose
|
---|
19 | or non-infringing. The entire risk as to the quality and performance of the covered
|
---|
20 | code is with you. Should any covered code prove defective in any respect, you (not
|
---|
21 | the initial developer or any other contributor) assume the cost of any necessary
|
---|
22 | servicing, repair or correction. This disclaimer of warranty constitutes an essential
|
---|
23 | part of this license. No use of any covered code is authorized hereunder except under
|
---|
24 | this disclaimer.
|
---|
25 |
|
---|
26 | Permission is hereby granted to use, copy, modify, and distribute this
|
---|
27 | source code, or portions hereof, for any purpose, including commercial applications,
|
---|
28 | freely and without fee, subject to the following restrictions:
|
---|
29 |
|
---|
30 | 1. The origin of this software must not be misrepresented; you must not
|
---|
31 | claim that you wrote the original software. If you use this software
|
---|
32 | in a product, an acknowledgment in the product documentation would be
|
---|
33 | appreciated but is not required.
|
---|
34 |
|
---|
35 | 2. Altered source versions must be plainly marked as such, and must not be
|
---|
36 | misrepresented as being the original software.
|
---|
37 |
|
---|
38 | 3. This notice may not be removed or altered from any source distribution.
|
---|
39 | --------------------------------------------------------------------------------
|
---|
40 | */
|
---|
41 | #if !defined(__xfile_h)
|
---|
42 | #define __xfile_h
|
---|
43 |
|
---|
44 | #if defined (WIN32) || defined (_WIN32_WCE)
|
---|
45 | #include <windows.h>
|
---|
46 | #endif
|
---|
47 |
|
---|
48 | #include <stdio.h>
|
---|
49 | #include <stdlib.h>
|
---|
50 |
|
---|
51 | #include "ximadef.h"
|
---|
52 |
|
---|
53 | class DLL_EXP CxFile
|
---|
54 | {
|
---|
55 | public:
|
---|
56 | CxFile(void) { };
|
---|
57 | virtual ~CxFile() { };
|
---|
58 |
|
---|
59 | virtual bool Close() = 0;
|
---|
60 | virtual size_t Read(void *buffer, size_t size, size_t count) = 0;
|
---|
61 | virtual size_t Write(const void *buffer, size_t size, size_t count) = 0;
|
---|
62 | virtual bool Seek(long offset, int origin) = 0;
|
---|
63 | virtual long Tell() = 0;
|
---|
64 | virtual long Size() = 0;
|
---|
65 | virtual bool Flush() = 0;
|
---|
66 | virtual bool Eof() = 0;
|
---|
67 | virtual long Error() = 0;
|
---|
68 | virtual bool PutC(unsigned char c)
|
---|
69 | {
|
---|
70 | // Default implementation
|
---|
71 | size_t nWrote = Write(&c, 1, 1);
|
---|
72 | return (bool)(nWrote == 1);
|
---|
73 | }
|
---|
74 | virtual long GetC() = 0;
|
---|
75 | virtual char * GetS(char *string, int n) = 0;
|
---|
76 | virtual long Scanf(const char *format, void* output) = 0;
|
---|
77 | };
|
---|
78 |
|
---|
79 | #endif //__xfile_h
|
---|