mirror of
https://github.com/AskDavis/Casinotest.git
synced 2026-01-01 05:05:57 -08:00
[issue-3] add boostrap download if it does not exist.
This commit is contained in:
20
src/init.cpp
20
src/init.cpp
@@ -423,6 +423,26 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
|
||||
// hardcoded $DATADIR/bootstrap.dat
|
||||
filesystem::path pathBootstrap = GetDataDir() / "bootstrap.dat";
|
||||
|
||||
if (!filesystem::exists(pathBootstrap)) {
|
||||
printf("Donwloading bootstrap.dat from casinocoin.org...\n");
|
||||
CURL *curl;
|
||||
FILE *fp;
|
||||
CURLcode res;
|
||||
char *url = "http://casinocoin.org/downloads/bootstrap.dat";
|
||||
char outfilename[FILENAME_MAX] = pathBootstrap.string().c_str();
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
fp = fopen(outfilename, "wb");
|
||||
curl_easy_setopt(curl, CURLOPT_URL, url);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
|
||||
res = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
if (filesystem::exists(pathBootstrap)) {
|
||||
FILE *file = fopen(pathBootstrap.string().c_str(), "rb");
|
||||
if (file) {
|
||||
|
||||
Reference in New Issue
Block a user