-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
94 lines (70 loc) · 2.05 KB
/
Copy pathmain.cpp
File metadata and controls
94 lines (70 loc) · 2.05 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
#include <string>
#include <fstream>
#include <iostream>
#include <filesystem>
#include <vector>
#include <algorithm>
namespace fs = std::filesystem;
using namespace std;
string path = "/usr/share/fontconfig/conf.avail/";
int input;
string fn_in;
string filename;
string cmd="vim ";
vector <string> paths;
vector<string>::iterator cfn;
int main()
{
for (const auto & entry : fs::directory_iterator(path)){
//std::cout << entry.path()<<"\n";
paths.push_back(entry.path());
}
while(true){
cout<<"Mattia's software FontConfig editor v1.0"<<endl;
cout<<"Choose and option:"<<endl;
cout<<"[1] List all config files\n[2] Edit a config file\n[3] Quit"<<endl;
cin>>input;
switch(input) {
case 1:{
for (const auto & entry : fs::directory_iterator(path))
{
std::cout << entry.path()<<"\n";
}
cout<<endl;
break;
}
case 2:{
//for (auto i : paths)
//cout << i << " ";
cout<<"Type the config file name"<<endl;
cin>>fn_in;
filename=path.append(fn_in);
cfn = find(paths.begin(), paths.end(), filename);
//if(cfn !=paths.end)
//cout<<*cfn<<endl;
//cout << distance(paths.begin(), cfn)<<endl;
ifstream inputFile(*cfn);
if (inputFile.is_open())
{
string line;
while (getline(inputFile, line))
{
cout << line << endl;
}
}
else
{
cout << "Invalid file name" << std::endl;
}
inputFile.close();
cmd=cmd.append(*cfn);
system(cmd.c_str());
break;
}
case 3:{
return 0;
}
}
//for (auto s : paths)std::cout << s << "\n";
}
}