ART: Unlink old file in OS::CreateEmptyFile
Update the documentation to make clear that a new file is expected
to be returned. A potentially existing file will not be reused
(and cleared).
Bug: 22047255
Change-Id: I0eb8601c7696d6f7b81547abcc06ff605826dc26
diff --git a/runtime/os_linux.cc b/runtime/os_linux.cc
index 2282789..675699d 100644
--- a/runtime/os_linux.cc
+++ b/runtime/os_linux.cc
@@ -36,6 +36,10 @@
}
File* OS::CreateEmptyFile(const char* name) {
+ // In case the file exists, unlink it so we get a new file. This is necessary as the previous
+ // file may be in use and must not be changed.
+ unlink(name);
+
return OpenFileWithFlags(name, O_RDWR | O_CREAT | O_TRUNC);
}