Reimplemented in Impala::Application::TagsLife::RemoteRetriever::RemoteImageRetriever. Definition at line 95 of file RemoteRetriever.h. References FileExists(), filename, fromCache, ILOG_DEBUG, ILOG_ERROR, target, toCache, and url. Referenced by Impala::Application::TagsLife::RemoteRetriever::RemoteImageRetriever::operator()(). 00095 { 00096 ILOG_DEBUG("Getting file from: " << url << " to store in " << target); 00097 00098 Core::Array::Array2dVec3UInt8* im = 0; 00099 if(fromCache && FileExists(filename)) { 00100 ILOG_DEBUG("Retrieving file from " << filename); 00101 std::ifstream cachedFile(filename.c_str(), std::ios::binary | std::ios::in); 00102 while (cachedFile.good()) // loop while extraction from file is possible 00103 target += (char) cachedFile.get(); // get character from file 00104 cachedFile.close(); 00105 return 1; 00106 } 00107 00108 #ifdef USE_CURL 00109 CURL *h = curl_easy_init(); 00110 CURLcode result; 00111 00112 target = std::string(); 00113 00114 curl_easy_setopt(h, CURLOPT_URL, url.c_str()); 00115 curl_easy_setopt(h, CURLOPT_WRITEFUNCTION, CurlCallback); 00116 curl_easy_setopt(h, CURLOPT_WRITEDATA, &target); 00117 00118 ILOG_DEBUG("Retrieving remote: " << url); 00119 result = curl_easy_perform(h); 00120 00121 if (result == CURLE_OK) { 00122 ILOG_DEBUG("retrieved " << target.size() << ", trying decode..."); 00123 00124 if(toCache) { 00125 std::ofstream cachedFile(filename.c_str(), std::ios::binary | std::ios::out); 00126 cachedFile << target; 00127 cachedFile.close(); 00128 } else { 00129 } 00130 curl_easy_cleanup(h); 00131 return 1; 00132 } 00133 curl_easy_cleanup(h); 00134 ILOG_ERROR("Could not retrieve URI: " << url); 00135 return 0; 00136 #else 00137 ILOG_ERROR("Network retrieval of files not compiled in this version."); 00138 return 0; 00139 #endif 00140 }
Here is the call graph for this function:
|