diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-05-26 15:28:48 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-05-26 15:28:48 +0000 |
| commit | 41df4b5e2801a6bb960dcc27b43af46bf6a7010f (patch) | |
| tree | b26a98badecae6f189b405bd08fff5de2244062e /src | |
| parent | 544732b124335cac5a390634da04d2ef63becd88 (diff) | |
2009-05-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use name.utf-8 and path.utf-8 key in higher priority than name and
path key respectively when persing .torrent file.
* src/BtContext.cc
* src/BtContext.h
* src/DefaultBtContext.cc
* test/DefaultBtContextTest.cc
* test/utf8.torrent
Diffstat (limited to 'src')
| -rw-r--r-- | src/BtContext.cc | 4 | ||||
| -rw-r--r-- | src/BtContext.h | 4 | ||||
| -rw-r--r-- | src/DefaultBtContext.cc | 16 |
3 files changed, 22 insertions, 2 deletions
diff --git a/src/BtContext.cc b/src/BtContext.cc index 4d306041..ee6a896a 100644 --- a/src/BtContext.cc +++ b/src/BtContext.cc @@ -38,12 +38,16 @@ namespace aria2 { const std::string BtContext::C_NAME("name"); +const std::string BtContext::C_NAME_UTF8("name.utf-8"); + const std::string BtContext::C_FILES("files"); const std::string BtContext::C_LENGTH("length"); const std::string BtContext::C_PATH("path"); +const std::string BtContext::C_PATH_UTF8("path.utf-8"); + const std::string BtContext::C_INFO("info"); const std::string BtContext::C_PIECES("pieces"); diff --git a/src/BtContext.h b/src/BtContext.h index 606707c7..ffe66739 100644 --- a/src/BtContext.h +++ b/src/BtContext.h @@ -90,12 +90,16 @@ public: static const std::string C_NAME; + static const std::string C_NAME_UTF8; + static const std::string C_FILES; static const std::string C_LENGTH; static const std::string C_PATH; + static const std::string C_PATH_UTF8; + static const std::string C_INFO; static const std::string C_PIECES; diff --git a/src/DefaultBtContext.cc b/src/DefaultBtContext.cc index 7b5613aa..8df1aaf1 100644 --- a/src/DefaultBtContext.cc +++ b/src/DefaultBtContext.cc @@ -117,7 +117,13 @@ void DefaultBtContext::extractFileEntries(const BDE& infoDict, const std::deque<std::string>& urlList) { if(overrideName.empty()) { - const BDE& nameData = infoDict[BtContext::C_NAME]; + std::string nameKey; + if(infoDict.containsKey(BtContext::C_NAME_UTF8)) { + nameKey = BtContext::C_NAME_UTF8; + } else { + nameKey = BtContext::C_NAME; + } + const BDE& nameData = infoDict[nameKey]; if(nameData.isString()) { name = nameData.s(); } else { @@ -146,7 +152,13 @@ void DefaultBtContext::extractFileEntries(const BDE& infoDict, } length += fileLengthData.i(); - const BDE& pathList = fileDict[BtContext::C_PATH]; + std::string pathKey; + if(fileDict.containsKey(BtContext::C_PATH_UTF8)) { + pathKey = BtContext::C_PATH_UTF8; + } else { + pathKey = BtContext::C_PATH; + } + const BDE& pathList = fileDict[pathKey]; if(!pathList.isList() || pathList.empty()) { throw DL_ABORT_EX("Path is empty."); } |
