diff options
author | Philip Craig <philip@pobox.com> | 2011-04-23 10:36:49 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2011-04-23 21:31:47 (GMT) |
commit | 98bb8487f62e55aed311fc36ce371884c1344764 (patch) | |
tree | 4918c391cabccac27159f31d9d75c0f3a3e56b47 | |
parent | ad78e41b85a936e5d2aa3630db3f4815af257254 (diff) | |
download | Ninja-98bb8487f62e55aed311fc36ce371884c1344764.zip Ninja-98bb8487f62e55aed311fc36ce371884c1344764.tar.gz Ninja-98bb8487f62e55aed311fc36ce371884c1344764.tar.bz2 |
Close() and unlink() files in ways that make Windows happy
This will make the build log compaction work on Windows.
It will also make the tests no longer leave a temp log file around.
-rw-r--r-- | src/build_log.cc | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/build_log.cc b/src/build_log.cc index 9add945..6943550 100644 --- a/src/build_log.cc +++ b/src/build_log.cc @@ -37,6 +37,7 @@ bool BuildLog::OpenForWrite(const string& path, string* err) { return true; // Do nothing, report success. if (needs_recompaction_) { + Close(); if (!Recompact(path, err)) return false; } @@ -129,6 +130,8 @@ bool BuildLog::Load(const string& path, string* err) { if (total_entry_count > unique_entry_count * kCompactionRatio) needs_recompaction_ = true; + fclose(file); + return true; } @@ -159,6 +162,10 @@ bool BuildLog::Recompact(const string& path, string* err) { } fclose(f); + if (unlink(path.c_str()) < 0) { + *err = strerror(errno); + return false; + } if (rename(temp_path.c_str(), path.c_str()) < 0) { *err = strerror(errno); |