| | 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 | |
| | 27 | |
| | 28 | /* |
| | 29 | * delete the file object |
| | 30 | */ |
| | 31 | CVmFile::~CVmFile() |
| | 32 | { |
| | 33 | /* if we still have an underlying OS file, close it */ |
| | 34 | if (fp_ != 0) |
| | 35 | osfcls(fp_); |
| | 36 | } |
| | 37 | |
| | 38 | /* |
| | 39 | * open for reading |
| | 40 | */ |
| | 41 | void CVmFile::open_read(const char *fname, os_filetype_t typ) |
| | 42 | { |
| | 43 | /* try opening the underlying OS file for binary reading */ |
| | 44 | fp_ = osfoprb(fname, typ); |
| | 45 | |
| | 46 | /* if that failed, throw an error */ |
| | 47 | if (fp_ == 0) |
| | 48 | err_throw(VMERR_FILE_NOT_FOUND); |
| | 49 | } |
| | 50 | |
| | 51 | /* |
| | 52 | * open for writing |
| | 53 | */ |
| | 54 | void CVmFile::open_write(const char *fname, os_filetype_t typ) |
| | 55 | { |
| | 56 | /* try opening the underlying OS file for binary writing */ |
| | 57 | fp_ = osfopwb(fname, typ); |
| | 58 | |
| | 59 | /* if that failed, throw an error */ |
| | 60 | if (fp_ == 0) |
| | 61 | err_throw(VMERR_CREATE_FILE); |
| | 62 | } |
| | 63 | |