-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecri.cpp
More file actions
168 lines (126 loc) · 2.86 KB
/
Copy pathrecri.cpp
File metadata and controls
168 lines (126 loc) · 2.86 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <memory>
#include <filesystem>
#include <chrono>
#include <thread>
#include <stdexcept>
#include <sstream>
/*
* BIG TODOS:
* process files
* versioning each thing of whatever it sees
* etc
*/
const std::string idealfilextension = ".bitt";
std::vector<char> tokenstants = {':',';'};
struct registers{
std::string containt;
std::string mitsage;
std::string nominem;
};
void mod1(std::filesystem::path k ){
std::string roi ="";
std::ifstream yo(k);
if (!yo.is_open()) return;
size_t po =0;
size_t m =0;
std::stringstream yocast;
yocast << yo.rdbuf();
yo.close();
std::string palius = yocast.str();
auto camito =[&]()->int{
for(size_t i =0; i<palius.length(); i++){
if(tokenstants[0] == palius[i]){
m =i;
for(size_t op=m+1; op<palius.length(); op++){
if(palius[op] ==tokenstants[1])
break;
roi += palius[op];
}
break;
}
}
return std::stoi(roi);
};
int replacer =camito();
replacer++;
int f =0;
int roe =0;
auto s = std::to_string(replacer);
auto pancho = [&]()->std::string{
std::string alt = "version:"+roi+";";
std::string neu = "version:"+s+";";
auto kairmos = palius.find(alt);
if(kairmos!= std::string::npos){
palius.replace(kairmos,alt.length(),neu);
}
return palius;
};
std::string text_finale = pancho();
std::ofstream archivo_out(k, std::ios::trunc);
if (archivo_out.is_open()) {
archivo_out << text_finale;
}
}
void creador(registers& r){
/*
* function related to create a file if this one doesn't exist
*/
r.mitsage = "version:0; LÑALALLALAL THIS FILE IS AUTOGENERATED BY BIT ";
r.nominem = "register.bitt";
std::ofstream archivo(r.nominem,std::ios::trunc);
archivo<<r.mitsage;
}
auto filebuscador(std::filesystem::path routedrats){
int contador = 0;
for(const auto& bit : std::filesystem::directory_iterator(".")){
if(bit.is_regular_file() &&
bit.path().extension() == idealfilextension){
contador++;
}
}
//std::cout<<contador; debug only*****
if( 2<=contador){
return 1;
}
else{
return 0;
}
}
auto zoek(std::filesystem::path rutilla){
for(const auto& interada :
std::filesystem::directory_iterator(rutilla)){
if(interada.is_regular_file()){
if(interada.path()
.extension() == idealfilextension){
return interada.path();
}
}
}
return std::filesystem::path {};
}
int main(){
registers k;
registers keimos;
std::filesystem::path aqui = std::filesystem::current_path();
auto bit =filebuscador(aqui);
if(bit ==1){
std::cerr<<"liado parda\n";
return 1;
}
else{
}
auto ko = zoek(aqui);
if(ko.empty()){
creador(k);
ko = k.nominem;
}
else{
ko = zoek(aqui);
}
mod1(ko);
return 0;
}