diff --git a/ChangeLog b/ChangeLog index 5db838a3a..4b25e781f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-05-14 Tatsuhiro Tsujikawa + + Use A2STR::SLASH_C, A2STR::DOT_C instead of "/", "." respectively. + * src/A2STR.cc + * src/A2STR.h + * src/File.cc + 2008-05-14 Tatsuhiro Tsujikawa Defined static const std::string IP("ip"), PORT("port") and use them diff --git a/src/A2STR.cc b/src/A2STR.cc index 061940da8..7ac4817c2 100644 --- a/src/A2STR.cc +++ b/src/A2STR.cc @@ -46,4 +46,6 @@ const std::string A2STR::LF_C("\n"); const std::string A2STR::SLASH_C("/"); +const std::string A2STR::DOT_C("."); + } // namespace aria2 diff --git a/src/A2STR.h b/src/A2STR.h index f25877cf1..f59a91084 100644 --- a/src/A2STR.h +++ b/src/A2STR.h @@ -52,6 +52,8 @@ public: static const std::string LF_C; static const std::string SLASH_C; + + static const std::string DOT_C; }; } // namespace aria2 diff --git a/src/File.cc b/src/File.cc index afe49bbc0..9bc57bf20 100644 --- a/src/File.cc +++ b/src/File.cc @@ -104,11 +104,11 @@ bool File::mkdirs() { } std::string accDir; - if(Util::startsWith(name, "/")) { - accDir = "/"; + if(Util::startsWith(name, A2STR::SLASH_C)) { + accDir = A2STR::SLASH_C; } for(std::deque::const_iterator itr = dirs.begin(); itr != dirs.end(); - itr++, accDir += "/") { + itr++, accDir += A2STR::SLASH_C) { accDir += *itr; if(File(accDir).isDir()) { continue; @@ -131,7 +131,7 @@ mode_t File::mode() std::string File::getBasename() const { - std::string::size_type lastSlashIndex = name.find_last_of("/"); + std::string::size_type lastSlashIndex = name.find_last_of(A2STR::SLASH_C); if(lastSlashIndex == std::string::npos) { return name; } else { @@ -141,15 +141,15 @@ std::string File::getBasename() const std::string File::getDirname() const { - std::string::size_type lastSlashIndex = name.find_last_of("/"); + std::string::size_type lastSlashIndex = name.find_last_of(A2STR::SLASH_C); if(lastSlashIndex == std::string::npos) { if(name.empty()) { return A2STR::NIL; } else { - return "."; + return A2STR::DOT_C; } } else if(lastSlashIndex == 0) { - return "/"; + return A2STR::SLASH_C; } else { return name.substr(0, lastSlashIndex); }