bool CFileCurl::GetMimeType(const CURL &url, CStdString &content, CStdString useragent) { /* 歌方: 1、 卦指: 1、 傍苧: 1、 */ CFileCurl file; if (!useragent.IsEmpty()) file.SetUserAgent(useragent); if( file.Stat(url, NULL) == 0 ) { content = file.GetMimeType(); CLog::Log(LOGDEBUG, "CFileCurl::GetMimeType - %s -> %s", url.Get().c_str(), content.c_str()); return true; } CLog::Log(LOGDEBUG, "CFileCurl::GetMimeType - %s -> failed", url.Get().c_str()); content = ""; return false; }
/* STATIC FUNCTIONS */ bool CFileCurl::GetHttpHeader(const CURL &url, CHttpHeader &headers) { /* 歌方: 1、 卦指: 1、 傍苧: 1、 */ try { CFileCurl file; if(file.Stat(url, NULL) == 0) { headers = file.GetHttpHeader(); return true; } return false; } catch(...) { CLog::Log(LOGERROR, "%s - Exception thrown while trying to retrieve header url: %s", __FUNCTION__, url.Get().c_str()); return false; } }
bool CHTTPDirectory::Exists(const char* strPath) { CFileCurl http; CURL url(strPath); struct __stat64 buffer; if( http.Stat(url, &buffer) != 0 ) { return false; } if (buffer.st_mode == _S_IFDIR) return true; return false; }
/* STATIC FUNCTIONS */ bool CFileCurl::GetHttpHeader(const CURI &url, CHttpHeader &headers) { try { CFileCurl file; if(file.Stat(url, NULL) == 0) { headers = file.GetHttpHeader(); return true; } return false; } catch(...) { CStdString path; path = url.Get(); CLog::Log(LOGERROR, "%s - Exception thrown while trying to retrieve header url: %s", __FUNCTION__, path.c_str()); return false; } }
bool CFileCurl::GetMimeType(const CURL &url, CStdString &content, CStdString useragent) { CFileCurl file; if (!useragent.IsEmpty()) file.SetUserAgent(useragent); struct __stat64 buffer; if( file.Stat(url, &buffer) == 0 ) { if (buffer.st_mode == _S_IFDIR) content = "x-directory/normal"; else content = file.GetMimeType(); CLog::Log(LOGDEBUG, "CFileCurl::GetMimeType - %s -> %s", url.Get().c_str(), content.c_str()); return true; } CLog::Log(LOGDEBUG, "CFileCurl::GetMimeType - %s -> failed", url.Get().c_str()); content = ""; return false; }
bool CFileCurl::GetContent(const CURI &url, CStdString &content, CStdString useragent) { CFileCurl file; if (!useragent.IsEmpty()) file.SetUserAgent(useragent); if( file.Stat(url, NULL) == 0 ) { content = file.GetContent(); return true; } if (file.GetLastRetCode() > 400 ) { content = "text/html"; } else { content = ""; } return false; }