Changeset 62d0677c34ce…
Parent 7658c2335d00…
by
Changes to one file · Browse files at 62d0677c34ce Showing diff from parent 7658c2335d00 Diff from another changeset...
@@ -100,9 +100,13 @@
DirsT subdirs_;
FilesT files_;
+
+ unsigned tickcount_;
+ char status_;
public:
- Directory(Directory* p, const std::string& n): parent_(p), name_(n) {}
+ Directory(Directory* p, const std::string& n):
+ parent_(p), name_(n), tickcount_(0), status_(-1) {}
~Directory();
std::string path(const std::string& n = "") const;
@@ -115,6 +119,9 @@ char status(const std::string& hgroot);
void print() const;
+
+private:
+ char status_imp(const std::string& hgroot);
};
@@ -126,6 +133,7 @@ }
}
+
int splitbase(const std::string& n, std::string& base, std::string& rest)
{
if (n.empty())
@@ -258,13 +266,13 @@}
-char Directory::status(const std::string& hgroot)
+char Directory::status_imp(const std::string& hgroot)
{
bool added = false;
for (DirsT::iterator i = subdirs_.begin(); i != subdirs_.end(); ++i)
{
- char s = (*i)->status(hgroot);
+ char s = (*i)->status_imp(hgroot);
if (s == 'M')
return 'M';
if (s == 'A')
@@ -279,7 +287,8 @@
if (0 != lstat(p.c_str(), stat))
{
- TDEBUG_TRACE("Directory(" << path() << ")::status: lstat(" << p << ") failed");
+ TDEBUG_TRACE("Directory(" << path()
+ << ")::status_imp: lstat(" << p << ") failed");
continue;
}
@@ -298,6 +307,23 @@}
+char Directory::status(const std::string& hgroot)
+{
+ if (status_ != -1)
+ {
+ unsigned tc = GetTickCount();
+ if (tc - tickcount_ < 3000) {
+ return status_;
+ }
+ }
+
+ status_ = status_imp(hgroot);
+ tickcount_ = GetTickCount();
+
+ return status_;
+}
+
+
void Directory::print() const
{
for (DirsT::const_iterator i = subdirs_.begin(); i != subdirs_.end(); ++i)
|
Loading...