initial commit

This commit is contained in:
2026-03-12 15:56:28 -05:00
commit 5e41e88961
18 changed files with 770 additions and 0 deletions

44
log.cc Normal file
View File

@@ -0,0 +1,44 @@
#include <fstream>
#include "public.h"
#include "log.h"
// gets the number of lines in a file. returns -1 if there was an error.
int
linesInFile(string path)
{
ifstream file(path);
if (!file) {
return 1;
} else {
int lineNum = 0;
string line;
int num = 0;
while (getline(file, line))
num++;
return num;
}
}
// appends a line of text to the end of a given file. returns 0 if the file
// existed, 1 if it didn't work
int
writeToFile(string path, string line, bool incLineNum)
{
ofstream file;
file.open(path, ios_base::app); // open the file in append mode
if (file.is_open()) {
file << line << endl;
// this probably would help but theres too much broken stuff
// right now to be sure if (incLineNum)
//{
// linePos++;
// }
return 0;
} else {
// do something if it didn't work
return 1; // i guess that's good enough for now
}
}