Fix configuration file I/O (#8)

Due to a programming error introduced in commit 83ec72e80c, an instance
of std::ifstream was being initialized with the path to the website
directory (without the file name appended to the path).
This commit is contained in:
luca0N! 2024-03-24 17:49:02 -03:00
parent 2cc0fa67c5
commit fb546ccec8
Signed by: luca0N
GPG Key ID: 5978D960572B449E
2 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 luca0N!
* Copyright (C) 2022-2024 luca0N!
*
* This file is part of Static Website Generator (swg).
*
@ -39,6 +39,8 @@
#include <filesystem>
#include <string>
const std::string SWG_CONFIG_FILENAME = "swg.cfg";
struct Blog {
char name[64],
path[64],

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 luca0N!
* Copyright (C) 2022-2024 luca0N!
*
* This file is part of Static Website Generator (swg).
*
@ -34,8 +34,10 @@ void parse_config(SwgContext *ctx, std::string const &path) {
int blogCount = 0;
Blog *currentBlog = NULL;
std::ifstream cfgStream(path + "/" + SWG_CONFIG_FILENAME);
if (!cfgStream)
throw std::runtime_error("Couldn't find swg configuration file at the specified path: " + path);
std::ifstream cfgStream(path);
// Parse configuration file
for (std::string line; std::getline(cfgStream, line);) {
// Skip comment lines