From 0bdd20e6fcc9a1e88911a7620038007325460660 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 12 Jun 2010 09:17:48 +0000 Subject: [PATCH] 2010-06-12 Tatsuhiro Tsujikawa Renamed member variables. * src/File.cc * src/File.h --- ChangeLog | 6 ++++++ src/File.cc | 30 +++++++++++++++--------------- src/File.h | 4 ++-- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4a68b7c1..caf700da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-06-12 Tatsuhiro Tsujikawa + + Renamed member variables. + * src/File.cc + * src/File.h + 2010-06-12 Tatsuhiro Tsujikawa Made protected member variable private. Added accessor funcs. diff --git a/src/File.cc b/src/File.cc index fcd9c27a..d22f37ee 100644 --- a/src/File.cc +++ b/src/File.cc @@ -54,12 +54,12 @@ namespace aria2 { # include #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 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::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() diff --git a/src/File.h b/src/File.h index 68260fb8..7890519a 100644 --- a/src/File.h +++ b/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);