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

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

File I/O class - initial coding, not tested at all!

File size: 2.2 KB
Line 
1/* $Id: kFile.h,v 1.1 2000-05-23 18:23:05 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();
41 BOOL position();
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);
50 BOOL readAt(void *pvBuffer, long cbBuffer, long off);
51
52 BOOL write(void *pvBuffer, long cbBuffer);
53 BOOL writeAt(void *pvBuffer, long cbBuffer, long off);
54
55 /** @cat File seek methods */
56 BOOL move(long off);
57 BOOL set(long off);
58 BOOL end();
59 BOOL start();
60
61 /** @cat Query methods */
62 LONG getSize();
63 BOOL isEOF();
64
65 /** @cat Error handling */
66 BOOL setThrowOnErrors();
67 BOOL setFailOnErrors();
68 int getLastError();
69};
70
71#endif
72
Note: See TracBrowser for help on using the repository browser.