Merge "Revert "Revert "Remove unused String8::setPathName.""" am: f9a9ee048c

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1771595

Change-Id: I6e76b9168f922dc71296582880c817fcc577995a
This commit is contained in:
Treehugger Robot 2021-07-20 19:53:09 +00:00 committed by Automerger Merge Worker
commit e9a9a4f071
3 changed files with 7 additions and 26 deletions

View file

@ -429,24 +429,17 @@ void String8::toLower()
// ---------------------------------------------------------------------------
// Path functions
void String8::setPathName(const char* name)
{
setPathName(name, strlen(name));
}
void String8::setPathName(const char* name, size_t len)
{
char* buf = lockBuffer(len);
static void setPathName(String8& s, const char* name) {
size_t len = strlen(name);
char* buf = s.lockBuffer(len);
memcpy(buf, name, len);
// remove trailing path separator, if present
if (len > 0 && buf[len-1] == OS_PATH_SEPARATOR)
len--;
if (len > 0 && buf[len - 1] == OS_PATH_SEPARATOR) len--;
buf[len] = '\0';
unlockBuffer(len);
s.unlockBuffer(len);
}
String8 String8::getPathLeaf(void) const
@ -559,7 +552,7 @@ String8& String8::appendPath(const char* name)
size_t len = length();
if (len == 0) {
// no existing filename, just use the new one
setPathName(name);
setPathName(*this, name);
return *this;
}
@ -579,7 +572,7 @@ String8& String8::appendPath(const char* name)
return *this;
} else {
setPathName(name);
setPathName(*this, name);
return *this;
}
}

View file

@ -89,10 +89,6 @@ std::vector<std::function<void(FuzzedDataProvider*, android::String8*, android::
str1->walkPath(path_out_str.get());
path_out_str->clear();
},
[](FuzzedDataProvider* dataProvider, android::String8* str1,
android::String8*) -> void {
str1->setPathName(dataProvider->ConsumeBytesWithTerminator<char>(5).data());
},
[](FuzzedDataProvider* dataProvider, android::String8* str1,
android::String8*) -> void {
str1->appendPath(dataProvider->ConsumeBytesWithTerminator<char>(5).data());

View file

@ -136,14 +136,6 @@ public:
* These methods operate on the string as if it were a path name.
*/
/*
* Set the filename field to a specific value.
*
* Normalizes the filename, removing a trailing '/' if present.
*/
void setPathName(const char* name);
void setPathName(const char* name, size_t numChars);
/*
* Get just the filename component.
*