Browse Source

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
Tatsuhiro Tsujikawa 17 years ago
parent
commit
1b874503cf
4 changed files with 18 additions and 7 deletions
  1. 7 0
      ChangeLog
  2. 2 0
      src/A2STR.cc
  3. 2 0
      src/A2STR.h
  4. 7 7
      src/File.cc

+ 7 - 0
ChangeLog

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

+ 2 - 0
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

+ 2 - 0
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
 

+ 7 - 7
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<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);
   }