30 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
31 #include <SDL_rwops.h>
47 File *
const handle =
static_cast<File *
>(
48 rw->hidden.unknown.data1);
52 if (whence == SEEK_SET)
56 else if (whence == SEEK_CUR)
59 const int64_t current = ftell(fd);
61 const int64_t current = lseek(fd, 0, SEEK_CUR);
67 "VirtFs::rwops_seek: Can't find position in file.");
72 if (
static_cast<int64_t
>(pos) != current)
75 "Can't fit current file position in an int!");
84 else if (whence == SEEK_END)
88 const long curpos = ftell(fd);
94 fseek(fd, 0, SEEK_END);
99 if (fstat(fd, &statbuf) == -1)
106 len =
static_cast<int64_t
>(statbuf.st_size);
112 #ifdef USE_FILE_FOPEN
113 if (fseek(fd, curpos, SEEK_SET) < 0)
119 "VirtFs::rwops_seek:Can't find end of file.");
124 if (
static_cast<int64_t
>(pos) != len)
126 #ifdef USE_FILE_FOPEN
127 fseek(fd, curpos, SEEK_SET);
130 "Can't fit end-of-file position in an int!");
139 "VirtFs::rwops_seek: Invalid 'whence' parameter.");
146 "Attempt to seek past start of file.");
150 const int64_t res =
FILESEEK(fd, pos, SEEK_SET);
167 File *
const handle =
static_cast<File *
>(
168 rw->hidden.unknown.data1);
171 #ifdef USE_FILE_FOPEN
172 const int64_t rc = fread(ptr,
size, maxnum, fd);
174 int max =
size * maxnum;
175 int cnt =
::read(fd, ptr, max);
178 const int64_t rc = cnt /
size;
181 #ifndef USE_FILE_FOPEN
182 if (rc !=
static_cast<int64_t
>(maxnum))
184 const int64_t pos = lseek(fd, 0, SEEK_CUR);
186 if (fstat(fd, &statbuf) == -1)
197 const void *
const ptr,
203 File *
const handle =
static_cast<File *
>(
204 rw->hidden.unknown.data1);
207 #ifdef USE_FILE_FOPEN
208 const int64_t rc = fwrite(ptr,
size, maxnum, fd);
210 int max =
size * maxnum;
211 int cnt =
::write(fd, ptr, max);
214 const int64_t rc = cnt /
size;
217 #ifndef USE_FILE_FOPEN
218 if (rc !=
static_cast<int64_t
>(maxnum))
220 const int64_t pos = lseek(fd, 0, SEEK_CUR);
222 if (fstat(fd, &statbuf) == -1)
237 File *
const handle =
static_cast<File*
>(
238 rw->hidden.unknown.data1);
245 RWOPSINT rwops_size(SDL_RWops *
const rw)
247 File *
const handle =
static_cast<File *
>(
248 rw->hidden.unknown.data1);
250 #ifdef USE_FILE_FOPEN
251 const long pos = ftell(fd);
252 fseek(fd, 0, SEEK_END);
253 const long sz = ftell(fd);
254 fseek(fd, pos, SEEK_SET);
258 if (fstat(fd, &statbuf) == -1)
263 return static_cast<int64_t>(statbuf.st_size);
#define reportAlways(...)
void assertLog(const char *const log_text,...)
int rwops_write(SDL_RWops *const rw, const void *const ptr, const int size, const int maxnum)
int32_t rwops_seek(SDL_RWops *const rw, const int32_t offset, const int whence)
int rwops_close(SDL_RWops *const rw)
int64_t read(File *const file, void *const buffer, const uint32_t objSize, const uint32_t objCount)
int rwops_read(SDL_RWops *const rw, void *const ptr, const int size, const int maxnum)
int64_t write(File *const file, const void *const buffer, const uint32_t objSize, const uint32_t objCount)