Open Font Render 1.2
Loading...
Searching...
No Matches
VisualStudio_Preset.h
Go to the documentation of this file.
1// -------------------------------------------------------
2// VisualStudio_Preset.h
3//
4// Copyright (c) 2024 takkaO
5//
6// If you use, modify, or redistribute this file independently
7// of the original repository, this program is licensed under
8// the MIT License.
9//
10// If you use, modify or redistribute this file as part of
11// the original repository, please follow the repository's license.
12//
13// -------------------------------------------------------
14
15#ifndef OFR_VISUAL_STUDIO_PRESET_H
16#define OFR_VISUAL_STUDIO_PRESET_H
17
18#include <list>
19#include <stdio.h>
20#include <stdlib.h>
21
22std::list<FILE *> ofr_file_list; // For multiple file loading
23
24FT_FILE *OFR_fopen(const char *filename, const char *mode) {
25 FILE *f = fopen(filename, mode);
26 ofr_file_list.push_back(f);
27 return ofr_file_list.back();
28}
29
30void OFR_fclose(FT_FILE *stream) {
31 if (stream != nullptr) {
32 fclose((FILE *)stream);
33 }
34}
35
36size_t OFR_fread(void *ptr, size_t size, size_t nmemb, FT_FILE *stream) {
37 if (stream != nullptr) {
38 return fread((uint8_t *)ptr, size, nmemb, (FILE *)stream);
39 }
40 return 0;
41}
42
43int OFR_fseek(FT_FILE *stream, long int offset, int whence) {
44 if (stream != nullptr) {
45 return fseek((FILE *)stream, offset, whence);
46 }
47 return -1;
48}
49
50long int OFR_ftell(FT_FILE *stream) {
51 if (stream != nullptr) {
52 return ftell((FILE *)stream);
53 }
54 return -1L;
55}
56
57#endif /* OFR_VISUAL_STUDIO_PRESET_H */
#define FT_FILE
Definition: FileSupport.h:16
std::list< FILE * > ofr_file_list
Definition: VisualStudio_Preset.h:22
int OFR_fseek(FT_FILE *stream, long int offset, int whence)
Moves the cursor to the specified position.
Definition: VisualStudio_Preset.h:43
long int OFR_ftell(FT_FILE *stream)
Get file cursor position.
Definition: VisualStudio_Preset.h:50
size_t OFR_fread(void *ptr, size_t size, size_t nmemb, FT_FILE *stream)
Read data from a file and store it in a buffer.
Definition: VisualStudio_Preset.h:36
FT_FILE * OFR_fopen(const char *filename, const char *mode)
Open file and get file pointer.
Definition: VisualStudio_Preset.h:24
void OFR_fclose(FT_FILE *stream)
Close file.
Definition: VisualStudio_Preset.h:30