From 4bdf100a9b33bda8b03decdf934c43b12373ec53 Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 12 Apr 2022 22:04:32 +0200 Subject: DataSource now properly includes file reading functions --- StarsEx/DataSource.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'StarsEx') diff --git a/StarsEx/DataSource.cpp b/StarsEx/DataSource.cpp index ce458d3..b413d82 100644 --- a/StarsEx/DataSource.cpp +++ b/StarsEx/DataSource.cpp @@ -7,6 +7,7 @@ #include "DataSource.h" #include +#include #include #include @@ -165,12 +166,12 @@ FileSystemDataSource::Load(const Text& prefix, const char* name, std::uint8_t*& std::filesystem::path full_path {m_path}; full_path.append(prefix.data()); full_path.append(name); - FILE* f = fopen(full_path.string().c_str(), "rb"); + auto f = std::fopen(full_path.string().c_str(), "rb"); if (!f) return 0; // Again, -1 would be better to differentiate an error from an empty file - fseek(f, 0, SEEK_END); - int length = ftell(f); - fseek(f, 0, SEEK_SET); + std::fseek(f, 0, SEEK_END); + int length = std::ftell(f); + std::fseek(f, 0, SEEK_SET); if (null_terminate) { buf = new std::uint8_t[length + 1]; if (buf) @@ -181,7 +182,7 @@ FileSystemDataSource::Load(const Text& prefix, const char* name, std::uint8_t*& } int bytes = 0; if (buf) - bytes = fread(buf, length, 1, f); - fclose(f); + bytes = std::fread(buf, length, 1, f); + std::fclose(f); return bytes; } -- cgit v1.1