From 7c3957c0c6b5c2973792eddc918b6fbfa37e2da9 Mon Sep 17 00:00:00 2001 From: tyanmahou Date: Wed, 11 Dec 2024 22:31:20 +0900 Subject: [PATCH] update --- Re-Abyss/app/debugs/Menu/MenuBuilder.cpp | 3 ++- Re-Abyss/app/utils/FileUtil/FileUtil.cpp | 18 ++++++++++++++++-- Re-Abyss/app/utils/FileUtil/FileUtil.hpp | 7 +++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Re-Abyss/app/debugs/Menu/MenuBuilder.cpp b/Re-Abyss/app/debugs/Menu/MenuBuilder.cpp index ec76bf79a..6c263f8e0 100644 --- a/Re-Abyss/app/debugs/Menu/MenuBuilder.cpp +++ b/Re-Abyss/app/debugs/Menu/MenuBuilder.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace @@ -63,7 +64,7 @@ namespace if (s3d::FileSystem::DirectoryContents(path).any([](const s3d::FilePath& p) { return s3d::FileSystem::Extension(p) == U"tmx"; })) { - auto child = Node::Create(s3d::FileSystem::BaseName(path)); + auto child = Node::Create(FileUtil::BaseName(path)); folder.add(BuildMainSceneChangeButtons(child, path)); } continue; diff --git a/Re-Abyss/app/utils/FileUtil/FileUtil.cpp b/Re-Abyss/app/utils/FileUtil/FileUtil.cpp index 710f543fd..00763fb1d 100644 --- a/Re-Abyss/app/utils/FileUtil/FileUtil.cpp +++ b/Re-Abyss/app/utils/FileUtil/FileUtil.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -14,7 +14,21 @@ namespace namespace abyss::FileUtil { - s3d::FilePath FixRelativePath(const s3d::FilePath& path) + s3d::String BaseName(s3d::FilePathView path) + { + if (path.ends_with(U'/')) { + path.remove_suffix(1); + } + return s3d::FileSystem::BaseName(path); + } + s3d::String FileName(s3d::FilePathView path) + { + if (path.ends_with(U'/')) { + path.remove_suffix(1); + } + return s3d::FileSystem::FileName(path); + } + s3d::FilePath FixRelativePath(const s3d::FilePath& path) { std::stack dirNameStack; String dirName = U""; diff --git a/Re-Abyss/app/utils/FileUtil/FileUtil.hpp b/Re-Abyss/app/utils/FileUtil/FileUtil.hpp index b32101321..dbef93289 100644 --- a/Re-Abyss/app/utils/FileUtil/FileUtil.hpp +++ b/Re-Abyss/app/utils/FileUtil/FileUtil.hpp @@ -1,8 +1,11 @@ -#pragma once +#pragma once #include namespace abyss::FileUtil { + s3d::String BaseName(s3d::FilePathView path); + s3d::String FileName(s3d::FilePathView path); + /// /// 相対パスの ../ ./を排除する /// ex Hoge/../Piyp/ => Hoge/ @@ -30,4 +33,4 @@ namespace abyss::FileUtil #else s3d::String FixPath(const s3d::FilePath& path, bool useResource = true); #endif -} \ No newline at end of file +}