Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

int Impala::Application::MediaTable::RemoteRetriever::RemoteFileRetriever::operator() (  )  [inline]

Definition at line 91 of file RemoteRetriever.h.

References FileExists(), filename, fromCache, Impala::Application::MediaTable::RemoteRetriever::GetInstance(), ILOG_DEBUG, ILOG_ERROR, target, toCache, and url.

00091                                  {
00092                         ILOG_DEBUG("Getting file from: " << url << " to store in " << &target);
00093 
00094                         Core::Array::Array2dVec3UInt8* im = 0;
00095                         if(fromCache && FileExists(filename)) {
00096                                 ILOG_DEBUG("Retrieving file from " << filename);
00097                                 std::ifstream cachedFile(filename.c_str(), std::ios::binary | std::ios::in);
00098                                 while (cachedFile.good())     // loop while extraction from file is possible
00099                                     target += (char) cachedFile.get();       // get character from file
00100                                 cachedFile.close();
00101                                 return 1;
00102                         }
00103 
00104 #ifdef USE_CURL
00105                         CURL *h = curl_easy_init();
00106                         CURLcode result;
00107 
00108                         target = std::string();
00109 
00110                         curl_easy_setopt(h, CURLOPT_URL, url.c_str());
00111                         curl_easy_setopt(h, CURLOPT_WRITEFUNCTION, CurlCallback);
00112                         curl_easy_setopt(h, CURLOPT_WRITEDATA, &target);
00113 #ifdef WIN32
00114                         curl_easy_setopt(h, CURLOPT_TIMEOUT, 5);
00115 #endif
00116 
00117                         ILOG_DEBUG("Retrieving remote: " << url);
00118                         result = curl_easy_perform(h);
00119 
00120                         if (result == CURLE_OK) {
00121                                 ILOG_DEBUG("retrieved " << target.size() << ", trying decode...");
00122 
00123                                 if(toCache) {
00124 #ifdef USE_BOOST_THREAD
00125                                         boost::mutex::scoped_lock lock(RemoteRetriever::GetInstance()->mutex_cache);
00126 #endif
00127                                         std::ofstream cachedFile(filename.c_str(), std::ios::binary | std::ios::out);
00128                                         cachedFile << target;
00129                                         cachedFile.close();
00130                                 } else {
00131                                 }
00132                                 curl_easy_cleanup(h);
00133                                 return 1;
00134                         }
00135                         curl_easy_cleanup(h);
00136                         ILOG_ERROR("Could not retrieve URI: " << url);
00137                         return 0;
00138 #else
00139                         ILOG_ERROR("Network retrieval of files not compiled in this version.");
00140                         return 0;
00141 #endif
00142                 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:44:34 2010 for ImpalaSrc by  doxygen 1.5.1