summaryrefslogtreecommitdiff
path: root/simpleperf/utils.cpp
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-06-17 22:21:12 -0700
committerYabin Cui <yabinc@google.com>2015-06-18 11:32:17 -0700
commit6afc7e17d39ab294bdf625076777443a6b4c8e18 (patch)
treebaeb99e59dac2cb3e3f25083d43debd01358acec /simpleperf/utils.cpp
parentb9408add5aea2ce30602392602948ba9c364fe6e (diff)
downloadextras-6afc7e17d39ab294bdf625076777443a6b4c8e18.tar.gz
Simpleperf: add branch stack feature in perf.data.
Also add the function to remove old perf.data. Bug: 19483574 Change-Id: I605bb637674d4674f95503a160de8c530fe87812
Diffstat (limited to 'simpleperf/utils.cpp')
-rw-r--r--simpleperf/utils.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/simpleperf/utils.cpp b/simpleperf/utils.cpp
index 5062504c..783bc8ff 100644
--- a/simpleperf/utils.cpp
+++ b/simpleperf/utils.cpp
@@ -20,6 +20,7 @@
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <base/logging.h>
@@ -66,3 +67,18 @@ void GetEntriesInDir(const std::string& dirpath, std::vector<std::string>* files
}
closedir(dir);
}
+
+bool RemovePossibleFile(const std::string& filename) {
+ struct stat st;
+ if (stat(filename.c_str(), &st) == 0) {
+ if (!S_ISREG(st.st_mode)) {
+ LOG(ERROR) << filename << " is not a file.";
+ return false;
+ }
+ if (unlink(filename.c_str()) == -1) {
+ PLOG(ERROR) << "unlink(" << filename << ") failed";
+ return false;
+ }
+ }
+ return true;
+}