/* */ #include "ProtocolDetector.h" #include "Request.h" #include "File.h" #include #include #include namespace aria2 { ProtocolDetector::ProtocolDetector() {} ProtocolDetector::~ProtocolDetector() {} bool ProtocolDetector::isStreamProtocol(const std::string& uri) const { return Request().setUrl(uri); } bool ProtocolDetector::guessTorrentFile(const std::string& uri) const { if(!File(uri).isFile()) { return false; } std::ifstream in(uri.c_str(), std::ios::binary); if(in) { char head; in >> head; return head == 'd'; } else { return false; } } bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const { if(!File(uri).isFile()) { return false; } std::ifstream in(uri.c_str(), std::ios::binary); if(in) { char head[6]; in >> std::setw(6) >> head; return strcmp(head, "