-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.cpp
More file actions
93 lines (74 loc) · 2.19 KB
/
Copy pathcreate.cpp
File metadata and controls
93 lines (74 loc) · 2.19 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
#include <iostream>
#include <filesystem>
#include <fstream>
#include <vector>
#include <random>
namespace fs = std::filesystem;
std::vector<std::string> extensions = {
".pdf", ".png", ".jpg", ".txt", ".docx",
".xlsx", ".csv", ".json", ".log", ".md", ".zip"
};
std::vector<std::string> words = {
"report", "invoice", "scan", "backup", "data", "image",
"notes", "draft", "final", "copy", "export", "tmp",
"file", "document", "archive", "session", "log"
};
std::random_device rd;
std::mt19937 gen(rd());
int randInt(int min, int max) {
std::uniform_int_distribution<> dist(min, max);
return dist(gen);
}
std::string randomChoice(const std::vector<std::string>& v) {
return v[randInt(0, v.size() - 1)];
}
std::string randomName() {
int count = randInt(2, 5);
std::string name;
for (int i = 0; i < count; i++) {
name += randomChoice(words);
if (i < count - 1) name += "_";
}
return name;
}
std::string randomExtension() {
return randomChoice(extensions);
}
std::string fakeContent(const std::string& ext) {
if (ext == ".txt" || ext == ".md" || ext == ".log") {
return "temporary log data - " + randomName();
}
if (ext == ".json") {
return "{\"status\":\"ok\",\"data\":[]}";
}
if (ext == ".csv") {
return "id,name,value\n1,test,0";
}
return "";
}
int main() {
std::string baseDir = "chaos_output";
fs::create_directory(baseDir);
std::vector<fs::path> folders;
folders.push_back(baseDir);
for (int i = 0; i < 20; i++) {
fs::path parent = folders[randInt(0, folders.size() - 1)];
fs::path newDir = parent / randomName();
fs::create_directories(newDir);
folders.push_back(newDir);
}
for (int i = 0; i < 1037; i++) { // nbr max
std::string ext = randomExtension();
fs::path folder;
if (randInt(0, 100) < 40) { //% fichiers racine
folder = baseDir;
} else {
folder = folders[randInt(0, folders.size() - 1)];
}
fs::path filePath = folder / (randomName() + ext);
std::ofstream file(filePath);
file << fakeContent(ext);
}
std::cout << "Chaos generated in: " << baseDir << std::endl;
return 0;
}