hopefully fix bug where program freaks out when there's no client/server.txt

This commit is contained in:
2026-03-18 16:13:51 -05:00
parent 9625ab2881
commit 0aa7a07c8b

11
log.cc
View File

@@ -1,5 +1,8 @@
#include <fstream> #include <fstream>
#include <ios>
#include <sys/stat.h>
#include "public.h" #include "public.h"
#include "log.h" #include "log.h"
@@ -27,10 +30,16 @@ int
writeToFile(string path, string line, bool incLineNum) writeToFile(string path, string line, bool incLineNum)
{ {
ofstream file; ofstream file;
file.open(path, ios_base::app); // open the file in append mode
/*
* Hopefully this fixes the program messing up where the server/client
* doesn't start if the file wasn't created by a previous session.
*/
file.open(path, ios_base::out|ios_base::app);
if (file.is_open()) { if (file.is_open()) {
file << line << endl; file << line << endl;
file.close();
// this probably would help but theres too much broken stuff // this probably would help but theres too much broken stuff
// right now to be sure if (incLineNum) // right now to be sure if (incLineNum)
//{ //{