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:
ISSOtm
2023-12-30 20:31:13 +01:00
committed by Rangi
parent 93d1d85f94
commit 6b559e99b2
5 changed files with 105 additions and 103 deletions

View File

@@ -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);
}