From e5ae916071a4e8467d7649a5cc700ca7310b6b69 Mon Sep 17 00:00:00 2001 From: Evan Martin Date: Fri, 7 Jan 2011 11:51:24 -0800 Subject: reread previous log on startup --- src/build_log.cc | 2 ++ src/ninja.cc | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/build_log.cc b/src/build_log.cc index 06db0e6..ba09b46 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -52,6 +52,8 @@ void BuildLog::Close() { bool BuildLog::Load(const string& path, string* err) { FILE* file = fopen(path.c_str(), "r"); if (!file) { + if (errno == ENOENT) + return true; *err = strerror(errno); return false; } diff --git a/src/ninja.cc b/src/ninja.cc index f88e2b9..a39ff5c 100644 --- a/src/ninja.cc +++ b/src/ninja.cc @@ -90,9 +90,17 @@ int main(int argc, char** argv) { return 0; } + const char* kLogPath = "ninja_log"; BuildLog log; - if (!log.OpenForWrite("ninja_log", &err)) + if (!log.Load(kLogPath, &err)) { + fprintf(stderr, "error loading build log: %s\n", err.c_str()); return 1; + } + + if (!log.OpenForWrite(kLogPath, &err)) { + fprintf(stderr, "error opening build log: %s\n", err.c_str()); + return 1; + } config.build_log = &log; Builder builder(&state, config); -- cgit v0.12