Debian Codegraph @

terps/tads/tads3/vmfile.cpp

raw symbols SCIP
1 #ifdef RCSID
2 static char RCSid[] =
3 "$Header: d:/cvsroot/tads/tads3/VMFILE.CPP,v 1.2 1999/05/17 02:52:28 MJRoberts Exp $";
4 #endif
5
6 /*
7 * Copyright (c) 1998, 2002 Michael J. Roberts. All Rights Reserved.
8 *
9 * Please see the accompanying license file, LICENSE.TXT, for information
10 * on using and copying this software.
11 */
12 /*
13 Name
14 vmfile.cpp - VM file implementation
15 Function
16
17 Notes
18
19 Modified
20 10/28/98 MJRoberts - Creation
21 */
22
23 #include "t3std.h"
24 #include "vmfile.h"
25 #include "vmerr.h"
26 #include "vmdatasrc.h"
27
28
29 /*
30 * delete the file object
31 */
32 CVmFile::~CVmFile()
33 {
34 /* if we still have an underlying OS file, close it */
35 if (fp_ != 0)
36 osfcls(fp_);
37 }
38
39 /*
40 * open for reading
41 */
42 void CVmFile::open_read(const char *fname, os_filetype_t typ)
43 {
44 /* try opening the underlying OS file for binary reading */
45 fp_ = osfoprb(fname, typ);
46
47 /* if that failed, throw an error */
48 if (fp_ == 0)
49 err_throw(VMERR_FILE_NOT_FOUND);
50 }
51
52 /*
53 * open for writing
54 */
55 void CVmFile::open_write(const char *fname, os_filetype_t typ)
56 {
57 /* try opening the underlying OS file for binary writing */
58 fp_ = osfopwb(fname, typ);
59
60 /* if that failed, throw an error */
61 if (fp_ == 0)
62 err_throw(VMERR_CREATE_FILE);
63 }