mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-09-21 20:06:40 +00:00
Remove CStr::Right
It was only a wrapper around `std::string::substr`. The interface matches the usecase more. In some places it's better to use `std::string::ends_with`.
This commit is contained in:
@@ -293,13 +293,6 @@ CStr CStr::UpperCase() const
|
||||
return newStr;
|
||||
}
|
||||
|
||||
// Retrieve the substring of the last n characters
|
||||
CStr CStr::Right(size_t len) const
|
||||
{
|
||||
ENSURE(len <= length());
|
||||
return substr(length()-len, len);
|
||||
}
|
||||
|
||||
// Retrieve the substring following the last occurrence of Str
|
||||
// (or the whole string if it doesn't contain Str)
|
||||
CStr CStr::AfterLast(const CStr& str, size_t startPos) const
|
||||
|
||||
@@ -161,14 +161,6 @@ public:
|
||||
**/
|
||||
CStr UpperCase() const;
|
||||
|
||||
/**
|
||||
* Retrieve last n characters of the CStr.
|
||||
*
|
||||
* @param size_t len the number of characters to retrieve.
|
||||
* @return CStr retrieved substring.
|
||||
**/
|
||||
CStr Right(size_t len) const;
|
||||
|
||||
/**
|
||||
* Retrieve substring of the CStr after last occurrence of a string.
|
||||
* Return substring of the CStr after the last occurrence of the search string.
|
||||
|
||||
@@ -288,7 +288,7 @@ void WriteJSONFile(const Script::Interface& scriptInterface, const std::wstring&
|
||||
bool DeleteCampaignSave(const CStrW& filePath)
|
||||
{
|
||||
OsPath realPath;
|
||||
if (!filePath.starts_with(L"saves/campaigns/") || filePath.Right(12) != L".0adcampaign")
|
||||
if (!filePath.starts_with(L"saves/campaigns/") || !filePath.ends_with(L".0adcampaign"))
|
||||
return false;
|
||||
if (!VfsFileExists(filePath))
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user