From ab42691a31128e9e05d911e2eea541e5b70a475b Mon Sep 17 00:00:00 2001 From: thunder2 Date: Tue, 21 Dec 2010 13:30:45 +0000 Subject: [PATCH] Removed unnecessary loops for debug output in CacheStrapper::loadList without debug enabled. Changed parameter of RsDirUtil::cleanupDirectory from "std::list keepFiles" to "const std::list &keepFiles". git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3925 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/dbase/cachestrapper.cc | 15 ++++++++------- libretroshare/src/util/rsdir.cc | 4 ++-- libretroshare/src/util/rsdir.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/libretroshare/src/dbase/cachestrapper.cc b/libretroshare/src/dbase/cachestrapper.cc index 8ddb0d443..6138b78e3 100644 --- a/libretroshare/src/dbase/cachestrapper.cc +++ b/libretroshare/src/dbase/cachestrapper.cc @@ -914,7 +914,10 @@ bool CacheStrapper::loadList(std::list& load) /* assemble a list of dirs to clean (union of cache dirs) */ std::list cacheDirs; - std::list::iterator dit, fit; + std::list::iterator dit; +#ifdef CS_DEBUG + std::list::iterator fit; +#endif std::map::iterator cit; for(cit = caches.begin(); cit != caches.end(); cit++) { @@ -936,18 +939,16 @@ bool CacheStrapper::loadList(std::list& load) std::cerr << "CacheStrapper::loadList() Files To Save:" << std::endl; #endif +#ifdef CS_DEBUG for(sit = saveFiles.begin(); sit != saveFiles.end(); sit++) { -#ifdef CS_DEBUG std::cerr << "CacheStrapper::loadList() Files To Save in dir: <" << sit->first << ">" << std::endl; -#endif for(fit = (sit->second).begin(); fit != (sit->second).end(); fit++) { -#ifdef CS_DEBUG std::cerr << "\tFile: " << *fit << std::endl; -#endif } } +#endif std::list emptyList; for(dit = cacheDirs.begin(); dit != cacheDirs.end(); dit++) @@ -958,12 +959,12 @@ bool CacheStrapper::loadList(std::list& load) sit = saveFiles.find(*dit); if (sit != saveFiles.end()) { +#ifdef CS_DEBUG for(fit = (sit->second).begin(); fit != (sit->second).end(); fit++) { -#ifdef CS_DEBUG std::cerr << "CacheStrapper::loadList() Keeping File: " << *fit << std::endl; -#endif } +#endif RsDirUtil::cleanupDirectory(*dit, sit->second); } else diff --git a/libretroshare/src/util/rsdir.cc b/libretroshare/src/util/rsdir.cc index 10a1316e9..54713cf1a 100644 --- a/libretroshare/src/util/rsdir.cc +++ b/libretroshare/src/util/rsdir.cc @@ -534,7 +534,7 @@ bool RsDirUtil::checkCreateDirectory(const std::string& dir) //#include //#include -bool RsDirUtil::cleanupDirectory(const std::string& cleandir, std::list keepFiles) +bool RsDirUtil::cleanupDirectory(const std::string& cleandir, const std::list &keepFiles) { /* check for the dir existance */ @@ -552,7 +552,7 @@ bool RsDirUtil::cleanupDirectory(const std::string& cleandir, std::list d_name; + const std::string &fname = dent -> d_name; std::string fullname = cleandir + "/" + fname; if (-1 != stat(fullname.c_str(), &buf)) diff --git a/libretroshare/src/util/rsdir.h b/libretroshare/src/util/rsdir.h index 1651c6100..bafa37b41 100644 --- a/libretroshare/src/util/rsdir.h +++ b/libretroshare/src/util/rsdir.h @@ -63,7 +63,7 @@ bool copyFile(const std::string& source,const std::string& dest); bool checkFile(const std::string& filename); bool checkDirectory(const std::string& dir); bool checkCreateDirectory(const std::string& dir); -bool cleanupDirectory(const std::string& dir, std::list keepFiles); +bool cleanupDirectory(const std::string& dir, const std::list &keepFiles); bool hashFile(const std::string& filepath, std::string &name, std::string &hash, uint64_t &size);