summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/ioprocs.h
blob: 1244873f14c9ff73cf018a10efd2c891a988d8ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// license:BSD-3-Clause
// copyright-holders:Nathan Woods
/*********************************************************************

    ioprocs.h

    File IO abstraction layer

*********************************************************************/
#ifndef MAME_FORMATS_IOPROCS_H
#define MAME_FORMATS_IOPROCS_H

#pragma once

#include <cstdint>
#include <cstdlib>



/***************************************************************************

    Type definitions

***************************************************************************/

struct io_procs
{
	void (*closeproc)(void *file) = nullptr;
	int (*seekproc)(void *file, int64_t offset, int whence) = nullptr;
	size_t (*readproc)(void *file, void *buffer, size_t length) = nullptr;
	size_t (*writeproc)(void *file, const void *buffer, size_t length) = nullptr;
	uint64_t (*filesizeproc)(void *file) = nullptr;
};



struct io_generic
{
	const struct io_procs *procs = nullptr;
	void *file = nullptr;
	uint8_t filler = 0;
};


/***************************************************************************

    Globals

***************************************************************************/

extern const io_procs stdio_ioprocs;
extern const io_procs stdio_ioprocs_noclose;
extern const io_procs corefile_ioprocs;
extern const io_procs corefile_ioprocs_noclose;



/***************************************************************************

    Prototypes

***************************************************************************/

void io_generic_close(struct io_generic *genio);
void io_generic_read(struct io_generic *genio, void *buffer, uint64_t offset, size_t length);
void io_generic_write(struct io_generic *genio, const void *buffer, uint64_t offset, size_t length);
void io_generic_write_filler(struct io_generic *genio, uint8_t filler, uint64_t offset, size_t length);
uint64_t io_generic_size(struct io_generic *genio);

#endif // MAME_FORMATS_IOPROCS_H