diff --git a/main.cpp b/main.cpp index 69115da..23a7c8d 100644 --- a/main.cpp +++ b/main.cpp @@ -1,21 +1,42 @@ #include #include +#include #include "../C++UTF8Test/utf8.h" +namespace fs = std::filesystem; + const int MAX_FILE_SIZE = 8096; -int main() { - std::fstream layout_file; - layout_file.open("testfiles/_layout.html"); +string32 readfile(const char* name) { + std::fstream file_stream; + file_stream.open(name); + char* data = new char [MAX_FILE_SIZE]; int count(0); - while (layout_file) - data[count++] = layout_file.get(); + while (file_stream) + data[count++] = file_stream.get(); + file_stream.close(); data[--count] = 0; - - string32 layout (data); - + string32 file = string32 (data); delete data; + return file; +} + +int main() { + std::string path = "source"; + + string32 layout = readfile("source/_layout.html"); + + 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"; + } + } + } + std::cout << layout << "\n"; }