Explorar o código

2009-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Use Util::pathJoin()
	* src/MetalinkParserController.cc
	* test/test.xml
Tatsuhiro Tsujikawa %!s(int64=16) %!d(string=hai) anos
pai
achega
4aae48c9b2
Modificáronse 3 ficheiros con 17 adicións e 4 borrados
  1. 6 0
      ChangeLog
  2. 10 3
      src/MetalinkParserController.cc
  3. 1 1
      test/test.xml

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2009-03-05  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Use Util::pathJoin()
+	* src/MetalinkParserController.cc
+	* test/test.xml
+	
 2009-03-05  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Use Util::pathJoin()

+ 10 - 3
src/MetalinkParserController.cc

@@ -33,6 +33,9 @@
  */
 /* copyright --> */
 #include "MetalinkParserController.h"
+
+#include <algorithm>
+
 #include "Metalinker.h"
 #include "MetalinkEntry.h"
 #include "MetalinkResource.h"
@@ -45,7 +48,7 @@
 # include "messageDigest.h"
 #endif // ENABLE_MESSAGE_DIGEST
 #include "Signature.h"
-#include <algorithm>
+#include "Util.h"
 
 namespace aria2 {
 
@@ -77,10 +80,14 @@ void MetalinkParserController::setFileNameOfEntry(const std::string& filename)
   if(_tEntry.isNull()) {
     return;
   }
+  std::deque<std::string> elements;
+  Util::slice(elements, filename, '/');
+  std::string path = Util::joinPath(elements.begin(), elements.end());
+
   if(_tEntry->file.isNull()) {
-    _tEntry->file.reset(new FileEntry(filename, 0, 0));
+    _tEntry->file.reset(new FileEntry(path, 0, 0));
   } else {
-    _tEntry->file->setPath(filename);
+    _tEntry->file->setPath(path);
   }
 }
 

+ 1 - 1
test/test.xml

@@ -28,7 +28,7 @@ fffff
         <url type="http" location="us" preference="100">http://httphost/aria2-0.5.2.tar.bz2</url>
       </resources>
     </file>
-    <file name="aria2-0.5.1.tar.bz2">
+    <file name="dir/../aria2-0.5.1.tar.bz2">
       <size>345689</size>
       <version>0.5.1</version>
       <language>ja-JP</language>