2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Use A2STR::SLASH_C, A2STR::DOT_C instead of "/", "." 
respectively.
	* src/A2STR.cc
	* src/A2STR.h
	* src/File.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-05-14 12:28:46 +00:00
parent 1aeefb5c4b
commit 1b874503cf
4 changed files with 18 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use A2STR::SLASH_C, A2STR::DOT_C instead of "/", "." respectively.
* src/A2STR.cc
* src/A2STR.h
* src/File.cc
2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Defined static const std::string IP("ip"), PORT("port") and use them

View File

@ -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

View File

@ -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

View File

@ -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<std::string>::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);
}