docs for FileIO, a very enjoyable namespace
This commit is contained in:
parent
07c58aab41
commit
9ccb5e1a6b
@ -8,6 +8,7 @@
|
||||
|
||||
std::string FileIO::read_all(const std::string& filename)
|
||||
{
|
||||
if(std::filesystem::is_directory(std::filesystem::status(filename))) Error::throw_error_without_location("unable to open file "+ filename + ": Is a directory");
|
||||
std::ifstream file;
|
||||
file.exceptions(std::ios::badbit | std::ios::failbit);
|
||||
try
|
||||
@ -19,7 +20,6 @@ std::string FileIO::read_all(const std::string& filename)
|
||||
Error::throw_error_without_location("unable to open file "+ filename + ": " + strerror(errno));
|
||||
return "";
|
||||
}
|
||||
if(std::filesystem::is_directory(std::filesystem::status(filename))) Error::throw_error_without_location("unable to open file "+ filename + ": Is a directory");
|
||||
file.exceptions(std::ios::goodbit);
|
||||
std::vector<char> file_chars;
|
||||
char fchar;
|
||||
|
@ -1,8 +1,11 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
/* Namespace for simple file operations. */
|
||||
namespace FileIO // namespaces are just so neat
|
||||
{
|
||||
/* Helper function to read all of a file's contents. */
|
||||
std::string read_all(const std::string& filename);
|
||||
/* Helper function to write a string to a file. */
|
||||
void write_all(const std::string& filename, const std::string& contents);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user