Skip to content

Commit f2b7889

Browse files
committed
Automate of generation and formatting README file
1 parent 6d55179 commit f2b7889

476 files changed

Lines changed: 600 additions & 33 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.DS_Store‎

0 Bytes
Binary file not shown.

‎README.md‎

Lines changed: 475 additions & 3 deletions

‎readme-generator.cpp‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include <cstdio>
2+
#include <fstream>
3+
#include <string>
4+
#include <cstring>
5+
#include <cassert>
6+
#include <dirent.h>
7+
using namespace std;
8+
9+
int main(void) {
10+
freopen("../README.md", "w", stdout);
11+
puts("## Solutions to LeetCode Programming Problems\n\n");
12+
DIR *dir;
13+
char *directoryPath = "/Users/kaidul/Documents/LeetCode_problems_solution/source-code/";
14+
struct dirent *ent;
15+
if ((dir = opendir (directoryPath)) != NULL) {
16+
while ((ent = readdir (dir)) != NULL) {
17+
int n = strlen(ent->d_name);
18+
if(n < 4) {
19+
continue;
20+
}
21+
char filename[260];
22+
for(int i = 0; i < n; ++i) {
23+
if(ent->d_name[i] == '_')
24+
filename[i] = ' ';
25+
else filename[i] = ent->d_name[i];
26+
}
27+
filename[strlen(ent->d_name)] = '\0';
28+
string sFileName = string(filename);
29+
int dot = sFileName.find('.');
30+
assert(dot != string::npos);
31+
sFileName = sFileName.substr(0, dot);
32+
printf("+ [%s](source-code/%s)\n", sFileName.c_str(), ent->d_name);
33+
// int result = rename(ent->d_name, filename);
34+
// if(result == 0) puts ( "File successfully renamed" );
35+
// else perror( "Error renaming file" );
36+
// printf ("%s, %s\n", ent->d_name, filename); // foo bar, foo_bar
37+
}
38+
closedir (dir);
39+
} else {
40+
/* could not open directory */
41+
perror ("");
42+
return EXIT_FAILURE;
43+
}
44+
return 0;
45+
}

‎rename_file.cpp‎

Lines changed: 0 additions & 30 deletions
This file was deleted.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)