mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 02:32:06 +00:00
Make file.hpp independent of gfx (#1733)
This commit is contained in:
@@ -15,8 +15,6 @@
|
|||||||
#include "helpers.hpp" // assume
|
#include "helpers.hpp" // assume
|
||||||
#include "platform.hpp"
|
#include "platform.hpp"
|
||||||
|
|
||||||
#include "gfx/warning.hpp"
|
|
||||||
|
|
||||||
class File {
|
class File {
|
||||||
std::variant<std::streambuf *, std::filebuf> _file;
|
std::variant<std::streambuf *, std::filebuf> _file;
|
||||||
|
|
||||||
@@ -32,11 +30,7 @@ public:
|
|||||||
assume(!(mode & std::ios_base::out));
|
assume(!(mode & std::ios_base::out));
|
||||||
_file.emplace<std::streambuf *>(std::cin.rdbuf());
|
_file.emplace<std::streambuf *>(std::cin.rdbuf());
|
||||||
if (setmode(STDIN_FILENO, (mode & std::ios_base::binary) ? O_BINARY : O_TEXT) == -1) {
|
if (setmode(STDIN_FILENO, (mode & std::ios_base::binary) ? O_BINARY : O_TEXT) == -1) {
|
||||||
fatal(
|
return nullptr;
|
||||||
"Failed to set stdin to %s mode: %s",
|
|
||||||
mode & std::ios_base::binary ? "binary" : "text",
|
|
||||||
strerror(errno)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assume(mode & std::ios_base::out);
|
assume(mode & std::ios_base::out);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
|
#include <errno.h>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
@@ -612,7 +613,7 @@ void parseExternalPalSpec(char const *arg) {
|
|||||||
std::filebuf file;
|
std::filebuf file;
|
||||||
// Some parsers read the file in text mode, others in binary mode
|
// Some parsers read the file in text mode, others in binary mode
|
||||||
if (!file.open(path, std::ios::in | std::get<2>(*iter))) {
|
if (!file.open(path, std::ios::in | std::get<2>(*iter))) {
|
||||||
error("Failed to open palette file \"%s\"", path);
|
fatal("Failed to open palette file \"%s\": %s", path, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user