parent
100bf07f44
commit
48efbb5e07
|
@ -100,7 +100,7 @@ int audioFileOpen(const char* fname, int flags, ...)
|
|||
audioFile->soundDecoder = soundDecoderInit(audioFileSoundDecoderReadHandler, audioFile->fileHandle, &(audioFile->field_14), &(audioFile->field_10), &(audioFile->fileSize));
|
||||
audioFile->fileSize *= 2;
|
||||
} else {
|
||||
audioFile->fileSize = std::filesystem::file_size(path);
|
||||
audioFile->fileSize = compat_filelength(fileno(stream));
|
||||
}
|
||||
|
||||
audioFile->position = 0;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <filesystem>
|
||||
|
||||
// Reads .DAT file contents.
|
||||
//
|
||||
|
@ -32,7 +31,7 @@ DBase* dbaseOpen(const char* filePath)
|
|||
|
||||
// Get file size, and reposition stream to read footer, which contains two
|
||||
// 32-bits ints.
|
||||
int fileSize = std::filesystem::file_size(filePath);
|
||||
int fileSize = compat_filelength(fileno(stream));
|
||||
if (fseek(stream, fileSize - sizeof(int) * 2, SEEK_SET) != 0) {
|
||||
goto err;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
|
||||
#include <filesystem>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
int compat_stricmp(const char* string1, const char* string2)
|
||||
{
|
||||
return SDL_strcasecmp(string1, string2);
|
||||
|
@ -81,3 +88,12 @@ void compat_makepath(char* path, const char* drive, const char* dir, const char*
|
|||
strcpy(path, p.string().substr(0, COMPAT_MAX_PATH - 1).c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
long compat_filelength(int fd)
|
||||
{
|
||||
long originalOffset = lseek(fd, 0, SEEK_CUR);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
long filesize = lseek(fd, 0, SEEK_END);
|
||||
lseek(fd, originalOffset, SEEK_SET);
|
||||
return filesize;
|
||||
}
|
||||
|
|
|
@ -24,5 +24,6 @@ char* compat_strlwr(char* string);
|
|||
char* compat_itoa(int value, char* buffer, int radix);
|
||||
void compat_splitpath(const char* path, char* drive, char* dir, char* fname, char* ext);
|
||||
void compat_makepath(char* path, const char* drive, const char* dir, const char* fname, const char* ext);
|
||||
long compat_filelength(int fd);
|
||||
|
||||
#endif /* PLATFORM_COMPAT_H */
|
||||
|
|
|
@ -418,9 +418,7 @@ long xfileGetSize(XFile* stream)
|
|||
fileSize = 0;
|
||||
break;
|
||||
default:
|
||||
fseek(stream->file, 0L, SEEK_END);
|
||||
fileSize = ftell(stream->file);
|
||||
rewind(stream->file);
|
||||
fileSize = compat_filelength(fileno(stream->file));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue