mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-08 23:26:12 +02:00
Add strBaseZ().
Since the base name is at the end of the filename it is possible to return the char pointer without making a copy, which is preferred in some cases.
This commit is contained in:
parent
8e140ad7e0
commit
aa37a21084
@ -203,12 +203,24 @@ strBase(const String *this)
|
|||||||
|
|
||||||
ASSERT(this != NULL);
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
|
FUNCTION_TEST_RETURN(strNew(strBaseZ(this)));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
strBaseZ(const String *this)
|
||||||
|
{
|
||||||
|
FUNCTION_TEST_BEGIN();
|
||||||
|
FUNCTION_TEST_PARAM(STRING, this);
|
||||||
|
FUNCTION_TEST_END();
|
||||||
|
|
||||||
|
ASSERT(this != NULL);
|
||||||
|
|
||||||
const char *end = this->buffer + this->size;
|
const char *end = this->buffer + this->size;
|
||||||
|
|
||||||
while (end > this->buffer && *(end - 1) != '/')
|
while (end > this->buffer && *(end - 1) != '/')
|
||||||
end--;
|
end--;
|
||||||
|
|
||||||
FUNCTION_TEST_RETURN(strNew(end));
|
FUNCTION_TEST_RETURN(end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************************************************************************/
|
/**********************************************************************************************************************************/
|
||||||
|
@ -77,8 +77,10 @@ String *strDup(const String *this);
|
|||||||
/***********************************************************************************************************************************
|
/***********************************************************************************************************************************
|
||||||
Functions
|
Functions
|
||||||
***********************************************************************************************************************************/
|
***********************************************************************************************************************************/
|
||||||
// Return the file part of a string (i.e. everything after the last / or the entire string if there is no /)
|
// Return the file part of a string (i.e. everything after the last / or the entire string if there is no /). strBaseZ() does not
|
||||||
|
// make a copy of the string so it may be more appropriate for large loops where saving memory is important.
|
||||||
String *strBase(const String *this);
|
String *strBase(const String *this);
|
||||||
|
const char *strBaseZ(const String *this);
|
||||||
|
|
||||||
// Does the string begin with the specified string?
|
// Does the string begin with the specified string?
|
||||||
bool strBeginsWith(const String *this, const String *beginsWith);
|
bool strBeginsWith(const String *this, const String *beginsWith);
|
||||||
|
@ -316,7 +316,7 @@ cfgFileLoad( // NOTE: Pas
|
|||||||
if (optionList[cfgOptConfigPath].found)
|
if (optionList[cfgOptConfigPath].found)
|
||||||
{
|
{
|
||||||
optConfigDefault =
|
optConfigDefault =
|
||||||
strNewFmt("%s/%s", strPtr(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), strPtr(strBase(optConfigDefault)));
|
strNewFmt("%s/%s", strPtr(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), strBaseZ(optConfigDefault));
|
||||||
optConfigIncludePathDefault =
|
optConfigIncludePathDefault =
|
||||||
strNewFmt("%s/%s", strPtr(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), PGBACKREST_CONFIG_INCLUDE_PATH);
|
strNewFmt("%s/%s", strPtr(strLstGet(optionList[cfgOptConfigPath].valueList, 0)), PGBACKREST_CONFIG_INCLUDE_PATH);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user