Add GetExecutableDirectory to libbase
Tests will often want to get the executable directory in order to
find test data.
Test: out/host/linux-x86/nativetest64/libbase_tests/libbase_tests
Change-Id: Ica9d211bcd039fcf83a22fd494816abd01b97aa3
diff --git a/base/file.cpp b/base/file.cpp
index 32c2439..81b04d7 100644
--- a/base/file.cpp
+++ b/base/file.cpp
@@ -238,8 +238,11 @@
#endif
}
-std::string Basename(const std::string& path) {
+std::string GetExecutableDirectory() {
+ return Dirname(GetExecutablePath());
+}
+std::string Basename(const std::string& path) {
// Copy path because basename may modify the string passed in.
std::string result(path);