2ff0b512 |
1 | #ifndef __CORETYPES_H__ |
2 | #define __CORETYPES_H__ |
3 | |
4 | #include <stdint.h> |
5 | #include <stdio.h> |
6 | |
7 | #ifdef USE_LIBRETRO_VFS |
8 | #include <streams/file_stream_transforms.h> |
9 | #endif |
10 | |
11 | #define ARRAY_LENGTH(x) (sizeof(x)/sizeof(x[0])) |
12 | |
13 | typedef uint64_t UINT64; |
14 | typedef uint32_t UINT32; |
15 | typedef uint16_t UINT16; |
16 | typedef uint8_t UINT8; |
17 | |
18 | typedef int64_t INT64; |
19 | typedef int32_t INT32; |
20 | typedef int16_t INT16; |
21 | typedef int8_t INT8; |
22 | |
226a5691 |
23 | #ifdef USE_LIBRETRO_VFS |
24 | #define core_file RFILE |
25 | #define core_fopen(file) rfopen(file, "rb") |
26 | #define core_fseek rfseek |
27 | #define core_ftell rftell |
28 | #define core_fread(fc, buff, len) rfread(buff, 1, len, fc) |
29 | #define core_fclose rfclose |
a9821f07 |
30 | #else |
226a5691 |
31 | #define core_file FILE |
2ff0b512 |
32 | #define core_fopen(file) fopen(file, "rb") |
33 | #if defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WIN64__) |
34 | #define core_fseek _fseeki64 |
35 | #define core_ftell _ftelli64 |
36 | #elif defined(_LARGEFILE_SOURCE) && defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 |
37 | #define core_fseek fseeko64 |
38 | #define core_ftell ftello64 |
39 | #else |
40 | #define core_fseek fseeko |
41 | #define core_ftell ftello |
42 | #endif |
43 | #define core_fread(fc, buff, len) fread(buff, 1, len, fc) |
44 | #define core_fclose fclose |
226a5691 |
45 | #endif |
2ff0b512 |
46 | |
47 | static UINT64 core_fsize(core_file *f) |
48 | { |
49 | UINT64 rv; |
50 | UINT64 p = core_ftell(f); |
51 | core_fseek(f, 0, SEEK_END); |
52 | rv = core_ftell(f); |
53 | core_fseek(f, p, SEEK_SET); |
54 | return rv; |
55 | } |
56 | |
57 | #endif |