mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-23 09:19:55 +00:00
COMMON: Add Path::numComponents() method
This commit is contained in:
parent
43a90ba922
commit
c6daf24573
@ -405,6 +405,27 @@ String Path::baseName() const {
|
||||
return unescape(kNoSeparator, begin, end);
|
||||
}
|
||||
|
||||
int Path::numComponents() const {
|
||||
if (_str.empty())
|
||||
return 0;
|
||||
|
||||
const char *str = _str.c_str();
|
||||
|
||||
if (isEscaped())
|
||||
str++;
|
||||
|
||||
int num = 1;
|
||||
|
||||
const char *sep = strchr(str, SEPARATOR);
|
||||
while (sep) {
|
||||
str = sep + 1;
|
||||
sep = strchr(str, SEPARATOR);
|
||||
num++;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
Path &Path::appendInPlace(const Path &x) {
|
||||
if (x._str.empty()) {
|
||||
return *this;
|
||||
|
@ -304,6 +304,11 @@ public:
|
||||
*/
|
||||
String baseName() const;
|
||||
|
||||
/**
|
||||
* Returns number of components in this path,
|
||||
*/
|
||||
int numComponents() const;
|
||||
|
||||
/** Check whether this path is identical to path @p x. */
|
||||
bool operator==(const Path &x) const {
|
||||
return _str == x._str;
|
||||
|
Loading…
Reference in New Issue
Block a user