-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlucastext.h
62 lines (59 loc) · 1.64 KB
/
lucastext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <windows.h>
#include <cstdio>
#include <fstream>
using namespace std;
void compile(string cppfile) {
ofstream compile("compiler.bat");
compile << " echo WATCH FOR COMPILATION ERRORS HERE!" << endl;
compile << "g++ " << cppfile << " -o " << cppfile << ".exe" << endl;
compile.close();
system("compiler.bat");
remove("compiler.bat");
return;
}
void save(string filename, string contents) {
char tempPath[MAX_PATH];
GetTempPathA(MAX_PATH, tempPath);
string tempFilePath{tempPath};
tempFilePath = tempFilePath + "lucastext\\" + filename;
ofstream savedata(tempFilePath);
savedata.close();
cout << tempFilePath;
cout << contents;
cout << filename;
}
void write(string filename) {
string input;
ofstream writing(filename);
std::cout << filename << " has been created! Type to add now!\nType #exit to exit!\nPro tip, use Ctrl + Shift + V to paste contents.";
while (write) {
getline(cin, input);
if (input == "#exit") {
break;
}
writing << input << endl;
}
cout << "File written successfully!\n";
return;
}
void read(string filename) {
ifstream read(filename);
if (read) {
cout << "Reading " << filename << endl;
}
if (!read) {
cout << "Problem reading " << filename << endl;
return;
}
while (!read.eof()) {
string output;
getline(read, output);
if (!read.eof()) {
cout << output << endl;
}
if (read.eof()) {
cout << output;
}
}
}