mirror of
https://github.com/KeyZox71/webserv.git
synced 2025-05-10 20:28:46 +02:00
「✨」 feat: changed to use the define
This commit is contained in:
11
src/help.cpp
11
src/help.cpp
@ -6,13 +6,14 @@
|
|||||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/04/10 13:08:36 by adjoly #+# #+# */
|
/* Created: 2025/04/10 13:08:36 by adjoly #+# #+# */
|
||||||
/* Updated: 2025/04/28 14:29:20 by adjoly ### ########.fr */
|
/* Updated: 2025/05/06 16:14:03 by adjoly ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include <log.hpp>
|
#include <log.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <help.hpp>
|
#include <help.hpp>
|
||||||
|
#include <sstream>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <webserv.hpp>
|
#include <webserv.hpp>
|
||||||
@ -28,11 +29,13 @@ void _printHelp(void) {
|
|||||||
|
|
||||||
void _generateConf(void) {
|
void _generateConf(void) {
|
||||||
webserv::Logger _log;
|
webserv::Logger _log;
|
||||||
if (access("./sample.conf", F_OK) == 0) {
|
if (access(SAMPLE_CONF_PATH, F_OK) == 0) {
|
||||||
_log.warn(std::string(SAMPLE_CONF_PATH) + " already exist, aborting");
|
_log.warn(std::string(SAMPLE_CONF_PATH) + " already exist, aborting");
|
||||||
} else {
|
} else {
|
||||||
_log.info("generating config into ./sample.conf...");
|
std::stringstream str;
|
||||||
std::ofstream file("./sample.conf");
|
str << "generating config into " << SAMPLE_CONF_PATH << "...";
|
||||||
|
_log.info(str.str());
|
||||||
|
std::ofstream file(SAMPLE_CONF_PATH);
|
||||||
if (file.is_open()) {
|
if (file.is_open()) {
|
||||||
file << "[server]\nhost = \"localhost\"\nport = "
|
file << "[server]\nhost = \"localhost\"\nport = "
|
||||||
"8080\n\n[server.location./]\nmethods = { \"GET\" }\nroot "
|
"8080\n\n[server.location./]\nmethods = { \"GET\" }\nroot "
|
||||||
|
Reference in New Issue
Block a user