removing one of the two download functions

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5612 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
xapantu 2010-07-01 17:16:10 +00:00
parent 5b20361094
commit 362abc0fc4
4 changed files with 15 additions and 24 deletions

View File

@ -27,29 +27,16 @@
#include "io/file_manager.hpp"
// ------------------------------------------------------------------------------------------------------
void download(std::string file)
void download(std::string file, std::string save)
{
CURL *session = curl_easy_init();
std::cout << "Downloading: " << std::string(UserConfigParams::m_server_addons.toString() + "/" + file) << std::endl;
curl_easy_setopt(session, CURLOPT_URL, std::string(UserConfigParams::m_server_addons.toString() + "/" + file).c_str());
FILE * fp = fopen(std::string(file_manager->getConfigDir() + std::string("/") + file).c_str(), "w");
curl_easy_setopt(session, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(session, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_perform(session);
fclose(fp);
curl_easy_cleanup(session);
std::cout << UserConfigParams::m_server_addons.toString() << std::endl;
}
// ------------------------------------------------------------------------------------------------------
void download(std::string file, std::string save)
{
CURL *session = curl_easy_init();
std::cout << "Downloading: " << std::string(UserConfigParams::m_server_addons.toString() + "/" + file) << std::endl;
curl_easy_setopt(session, CURLOPT_URL, std::string(UserConfigParams::m_server_addons.toString() + "/" + file).c_str());
FILE * fp = fopen(std::string(file_manager->getConfigDir() + std::string("/") + save).c_str(), "w");
FILE * fp;
if(save != "")
fp = fopen(std::string(file_manager->getConfigDir() + std::string("/") + save).c_str(), "w");
else
fp = fopen(std::string(file_manager->getConfigDir() + std::string("/") + file).c_str(), "w");
curl_easy_setopt(session, CURLOPT_WRITEDATA, fp);
curl_easy_setopt(session, CURLOPT_WRITEFUNCTION, fwrite);
curl_easy_perform(session);

View File

@ -21,11 +21,7 @@
#define HEADER_NETWORK_HPP
/** Download a file. The file name isn't absolute, the server in the config will be added to file. */
void download(std::string file);
/** Download a file with a specific destination. */
void download(std::string file, std::string out);
void download(std::string file, std::string save = "");
#endif
#endif

View File

@ -583,3 +583,10 @@ void FileManager::listFiles(std::set<std::string>& result, const std::string& di
} // listFiles
//-----------------------------------------------------------------------------
#ifdef ADDONS_MANAGER
void FileManager::checkAndCreateDirForAddons(std::string addons_path)
{
checkAndCreateDirectory(getAddonsDir() + "/data/" + addons_path);
}
#endif

View File

@ -80,6 +80,7 @@ public:
std::string getConfigDir () const;
#ifdef ADDONS_MANAGER
std::string getAddonsDir () const;
void checkAndCreateDirForAddons(std::string addons_path);
#endif
std::string getKartDir () const;
std::string getDataDir () const;