XenevaOS
Loading...
Searching...
No Matches
w_file.h
Go to the documentation of this file.
1//
2// Copyright(C) 1993-1996 Id Software, Inc.
3// Copyright(C) 2005-2014 Simon Howard
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// DESCRIPTION:
16// WAD I/O functions.
17//
18
19
20#ifndef __W_FILE__
21#define __W_FILE__
22
23#include <stdio.h>
24#include "doomtype.h"
25
26typedef struct _wad_file_s wad_file_t;
27
28typedef struct
29{
30 // Open a file for reading.
31
32 wad_file_t *(*OpenFile)(char *path);
33
34 // Close the specified file.
35
37
38 // Read data from the specified position in the file into the
39 // provided buffer. Returns the number of bytes read.
40
41 size_t (*Read)(wad_file_t *file, unsigned int offset,
42 void *buffer, size_t buffer_len);
43
45
47{
48 // Class of this file.
49
51
52 // If this is NULL, the file cannot be mapped into memory. If this
53 // is non-NULL, it is a pointer to the mapped file.
54
55 byte *mapped;
56
57 // Length of the file, in bytes.
58
59 unsigned int length;
60};
61
62// Open the specified file. Returns a pointer to a new wad_file_t
63// handle for the WAD file, or NULL if it could not be opened.
64
66
67// Close the specified WAD file.
68
69void W_CloseFile(wad_file_t *wad);
70
71// Read data from the specified file into the provided buffer. The
72// data is read from the specified offset from the start of the file.
73// Returns the number of bytes read.
74
75size_t W_Read(wad_file_t *wad, unsigned int offset,
76 void *buffer, size_t buffer_len);
77
78#endif /* #ifndef __W_FILE__ */
uint64_t size_t
Definition stdint.h:104
size_t size_t offset
Definition drm_bridge.h:1299
Definition w_file.h:47
byte * mapped
Definition w_file.h:55
unsigned int length
Definition w_file.h:59
wad_file_class_t * file_class
Definition w_file.h:50
Definition fs.h:142
Definition path.h:8
Definition w_file.h:29
int CloseFile(int fd)
CloseFile – closes a general file.
Definition fileserv.cpp:326
wad_file_t * W_OpenFile(char *path)
Definition w_file.c:53
void W_CloseFile(wad_file_t *wad)
Definition w_file.c:85
size_t W_Read(wad_file_t *wad, unsigned int offset, void *buffer, size_t buffer_len)
Definition w_file.c:90