summaryrefslogtreecommitdiffhomepage
path: root/StarsEx
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-12 22:04:32 +0200
committerAki <please@ignore.pl>2022-04-12 22:04:32 +0200
commit4bdf100a9b33bda8b03decdf934c43b12373ec53 (patch)
treeb6c2682ff647f08447d597b0532647b06ce6446f /StarsEx
parentb0469ba1c28d1c8febed0693bc6a07cdaf09214a (diff)
downloadstarshatter-4bdf100a9b33bda8b03decdf934c43b12373ec53.zip
starshatter-4bdf100a9b33bda8b03decdf934c43b12373ec53.tar.gz
starshatter-4bdf100a9b33bda8b03decdf934c43b12373ec53.tar.bz2
DataSource now properly includes file reading functions
Diffstat (limited to 'StarsEx')
-rw-r--r--StarsEx/DataSource.cpp13
1 files changed, 7 insertions, 6 deletions
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 <cstdint>
+#include <cstdio>
#include <cstring>
#include <filesystem>
@@ -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;
}