Dreambox C/C++ SDK v1.0.0
C/C++ SDK for creating Dreambox games
Loading...
Searching...
No Matches
db_io.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5#ifdef __cplusplus
6extern "C"
7{
8#endif
9
10#define IO_WHENCE_BEGIN 0
11#define IO_WHENCE_CURRENT 1
12#define IO_WHENCE_END 2
13
14#define IO_FILEMODE_READ 0
15#define IO_FILEMODE_WRITE 1
16
18typedef struct
19{
21 char name[128];
22
24 uint64_t created;
25
27 uint64_t modified;
28
30 uint32_t size;
31
33 uint32_t isDirectory;
34} IODIRENT;
35
37typedef void IODIR;
38
40typedef void IOFILE;
41
45extern uint8_t fs_deviceExists(const char *device);
46
49extern void fs_deviceEject(const char *device);
50
54extern uint8_t fs_fileExists(const char *filepath);
55
60extern IOFILE *fs_open(const char *filepath, uint32_t mode);
61
68extern IOFILE *fs_allocMemoryCard(const char *filename, const void *icon, const uint16_t *iconPalette, uint32_t numBlocks);
69
75extern uint32_t fs_read(IOFILE *filehandle, void *buffer, uint32_t readLen);
76
82extern uint32_t fs_write(IOFILE *filehandle, const void *buffer, uint32_t readLen);
83
89extern uint32_t fs_seek(IOFILE *filehandle, int32_t position, uint32_t whence);
90
94extern uint32_t fs_tell(IOFILE *filehandle);
95
99extern uint8_t fs_eof(IOFILE *filehandle);
100
103extern void fs_close(IOFILE *filehandle);
104
108extern IODIR *fs_openDir(const char *path);
109
113extern IODIRENT *fs_readDir(IODIR *dirHandle);
114
117extern void fs_rewindDir(IODIR *dirHandle);
118
121extern void fs_closeDir(IODIR *dirHandle);
122
123#ifdef __cplusplus
124}
125#endif
void fs_close(IOFILE *filehandle)
Close a previously opened file stream.
void fs_closeDir(IODIR *dirHandle)
Close open directory.
IODIRENT * fs_readDir(IODIR *dirHandle)
Reads the next directory entry from the open directory.
uint32_t fs_seek(IOFILE *filehandle, int32_t position, uint32_t whence)
Seek to a position within the open file stream.
uint8_t fs_eof(IOFILE *filehandle)
Retrieve whether the given file stream's position is at its end.
IOFILE * fs_allocMemoryCard(const char *filename, const void *icon, const uint16_t *iconPalette, uint32_t numBlocks)
Allocate a new file on the memory card.
IODIR * fs_openDir(const char *path)
Open a directory.
uint8_t fs_deviceExists(const char *device)
Check if the given storage device is present.
void fs_rewindDir(IODIR *dirHandle)
Rewind open directory to the beginning of the listing.
uint32_t fs_read(IOFILE *filehandle, void *buffer, uint32_t readLen)
Read data from an open file stream.
uint32_t fs_tell(IOFILE *filehandle)
Retrieve the current position within the open file stream.
void IODIR
Opaque handle to an open directory.
Definition: db_io.h:37
void IOFILE
Opaque handle to an open file descriptor.
Definition: db_io.h:40
uint8_t fs_fileExists(const char *filepath)
Check if the file exists.
void fs_deviceEject(const char *device)
Eject the given storage device, if it supports it.
uint32_t fs_write(IOFILE *filehandle, const void *buffer, uint32_t readLen)
Write to an open file stream.
IOFILE * fs_open(const char *filepath, uint32_t mode)
Open a file for reading.
Directory entry detailing information about a file or directory.
Definition: db_io.h:19
uint64_t created
A timestamp representing the time this file or directory was created.
Definition: db_io.h:24
uint64_t modified
A timestamp representing the time this file or directory was last modified.
Definition: db_io.h:27
uint32_t isDirectory
True if this is a directory, false otherwise.
Definition: db_io.h:33
uint32_t size
The size of this file in bytes (0 if this is a directory)
Definition: db_io.h:30