cleaned up some things, fixed some mem leaks
[riven-wahrk.git] / src / File.h
blob3616d37a555aada856518e65b90df4da677d41d6
2 /*
4 * Riven-Wahrk - a reimplementation of the game Riven, by Cyan
5 * Copyright (C) 2009 Tyler Genter <tylergenter@gmail.com>
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef _FILE_H_
23 #define _FILE_H_
25 #include <string>
27 #include "Common.h"
28 #include "Mohawk.h"
30 #include "Stack.h"
32 // each file is defined by a stack (aspit, gspit), a resource type
33 // (movie, script, image, sound), and a resource id
35 class File {
37 uint8_t *data;
38 int size;
40 public:
41 File (Stack *stack, uint32_t type, int id);
42 File () {};
44 int getSize () {
45 return size;
48 // dump the file to a file on the filsystem
49 void dump (std::string path);
51 uint8_t readUChar (int addr) {
52 return *(data + addr);
55 int8_t readSChar (int addr) {
56 return *(data + addr);
59 uint16_t readUShort (int addr) {
60 return Common::swapBytes (*(uint16_t*) (data + addr));
63 int16_t readSShort (int addr) {
64 return Common::swapBytes (*(uint16_t*) (data + addr));
67 uint32_t readULong (int addr) {
68 return Common::swapBytes (*(uint32_t*) (data + addr));
71 int32_t readSLong (int addr) {
72 return Common::swapBytes (*(uint32_t*) (data + addr));
75 uint8_t *readCharArray (int addr) {
76 return data + addr;
79 uint16_t *readShortArray (int count, int addr);
80 uint32_t *readLongArray (int count, int addr);
85 #endif