Add std::string StartsWith*/EndsWith* overloads.
We should have done this from the beginning. Thanks to Windows, we're not
going to be able to switch libbase over to std::string_view any time soon.
Bug: N/A
Test: ran tests
Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
diff --git a/init/devices.cpp b/init/devices.cpp
index af6b50a..8d27f4f 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -127,7 +127,7 @@
}
bool Permissions::Match(const std::string& path) const {
- if (prefix_) return StartsWith(path, name_.c_str());
+ if (prefix_) return StartsWith(path, name_);
if (wildcard_) return fnmatch(name_.c_str(), path.c_str(), FNM_PATHNAME) == 0;
return path == name_;
}
@@ -300,9 +300,9 @@
static const std::string devices_platform_prefix = "/devices/platform/";
static const std::string devices_prefix = "/devices/";
- if (StartsWith(device, devices_platform_prefix.c_str())) {
+ if (StartsWith(device, devices_platform_prefix)) {
device = device.substr(devices_platform_prefix.length());
- } else if (StartsWith(device, devices_prefix.c_str())) {
+ } else if (StartsWith(device, devices_prefix)) {
device = device.substr(devices_prefix.length());
}