forked from scott/threaded_network_chat
hopefully fix bug where program freaks out when there's no client/server.txt
This commit is contained in:
11
log.cc
11
log.cc
@@ -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)
|
||||||
//{
|
//{
|
||||||
|
|||||||
Reference in New Issue
Block a user