Merge "Revert "Revert "Remove unused String8::setPathName.""" am: f9a9ee048c am: e9a9a4f071
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1771595 Change-Id: I815e30f78c4a129de8186bd1b08278024fdf01d6
This commit is contained in:
commit
f34b2446bb
3 changed files with 7 additions and 26 deletions
|
|
@ -431,24 +431,17 @@ void String8::toLower()
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Path functions
|
// Path functions
|
||||||
|
|
||||||
void String8::setPathName(const char* name)
|
static void setPathName(String8& s, const char* name) {
|
||||||
{
|
size_t len = strlen(name);
|
||||||
setPathName(name, strlen(name));
|
char* buf = s.lockBuffer(len);
|
||||||
}
|
|
||||||
|
|
||||||
void String8::setPathName(const char* name, size_t len)
|
|
||||||
{
|
|
||||||
char* buf = lockBuffer(len);
|
|
||||||
|
|
||||||
memcpy(buf, name, len);
|
memcpy(buf, name, len);
|
||||||
|
|
||||||
// remove trailing path separator, if present
|
// remove trailing path separator, if present
|
||||||
if (len > 0 && buf[len-1] == OS_PATH_SEPARATOR)
|
if (len > 0 && buf[len - 1] == OS_PATH_SEPARATOR) len--;
|
||||||
len--;
|
|
||||||
|
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
unlockBuffer(len);
|
s.unlockBuffer(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
String8 String8::getPathLeaf(void) const
|
String8 String8::getPathLeaf(void) const
|
||||||
|
|
@ -561,7 +554,7 @@ String8& String8::appendPath(const char* name)
|
||||||
size_t len = length();
|
size_t len = length();
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
// no existing filename, just use the new one
|
// no existing filename, just use the new one
|
||||||
setPathName(name);
|
setPathName(*this, name);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -581,7 +574,7 @@ String8& String8::appendPath(const char* name)
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
} else {
|
} else {
|
||||||
setPathName(name);
|
setPathName(*this, name);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,10 +89,6 @@ std::vector<std::function<void(FuzzedDataProvider*, android::String8*, android::
|
||||||
str1->walkPath(path_out_str.get());
|
str1->walkPath(path_out_str.get());
|
||||||
path_out_str->clear();
|
path_out_str->clear();
|
||||||
},
|
},
|
||||||
[](FuzzedDataProvider* dataProvider, android::String8* str1,
|
|
||||||
android::String8*) -> void {
|
|
||||||
str1->setPathName(dataProvider->ConsumeBytesWithTerminator<char>(5).data());
|
|
||||||
},
|
|
||||||
[](FuzzedDataProvider* dataProvider, android::String8* str1,
|
[](FuzzedDataProvider* dataProvider, android::String8* str1,
|
||||||
android::String8*) -> void {
|
android::String8*) -> void {
|
||||||
str1->appendPath(dataProvider->ConsumeBytesWithTerminator<char>(5).data());
|
str1->appendPath(dataProvider->ConsumeBytesWithTerminator<char>(5).data());
|
||||||
|
|
|
||||||
|
|
@ -136,14 +136,6 @@ public:
|
||||||
* These methods operate on the string as if it were a path name.
|
* 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.
|
* Get just the filename component.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue