Replace filelength

See #17
This commit is contained in:
Jan Šimek 2022-05-28 18:41:29 +02:00
parent 14ce3994ce
commit 7a58904aa4
5 changed files with 13 additions and 5 deletions

View File

@ -6,9 +6,9 @@
#include "sound.h"
#include <assert.h>
#include <io.h>
#include <stdio.h>
#include <string.h>
#include <filesystem>
// 0x5108C0
AudioFileIsCompressedProc* _queryCompressedFunc_2 = _defaultCompressionFunc__;
@ -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 = filelength(fileno(stream));
audioFile->fileSize = std::filesystem::file_size(path);
}
audioFile->position = 0;

View File

@ -5,6 +5,7 @@
#include "sound.h"
#include <limits.h>
#include <stdlib.h> // qsort
#include <stdio.h>
#include <string.h>

View File

@ -5,10 +5,10 @@
#include <fpattern.h>
#include <assert.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <filesystem>
// Reads .DAT file contents.
//
@ -32,7 +32,7 @@ DBase* dbaseOpen(const char* filePath)
// Get file size, and reposition stream to read footer, which contains two
// 32-bits ints.
int fileSize = filelength(fileno(stream));
int fileSize = std::filesystem::file_size(filePath);
if (fseek(stream, fileSize - sizeof(int) * 2, SEEK_SET) != 0) {
goto err;
}

View File

@ -56,7 +56,12 @@
#include "window_manager.h"
#include "world_map.h"
#ifdef _WIN32
#include <io.h>
#else
#include <unistd.h> // access
#endif
#include <stdio.h>
#define HELP_SCREEN_WIDTH (640)

View File

@ -418,7 +418,9 @@ long xfileGetSize(XFile* stream)
fileSize = 0;
break;
default:
fileSize = filelength(fileno(stream->file));
fseek(stream->file, 0L, SEEK_END);
fileSize = ftell(stream->file);
rewind(stream->file);
break;
}