Browse Source

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
Tatsuhiro Tsujikawa 17 years ago
parent
commit
b4e5ba2779
2 changed files with 13 additions and 0 deletions
  1. 6 0
      ChangeLog
  2. 7 0
      src/ProtocolDetector.cc

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+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
+	
 2008-06-08  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Limited the number files opened in each BitTorrent download. The default

+ 7 - 0
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];