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__); // LOGD("error: %s,%d",__func__,__LINE__);
const std::string basePath("file:///android_asset/"); const std::string basePath("file:///android_asset/");
using namespace cxx17; using namespace cxx17; // for cxx17::string_view literal
const auto assetsPath = "assets/"_sv;
std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fileName); std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fileName);
std::string urlString; std::string urlString;
if (fullPath.empty()) { if (fullPath.empty()) {
return urlString; return urlString;
} else if (fullPath[0] == '/') { } else if (fullPath[0] == '/') {
urlString.append("file://").append(fullPath); 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; urlString = fullPath;
} else { } else {
urlString.append(basePath).append(fullPath); urlString.append(basePath).append(fullPath);