blob: 08ae9cf5a0c25c2bbb5edd7d8b697e11e0d71cca (
plain)
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
|
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
std::vector<std::string> directoryFiles;
const std::vector<std::string> files = {
"2d/rigidbody/rigidbody_1/main.cpp"
};
int main() {
struct dirent *entry = nullptr;
DIR *dp = nullptr;
dp = opendir("shared_cpp");
if (dp != nullptr) {
while ((entry = readdir(dp))) {
std::string sharedName = std::string("shared_cpp/") + entry->d_name;
directoryFiles.push_back(sharedName);
}
}
closedir(dp);
for (auto file : files) {
printf("Creating zip file for: %s\n", file.c_str());
std::string zipCommand = "";
std::ifstream cppFile;
cppFile.open(file);
if (!cppFile.is_open()) {
printf("Unable to create zip file for: %s\n", file.c_str());
continue;
}
std::string line;
std::ifstream outMainCpp("tmp.main.cpp");
std::string buffer;
while (getline(cppFile, line)) {
if (line.rfind("#include ", 0) == 0) {
int sharedCppFind = line.find("shared_cpp");
if (sharedCppFind != std::string::npos) {
line = line.substr(sharedCppFind + strlen("shared_cpp/"));
}
}
buffer += line;
buffer += "\n";
}
outMainCpp << buffer;
outMainCpp.close();
std::string zipCommand = "zip ";
zipCommand += "tmp.main.cpp";
for (auto dirFile : directoryFiles) {
}
system(zipCommand.c_str());
}
//system("zip archive.zip test_file.txt");
return 0;
}
|