mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Revert "Switch to using std::filesystem (#1235)"
This reverts commit cf62ff772f.
Some functions used by this break on macOS before 10.15,
which we want to keep supporting.
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include <assert.h>
|
||||
#include <cassert>
|
||||
#include <fcntl.h>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <ios>
|
||||
#include <iostream>
|
||||
@@ -42,7 +41,7 @@ public:
|
||||
* This should only be called once, and before doing any `->` operations.
|
||||
* Returns `nullptr` on error, and a non-null pointer otherwise.
|
||||
*/
|
||||
File *open(std::filesystem::path const &path, std::ios_base::openmode mode) {
|
||||
File *open(std::string const &path, std::ios_base::openmode mode) {
|
||||
if (path != "-") {
|
||||
return _file.emplace<std::filebuf>().open(path, mode) ? this : nullptr;
|
||||
} else if (mode & std::ios_base::in) {
|
||||
@@ -86,11 +85,11 @@ public:
|
||||
: nullptr;
|
||||
}
|
||||
|
||||
std::string string(std::filesystem::path const &path) const {
|
||||
return std::visit(Visitor{[&path](std::filebuf const &) { return path.string(); },
|
||||
char const *c_str(std::string const &path) const {
|
||||
return std::visit(Visitor{[&path](std::filebuf const &) { return path.c_str(); },
|
||||
[](std::streambuf const *buf) {
|
||||
return std::string{buf == std::cin.rdbuf()
|
||||
? "<stdin>" : "<stdout>"};
|
||||
return buf == std::cin.rdbuf()
|
||||
? "<stdin>" : "<stdout>";
|
||||
}},
|
||||
_file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user