-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
63 lines (54 loc) · 1.58 KB
/
Main.cpp
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
#include <fstream>
#include <filesystem>
#include <iostream>
#include <string>
namespace fs = std::filesystem;
int main()
{
std::string newName, oldPath, oldName;
std::getline(std::cin, oldPath);
std::getline(std::cin, newName);
oldName = fs::path(oldPath).filename().string();
std::ifstream sln(oldPath + '/' + oldName + ".sln");
std::ofstream slnOut(oldPath + '/' + newName + ".sln");
if (sln.is_open())
{
std::string data;
size_t pos;
while (std::getline(sln, data))
{
while (data.find(oldName) != std::string::npos)
{
pos = data.find(oldName);
data = data.replace(pos, oldName.size(), newName);
}
slnOut.write((data + '\n').data(), data.size() + 1);
}
sln.close();
slnOut.close();
}
std::ifstream vcxproj(oldPath + '/' + oldName + ".vcxproj");
std::ofstream vcxprojOut(oldPath + '/' + newName + ".vcxproj");
if (vcxproj.is_open())
{
std::string data;
size_t pos;
while (std::getline(vcxproj, data))
{
while (data.find(oldName) != std::string::npos)
{
pos = data.find(oldName);
data = data.replace(pos, oldName.size(), newName);
}
vcxprojOut.write((data + '\n').data(), data.size() + 1);
}
vcxproj.close();
vcxprojOut.close();
}
fs::remove(oldPath + '/' + oldName + ".sln");
fs::remove(oldPath + '/' + oldName + ".vcxproj");
fs::rename(oldPath + '/' + oldName + ".vcxproj.filters", oldPath + '/' + newName + ".vcxproj.filters");
fs::rename(oldPath + '/' + oldName + ".vcxproj.user", oldPath + '/' + newName + ".vcxproj.user");
fs::rename(oldPath, fs::path(oldPath).parent_path().string() + '/' + newName);
return 0;
}