Tramway SDK
file.h
Go to the documentation of this file.
1// TRAMWAY DRIFT AND DUNGEON EXPLORATION SIMULATOR 2022
2// All rights reserved.
3
4#ifndef TRAM_SDK_PLATFORM_FILE_H
5#define TRAM_SDK_PLATFORM_FILE_H
6
7#include <cstddef>
8
9namespace tram {
10
14};
15
17public:
18 FileReader (const char* path, FileSource source = SOURCE_ANY);
19 ~FileReader ();
20
21 bool is_open();
22
23 const char* contents = nullptr;
24 size_t length = 0;
25};
26
28public:
29 FileWriter (const char* path, FileSource source = SOURCE_ANY);
30 ~FileWriter ();
31
32 bool is_open();
33 void write (const char* data, size_t length);
34
35private:
36 void* file_handle = nullptr;
37};
38
39}
40
41#endif // PLATFORM_FILE_H
Definition: file.h:16
size_t length
Definition: file.h:24
bool is_open()
Checks if file was loaded into memory.
Definition: file.cpp:56
~FileReader()
Deletes the loaded file from memory.
Definition: file.cpp:48
FileReader(const char *path, FileSource source=SOURCE_ANY)
Loads a file into memory.
Definition: file.cpp:16
const char * contents
Definition: file.h:23
Definition: file.h:27
FileWriter(const char *path, FileSource source=SOURCE_ANY)
Opens a file for writing.
Definition: file.cpp:65
bool is_open()
Checks if a file was opened for writing.
Definition: file.cpp:94
void write(const char *data, size_t length)
Writes to a file.
Definition: file.cpp:89
~FileWriter()
Closes the file for writing.
Definition: file.cpp:77
Definition: api.h:9
FileSource
Definition: file.h:11
@ SOURCE_DISK
Definition: file.h:13
@ SOURCE_ANY
Definition: file.h:12