source: trunk/tools/common/kFile.h@ 3830

Last change on this file since 3830 was 3629, checked in by bird, 25 years ago

Added printf method (works for upto 64KB of data).

File size: 2.4 KB
Line 
1/* $Id: kFile.h,v 1.3 2000-05-29 19:45:58 bird Exp $
2 *
3 * kFile - Simple (for the time being) file class.
4 *
5 * Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10
11#ifndef _kFile_h_
12#define _kFile_h_
13
14
15
16/**
17 * Simple file class.
18 * It uses a lazy algorithm for chaning the file position.
19 * It is extenable to do buffered reading too.
20 * @author knut st. osmundsen
21 */
22class kFile
23{
24protected:
25 /** @cat Main datamembers */
26 HFILE hFile; /* Pointer to stdio filehandle */
27 BOOL fReadOnly; /* True if readonly access, False is readwrite. */
28 int rc; /* Last error (return code). */
29 FILESTATUS4 filestatus; /* Filestatus data. */
30 BOOL fStatusClean; /* True if filestatus is clean. False is not clean */
31 BOOL fThrowErrors; /* When true we'll throw the rc on errors, else return FALSE. */
32
33 /** @cat Position datamembers */
34 unsigned long offVirtual; /* Virtual file position - lazy set. */
35 unsigned long offReal; /* Real file position. */
36
37 /** @cat Buffering datamembers */
38
39 /** @cat internal methods for maintaing internal structures. */
40 BOOL refreshFileStatus() throw(int);
41 BOOL position() throw(int);
42
43public:
44 /** @cat constructor */
45 kFile(const char *pszFilename, BOOL fReadOnly = TRUE) throw(int);
46 ~kFile();
47
48 /** @cat File I/O methods */
49 BOOL read(void *pvBuffer, long cbBuffer) throw(int);
50 BOOL readAt(void *pvBuffer, long cbBuffer, long off) throw(int);
51
52 BOOL write(void *pvBuffer, long cbBuffer) throw(int);
53 BOOL writeAt(void *pvBuffer, long cbBuffer, long off) throw(int);
54
55 int printf(const char *pszFormat, ...) throw (int);
56
57 /** @cat File seek methods */
58 BOOL move(long off) throw(int);
59 BOOL set(long off) throw(int);
60 BOOL end() throw(int);
61 BOOL start();
62
63 /** @cat Query methods */
64 long getSize() throw(int);
65 long getPos() const throw(int);
66 BOOL isEOF() throw(int);
67
68 /** @cat Error handling */
69 BOOL setThrowOnErrors();
70 BOOL setFailOnErrors();
71 int getLastError() const;
72};
73
74#endif
75
Note: See TracBrowser for help on using the repository browser.