Open Font Render 1.2
Loading...
Searching...
No Matches
FileSupport.h
Go to the documentation of this file.
1// -------------------------------------------------------
2// FileSupport.h
3//
4// Copyright (c) 2021 takkaO
5//
6// If you use, modify or redistribute this file as part of
7// the original repository, please follow the repository's license.
8//
9// -------------------------------------------------------
10
11#ifndef FILE_SUPPORT_H
12#define FILE_SUPPORT_H
13
14#include <cstddef>
15
16#define FT_FILE void
17#define ft_fclose OFR_fclose
18#define ft_fopen OFR_fopen
19#define ft_fread OFR_fread
20#define ft_fseek OFR_fseek
21#define ft_ftell OFR_ftell
22
23#if defined(_MSC_VER) // Support for VisualStudio
24
25extern "C" {
26 void OFR_fclose(FT_FILE *stream);
27 FT_FILE *OFR_fopen(const char *filename, const char *mode);
28 size_t OFR_fread(void *ptr, size_t size, size_t nmemb, FT_FILE *stream);
29 int OFR_fseek(FT_FILE *stream, long int offset, int whence);
30 long int OFR_ftell(FT_FILE *stream);
31
32 void _default_OFR_fclose(FT_FILE *stream);
33 FT_FILE *_default_OFR_fopen(const char *filename, const char *mode);
34 size_t _default_OFR_fread(void *ptr, size_t size, size_t nmemb, FT_FILE *stream);
35 int _default_OFR_fseek(FT_FILE *stream, long int offset, int whence);
36 long int _default_OFR_ftell(FT_FILE *stream);
37}
38
39 #pragma comment(linker, "/alternatename:OFR_fclose=_default_OFR_fclose")
40 #pragma comment(linker, "/alternatename:OFR_fopen=_default_OFR_fopen")
41 #pragma comment(linker, "/alternatename:OFR_fread=_default_OFR_fread")
42 #pragma comment(linker, "/alternatename:OFR_fseek=_default_OFR_fseek")
43 #pragma comment(linker, "/alternatename:OFR_ftell=_default_OFR_ftell")
44
45#else
46
47void OFR_fclose(FT_FILE *stream);
48FT_FILE *OFR_fopen(const char *filename, const char *mode);
49size_t OFR_fread(void *ptr, size_t size, size_t nmemb, FT_FILE *stream);
50int OFR_fseek(FT_FILE *stream, long int offset, int whence);
51long int OFR_ftell(FT_FILE *stream);
52
53#endif
54
55#ifdef CONFIG_SPIRAM_SUPPORT
56 #define ft_scalloc ps_calloc
57 #define ft_smalloc ps_malloc
58 #define ft_srealloc ps_realloc
59#else
60 #define ft_scalloc calloc
61 #define ft_smalloc malloc
62 #define ft_srealloc realloc
63#endif
64
65#endif
#define FT_FILE
Definition: FileSupport.h:16
int OFR_fseek(FT_FILE *stream, long int offset, int whence)
Moves the cursor to the specified position.
Definition: FileSupport.cpp:120
long int OFR_ftell(FT_FILE *stream)
Get file cursor position.
Definition: FileSupport.cpp:131
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: FileSupport.cpp:107
FT_FILE * OFR_fopen(const char *filename, const char *mode)
Open file and get file pointer.
Definition: FileSupport.cpp:93
void OFR_fclose(FT_FILE *stream)
Close file.
Definition: FileSupport.cpp:82