Use a special name for stdin/stdout in diagnostics

This commit is contained in:
ISSOtm authored and Eldred Habert committed 2022-11-15 19:49:04 +01:00
1 parent 6902387991
commit 3e5cd8ce1a
5 files changed
+41 -21

No files matched your search

+9
View File
@@ -78,6 +78,7 @@ public:
// See the `operator*` equivalent.
return const_cast<File *>(this)->operator->();
}
File *close() {
return std::visit(Visitor{[this](std::filebuf &file) {
// This is called by the destructor, and an explicit `close`
@@ -90,6 +91,14 @@ public:
? this
: nullptr;
}
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 buf == std::cin.rdbuf() ? "<stdin>" : "<stdout>";
}},
_file);
}
};
#endif // RGBDS_FILE_HPP