summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Liam2023-12-17 14:25:42 -0500
committerGravatar Liam2023-12-17 14:25:42 -0500
commit09e8fb75ce0b16acc3fa21379c4b3e69d43c520b (patch)
treed6771c87088db094492daf2ed39829cf5efc5873 /src
parentMerge pull request #12378 from liamwhite/offsetof (diff)
downloadyuzu-09e8fb75ce0b16acc3fa21379c4b3e69d43c520b.tar.gz
yuzu-09e8fb75ce0b16acc3fa21379c4b3e69d43c520b.tar.xz
yuzu-09e8fb75ce0b16acc3fa21379c4b3e69d43c520b.zip
path_util: copy output for GetParentPath
Diffstat (limited to '')
-rw-r--r--src/common/fs/path_util.cpp6
-rw-r--r--src/common/fs/path_util.h2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/common/fs/path_util.cpp b/src/common/fs/path_util.cpp
index d2f50432a..4f69db6f5 100644
--- a/src/common/fs/path_util.cpp
+++ b/src/common/fs/path_util.cpp
@@ -418,9 +418,9 @@ std::string SanitizePath(std::string_view path_, DirectorySeparator directory_se
418 return std::string(RemoveTrailingSlash(path)); 418 return std::string(RemoveTrailingSlash(path));
419} 419}
420 420
421std::string_view GetParentPath(std::string_view path) { 421std::string GetParentPath(std::string_view path) {
422 if (path.empty()) { 422 if (path.empty()) {
423 return path; 423 return std::string(path);
424 } 424 }
425 425
426#ifdef ANDROID 426#ifdef ANDROID
@@ -439,7 +439,7 @@ std::string_view GetParentPath(std::string_view path) {
439 name_index = std::max(name_bck_index, name_fwd_index); 439 name_index = std::max(name_bck_index, name_fwd_index);
440 } 440 }
441 441
442 return path.substr(0, name_index); 442 return std::string(path.substr(0, name_index));
443} 443}
444 444
445std::string_view GetPathWithoutTop(std::string_view path) { 445std::string_view GetPathWithoutTop(std::string_view path) {
diff --git a/src/common/fs/path_util.h b/src/common/fs/path_util.h
index 23c8b1359..59301e7ed 100644
--- a/src/common/fs/path_util.h
+++ b/src/common/fs/path_util.h
@@ -302,7 +302,7 @@ enum class DirectorySeparator {
302 DirectorySeparator directory_separator = DirectorySeparator::ForwardSlash); 302 DirectorySeparator directory_separator = DirectorySeparator::ForwardSlash);
303 303
304// Gets all of the text up to the last '/' or '\' in the path. 304// Gets all of the text up to the last '/' or '\' in the path.
305[[nodiscard]] std::string_view GetParentPath(std::string_view path); 305[[nodiscard]] std::string GetParentPath(std::string_view path);
306 306
307// Gets all of the text after the first '/' or '\' in the path. 307// Gets all of the text after the first '/' or '\' in the path.
308[[nodiscard]] std::string_view GetPathWithoutTop(std::string_view path); 308[[nodiscard]] std::string_view GetPathWithoutTop(std::string_view path);