-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMCInstaller.cpp
More file actions
83 lines (63 loc) · 1.64 KB
/
MCInstaller.cpp
File metadata and controls
83 lines (63 loc) · 1.64 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
#include <iostream>
#include <Windows.h>
#include <fstream>
#include <Urlmon.h>
#include <direct.h>
#include <string>
#include <sys/stat.h>
#include <json/json.h>
#include <json/value.h>
using namespace std;
string mcversion;
string mcdir;
void main_downloader();
bool file_download(string u, string p);
int main(int argc, char** argv) {
if (argc < 3)
{
cout << "[-] You need more arguments.";
return 1;
}
mcversion = argv[1];
mcdir = argv[2];
ifstream jarfile, jsonfile;
string jar = mcdir + "\\versions\\" + mcversion + "\\" + mcversion + ".jar";
string json = mcdir + "\\versions\\" + mcversion + "\\" + mcversion + ".json";
jarfile.open(jar.c_str());
jsonfile.open(json.c_str());
if (jarfile || jsonfile) {
cout << "You have MC in " << mcversion;
return 1;
}
main_downloader();
return 0;
}
void main_downloader()
{
string url = "https://raw.githubusercontent.com/InventivetalentDev/minecraft-assets/" + mcversion + "/version.json";
string path = std::string(mcdir + "\\versions\\" + mcversion);
struct stat buffer;
if (stat(path.c_str(), &buffer) != 0)
{
CreateDirectory(path.c_str(), NULL);
}
string vrspath = path + "\\version.json";
file_download(url, vrspath);
ifstream file(vrspath.c_str());
Json::Reader reader;
Json::Value completeJsonData;
reader.parse(file, completeJsonData);
}
bool file_download(string f_url, string f_path)
{
if (S_OK == URLDownloadToFile(NULL, f_url.c_str(), f_path.c_str(), 0, NULL))
{
cout << "[+] Success Download ";
return true;
}
else
{
cout << "[-] Failed Download";
return false;
}
}