From f6504276467a976aff6506c8f120ed81f4480cfa Mon Sep 17 00:00:00 2001 From: Xnoe Date: Wed, 8 Jul 2020 22:30:35 +0100 Subject: [PATCH] It's now in a working state. Yay! --- main.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 23a7c8d..76da3fe 100644 --- a/main.cpp +++ b/main.cpp @@ -6,7 +6,7 @@ namespace fs = std::filesystem; -const int MAX_FILE_SIZE = 8096; +const int MAX_FILE_SIZE = 65536; string32 readfile(const char* name) { std::fstream file_stream; @@ -27,16 +27,18 @@ int main() { std::string path = "source"; string32 layout = readfile("source/_layout.html"); + fs::remove_all("output"); for (const auto & file : fs::recursive_directory_iterator(path)) { if (file.is_regular_file()) { if (file.path().stem().string().at(0) != '_') { string32 newFile = layout; - newFile.replace("{{ content }}", readfile(file.path().string().c_str())); - std::cout << "File: " << file.path() << "\n-----\n" << newFile << "\n-----\n"; + newFile.replace("{{ content }}", readfile(file.path().c_str())); + fs::create_directories("output" + file.path().parent_path().string().substr(6)); + std::ofstream outfile("output" + file.path().string().substr(6)); + outfile << newFile; + outfile.close(); } } } - - std::cout << layout << "\n"; }