aboutsummaryrefslogtreecommitdiff
path: root/src/common/fs
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/fs')
-rw-r--r--src/common/fs/path_util.cpp20
-rw-r--r--src/common/fs/path_util.h12
2 files changed, 10 insertions, 22 deletions
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index e032360961..fa1403225e 100644
--- a/src/common/fs/path_util.cpp
+++ b/src/common/fs/path_util.cpp
@@ -517,24 +517,4 @@ std::string_view GetPathWithoutTop(std::string_view path) {
return path.substr(std::min(name_bck_index, name_fwd_index) + 1);
}
-std::string_view GetFilename(std::string_view path) {
- const auto name_index = path.find_last_of("\\/");
-
- if (name_index == std::string_view::npos) {
- return {};
- }
-
- return path.substr(name_index + 1);
-}
-
-std::string_view GetExtensionFromFilename(std::string_view name) {
- const std::size_t index = name.rfind('.');
-
- if (index == std::string_view::npos) {
- return {};
- }
-
- return name.substr(index + 1);
-}
-
} // namespace Common::FS
diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h
index c1f478690a..b34efc472f 100644
--- a/src/common/fs/path_util.h
+++ b/src/common/fs/path_util.h
@@ -352,9 +352,17 @@ enum class DirectorySeparator {
[[nodiscard]] std::string_view GetPathWithoutTop(std::string_view path);
// Gets the filename of the path
-[[nodiscard]] std::string_view GetFilename(std::string_view path);
+[[nodiscard]] inline std::string_view GetFilename(const std::string_view path) noexcept {
+ if (auto const name_index = path.find_last_of("\\/"); name_index != std::string_view::npos)
+ return path.substr(name_index + 1);
+ return {};
+}
// Gets the extension of the filename
-[[nodiscard]] std::string_view GetExtensionFromFilename(std::string_view name);
+[[nodiscard]] inline std::string_view GetExtensionFromFilename(const std::string_view name) noexcept {
+ if (auto const index = name.rfind('.'); index != std::string_view::npos)
+ return name.substr(index + 1);
+ return {};
+}
} // namespace Common::FS