Improve code style

This commit is contained in:
halx99 2021-07-15 23:10:36 +08:00
parent ec5ef59474
commit 0d4aec88d1
1 changed files with 2 additions and 3 deletions

View File

@ -145,15 +145,14 @@ std::string getUrlStringByFileName(const std::string& fileName) {
// LOGD("error: %s,%d",__func__,__LINE__);
const std::string basePath("file:///android_asset/");
using namespace cxx17;
const auto assetsPath = "assets/"_sv;
using namespace cxx17; // for cxx17::string_view literal
std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fileName);
std::string urlString;
if (fullPath.empty()) {
return urlString;
} else if (fullPath[0] == '/') {
urlString.append("file://").append(fullPath);
} else if (cxx20::starts_with(cxx17::string_view{fullPath}, assetsPath)) {
} else if (cxx20::starts_with(cxx17::string_view{fullPath}, "assets/"_sv)) {
urlString = fullPath;
} else {
urlString.append(basePath).append(fullPath);