summaryrefslogtreecommitdiff
path: root/src/ProtocolDetector.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-06-08 12:07:17 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-06-08 12:07:17 +0000
commitb4e5ba2779e2f6230a6db69553e6e459f94efd7d (patch)
tree0a2dae37e2b9414439d1929f9a93199eb9e85ce9 /src/ProtocolDetector.cc
parent2ad5df249ea835e14981ca84643b1bd23d037253 (diff)
2008-06-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed the bug that aria2 aborts when a path to a directory is given in command-line. * src/ProtocolDetector.cc
Diffstat (limited to 'src/ProtocolDetector.cc')
-rw-r--r--src/ProtocolDetector.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ProtocolDetector.cc b/src/ProtocolDetector.cc
index 9a01736f..ee743c65 100644
--- a/src/ProtocolDetector.cc
+++ b/src/ProtocolDetector.cc
@@ -34,6 +34,7 @@
/* copyright --> */
#include "ProtocolDetector.h"
#include "Request.h"
+#include "File.h"
#include <cstring>
#include <fstream>
#include <iomanip>
@@ -51,6 +52,9 @@ bool ProtocolDetector::isStreamProtocol(const std::string& uri) const
bool ProtocolDetector::guessTorrentFile(const std::string& uri) const
{
+ if(!File(uri).isFile()) {
+ return false;
+ }
std::ifstream in(uri.c_str());
if(in) {
char head;
@@ -63,6 +67,9 @@ bool ProtocolDetector::guessTorrentFile(const std::string& uri) const
bool ProtocolDetector::guessMetalinkFile(const std::string& uri) const
{
+ if(!File(uri).isFile()) {
+ return false;
+ }
std::ifstream in(uri.c_str());
if(in) {
char head[6];