瀏覽代碼

2010-06-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Renamed member variables.
	* src/File.cc
	* src/File.h
Tatsuhiro Tsujikawa 15 年之前
父節點
當前提交
0bdd20e6fc
共有 3 個文件被更改,包括 23 次插入17 次删除
  1. 6 0
      ChangeLog
  2. 15 15
      src/File.cc
  3. 2 2
      src/File.h

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2010-06-12  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Renamed member variables.
+	* src/File.cc
+	* src/File.h
+
 2010-06-12  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Made protected member variable private. Added accessor funcs.

+ 15 - 15
src/File.cc

@@ -54,12 +54,12 @@ namespace aria2 {
 # include <windows.h>
 #endif // __MINGW32__
 
-File::File(const std::string& name):name(name) {}
+File::File(const std::string& name):_name(name) {}
 
 File::~File() {}
 
 int File::fillStat(a2_struct_stat& fstat) {
-  return a2stat(name.c_str(), &fstat);
+  return a2stat(_name.c_str(), &fstat);
 }
 
 bool File::exists() {
@@ -85,9 +85,9 @@ bool File::isDir() {
 
 bool File::remove() {
   if(isFile()) {
-    return unlink(name.c_str()) == 0;
+    return unlink(_name.c_str()) == 0;
   } else if(isDir()) {
-    return rmdir(name.c_str()) == 0;
+    return rmdir(_name.c_str()) == 0;
   } else {
     return false;
   }
@@ -106,13 +106,13 @@ bool File::mkdirs() {
     return false;
   }
   std::vector<std::string> dirs;
-  util::split(name, std::back_inserter(dirs), "/");
+  util::split(_name, std::back_inserter(dirs), "/");
   if(!dirs.size()) {
     return true;
   }
 
   std::string accDir;
-  if(util::startsWith(name, A2STR::SLASH_C)) {
+  if(util::startsWith(_name, A2STR::SLASH_C)) {
     accDir = A2STR::SLASH_C;
   }
   for(std::vector<std::string>::const_iterator itr = dirs.begin(),
@@ -139,19 +139,19 @@ mode_t File::mode()
 
 std::string File::getBasename() const
 {
-  std::string::size_type lastSlashIndex = name.find_last_of(A2STR::SLASH_C);
+  std::string::size_type lastSlashIndex = _name.find_last_of(A2STR::SLASH_C);
   if(lastSlashIndex == std::string::npos) {
-    return name;
+    return _name;
   } else {
-    return name.substr(lastSlashIndex+1);
+    return _name.substr(lastSlashIndex+1);
   }
 }
 
 std::string File::getDirname() const
 {
-  std::string::size_type lastSlashIndex = name.find_last_of(A2STR::SLASH_C);
+  std::string::size_type lastSlashIndex = _name.find_last_of(A2STR::SLASH_C);
   if(lastSlashIndex == std::string::npos) {
-    if(name.empty()) {
+    if(_name.empty()) {
       return A2STR::NIL;
     } else {
       return A2STR::DOT_C;
@@ -159,7 +159,7 @@ std::string File::getDirname() const
   } else if(lastSlashIndex == 0) {
     return A2STR::SLASH_C;
   } else {
-    return name.substr(0, lastSlashIndex);
+    return _name.substr(0, lastSlashIndex);
   }
 }
 
@@ -178,8 +178,8 @@ bool File::renameTo(const std::string& dest)
     }
   }
 #endif // __MINGW32__
-  if(rename(name.c_str(), dest.c_str()) == 0) {
-    name = dest;
+  if(rename(_name.c_str(), dest.c_str()) == 0) {
+    _name = dest;
     return true;
   } else {
     return false;
@@ -191,7 +191,7 @@ bool File::utime(const Time& actime, const Time& modtime) const
   struct utimbuf ub;
   ub.actime = actime.getTime();
   ub.modtime = modtime.getTime();
-  return ::utime(name.c_str(), &ub) == 0;
+  return ::utime(_name.c_str(), &ub) == 0;
 }
 
 Time File::getModifiedTime()

+ 2 - 2
src/File.h

@@ -49,7 +49,7 @@ namespace aria2 {
  */
 class File {
 private:
-  std::string name;
+  std::string _name;
   
   /**
    * Returns the return value of stat(...)
@@ -99,7 +99,7 @@ public:
 
   const std::string& getPath() const
   {
-    return name;
+    return _name;
   }
 
   static bool isDir(const std::string& filename);