This repository was archived by the owner on Jan 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateReadMe.cpp
More file actions
106 lines (78 loc) · 1.98 KB
/
updateReadMe.cpp
File metadata and controls
106 lines (78 loc) · 1.98 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#include <filesystem>
#include <fstream>
#include <ctime>
namespace fs = std::filesystem;
void readmeInit(std::ofstream &out);
bool bojStats(std::ofstream &out, std::ofstream &err);
void copy(std::string source, std::ofstream &out);
int main(int argc, char const *argv[])
{
bool exception = false;
std::ofstream out;
out.open("readme.md");
std::ofstream err;
err.open("error.log");
readmeInit(out);
exception |= bojStats(out, err);
out.close();
err.close();
if (!exception)
{
fs::remove("error.log");
}
else
{
out.open("readme.md");
out << "Error Occured.\n\nPlease See The Error Log\n";
}
return 0;
}
void readmeInit(std::ofstream &out)
{
out << "# 대충 레포 제목\n\n";
}
bool bojStats(std::ofstream &out, std::ofstream &err)
{
fs::path BOJ("Baekjoon Online Judge");
if (!fs::exists(BOJ))
{
err << "Fatal Error : Directory \"" + BOJ.string() + "\" Does Not Exist\n";
return true;
}
if (!fs::is_directory(BOJ))
{
err << "Fatal Error : \"" + BOJ.string() + "\" Is Not A Directory\n";
return true;
}
int cnt = 0;
for (auto &p : fs::directory_iterator(BOJ))
{
if (fs::is_directory(p))
{
cnt++;
}
}
out << "BOJ Problem Count = " << cnt << "\n\n";
out << "---\n\n";
out << "## 코드포스 레이팅\n";
out << "[](https://github.com/ingyu1008/Algorithm-Problem-Solving/blob/master/cfStats.html)";
out << "---\n\n";
out << "## 최근 푼 문제 (BaekJoon)\n";
copy("recent.md", out);
out << "\n\n---\n\n";
time_t t;
time(&t);
out << "last updated : " << asctime(localtime(&t)) << "\n";
return false;
}
void copy(std::string source, std::ofstream &out)
{
std::ifstream src;
src.open(source);
std::string line;
while (std::getline(src, line))
{
out << line << "\n";
}
src.close();
}