Bläddra i källkod

2009-07-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Don't append "/" if base URI ends with "/".
	* src/bittorrent_helper.cc
	* test/url-list-multiFile.torrent
Tatsuhiro Tsujikawa 16 år sedan
förälder
incheckning
30b65f79e7
3 ändrade filer med 23 tillägg och 3 borttagningar
  1. 6 0
      ChangeLog
  2. 16 2
      src/bittorrent_helper.cc
  3. 1 1
      test/url-list-multiFile.torrent

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2009-07-01  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Don't append "/" if base URI ends with "/".
+	* src/bittorrent_helper.cc
+	* test/url-list-multiFile.torrent
+
 2009-07-01  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	HTTP pipelining is now working. Fixed Segmention fault in

+ 16 - 2
src/bittorrent_helper.cc

@@ -134,6 +134,21 @@ static void extractUrlList(std::vector<std::string>& uris, const BDE& bde)
   }
 }
 
+template<typename InputIterator, typename OutputIterator>
+static OutputIterator createUri
+(InputIterator first, InputIterator last, OutputIterator out,
+ const std::string& filePath)
+{
+  for(; first != last; ++first) {
+    if(Util::endsWith(*first, "/")) {
+      *out++ = (*first)+filePath;
+    } else {
+      *out++ = (*first)+"/"+filePath;
+    }
+  }
+  return out;
+}
+
 static void extractFileEntries
 (const SharedHandle<DownloadContext>& ctx,
  BDE& torrent,
@@ -209,8 +224,7 @@ static void extractFileEntries
       path = Util::joinPath(elements.begin(), elements.end());
 
       std::deque<std::string> uris;
-      std::transform(urlList.begin(), urlList.end(), std::back_inserter(uris),
-		     std::bind2nd(std::plus<std::string>(), "/"+path));
+      createUri(urlList.begin(), urlList.end(), std::back_inserter(uris), path);
       SharedHandle<FileEntry> fileEntry
 	(new FileEntry(strconcat(ctx->getDir(), "/", path),
 		       fileLengthData.i(),

+ 1 - 1
test/url-list-multiFile.torrent

@@ -1 +1 @@
-d8:url-listl21:http://localhost/dist18:http://mirror/diste8:announce36:http://aria.rednoah.com/announce.php13:announce-listll15:http://tracker1el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee
+d8:url-listl22:http://localhost/dist/18:http://mirror/diste8:announce36:http://aria.rednoah.com/announce.php13:announce-listll15:http://tracker1el15:http://tracker2el15:http://tracker3ee7:comment17:REDNOAH.COM RULES13:creation datei1123456789e4:infod5:filesld6:lengthi284e4:pathl5:aria23:src6:aria2ceed6:lengthi100e4:pathl19:aria2-0.2.2.tar.bz2eee4:name10:aria2-test12:piece lengthi128e6:pieces60:AAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCee