summaryrefslogtreecommitdiffstats
path: root/src/stat_cache.cc
diff options
context:
space:
mode:
authorThiago Farina <tfransosi@gmail.com>2011-05-31 16:36:23 (GMT)
committerEvan Martin <martine@danga.com>2011-05-31 16:39:45 (GMT)
commit2e173199dfb36de2843722664607160e397846dd (patch)
tree9dae69fd7207beb613aef2e40cacd592ec2b7a7e /src/stat_cache.cc
parent0d4c9611aa6f8958cc2c7bf4355f46945d09c1a4 (diff)
downloadNinja-2e173199dfb36de2843722664607160e397846dd.zip
Ninja-2e173199dfb36de2843722664607160e397846dd.tar.gz
Ninja-2e173199dfb36de2843722664607160e397846dd.tar.bz2
ninja: Split StatCache struct into its own header file.
Note: This is a TODO in ninja_jumble.cc. Signed-off-by: Thiago Farina <tfarina@chromium.org>
Diffstat (limited to 'src/stat_cache.cc')
-rw-r--r--src/stat_cache.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/stat_cache.cc b/src/stat_cache.cc
new file mode 100644
index 0000000..bdf20a8
--- /dev/null
+++ b/src/stat_cache.cc
@@ -0,0 +1,38 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "stat_cache.h"
+
+#include <stdio.h>
+
+#include "graph.h"
+
+FileStat* StatCache::GetFile(const std::string& path) {
+ Paths::iterator i = paths_.find(path);
+ if (i != paths_.end())
+ return i->second;
+ FileStat* file = new FileStat(path);
+ paths_[path] = file;
+ return file;
+}
+
+void StatCache::Dump() {
+ for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) {
+ FileStat* file = i->second;
+ printf("%s %s\n",
+ file->path_.c_str(),
+ file->status_known() ? (file->node_->dirty_ ? "dirty" : "clean")
+ : "unknown");
+ }
+}