diff options
author | 2022-06-15 06:57:23 -0400 | |
---|---|---|
committer | 2022-06-15 20:57:23 +1000 | |
commit | 699630ed167692e6d8d953caadd228bbd87c19aa (patch) | |
tree | 3b85ee6f8ceb4bcc5e97419206bb89200185faf4 /src/osd/modules/file | |
parent | fe1e26a9fb437de24661a5cb16f82ec94cdb14fc (diff) |
osdcore.h: Changed osd_subst_env to accept a std::string_view and return a std::string. (#9928)
Diffstat (limited to 'src/osd/modules/file')
-rw-r--r-- | src/osd/modules/file/posixdir.cpp | 6 | ||||
-rw-r--r-- | src/osd/modules/file/posixfile.cpp | 2 | ||||
-rw-r--r-- | src/osd/modules/file/winfile.cpp | 2 | ||||
-rw-r--r-- | src/osd/modules/file/winrtfile.cpp | 4 |
4 files changed, 7 insertions, 7 deletions
diff --git a/src/osd/modules/file/posixdir.cpp b/src/osd/modules/file/posixdir.cpp index 63a02925bf1..efe68c2eda9 100644 --- a/src/osd/modules/file/posixdir.cpp +++ b/src/osd/modules/file/posixdir.cpp @@ -193,7 +193,7 @@ bool posix_directory::open_impl(std::string const &dirname) { assert(!m_fd); - osd_subst_env(m_path, dirname); + m_path = osd_subst_env(dirname); m_fd.reset(::opendir(m_path.c_str())); return bool(m_fd); } @@ -224,7 +224,7 @@ directory::ptr directory::open(std::string const &dirname) // osd_subst_env //============================================================ -void osd_subst_env(std::string &dst, std::string const &src) +std::string osd_subst_env(std::string_view src) { std::string result, var; auto start = src.begin(); @@ -292,5 +292,5 @@ void osd_subst_env(std::string &dst, std::string const &src) } } - dst = std::move(result); + return result; } diff --git a/src/osd/modules/file/posixfile.cpp b/src/osd/modules/file/posixfile.cpp index 580288c7d10..3b0e7b4b537 100644 --- a/src/osd/modules/file/posixfile.cpp +++ b/src/osd/modules/file/posixfile.cpp @@ -257,7 +257,7 @@ std::error_condition osd_file::open(std::string const &path, std::uint32_t openf for (auto it = dst.begin(); it != dst.end(); ++it) *it = (INVPATHSEPCH == *it) ? PATHSEPCH : *it; #endif - try { osd_subst_env(dst, dst); } + try { dst = osd_subst_env(dst); } catch (...) { return std::errc::not_enough_memory; } // attempt to open the file diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp index be4fa6f70c3..199537bbdee 100644 --- a/src/osd/modules/file/winfile.cpp +++ b/src/osd/modules/file/winfile.cpp @@ -164,7 +164,7 @@ DWORD create_path_recursive(TCHAR *path) std::error_condition osd_file::open(std::string const &orig_path, uint32_t openflags, ptr &file, std::uint64_t &filesize) noexcept { std::string path; - try { osd_subst_env(path, orig_path); } + try { path = osd_subst_env(orig_path); } catch (...) { return std::errc::not_enough_memory; } if (win_check_socket_path(path)) diff --git a/src/osd/modules/file/winrtfile.cpp b/src/osd/modules/file/winrtfile.cpp index bc45ead48ae..3de1c19605d 100644 --- a/src/osd/modules/file/winrtfile.cpp +++ b/src/osd/modules/file/winrtfile.cpp @@ -163,8 +163,8 @@ DWORD create_path_recursive(TCHAR *path) osd_file::error osd_file::open(std::string const &orig_path, uint32_t openflags, ptr &file, std::uint64_t &filesize) { std::string path; - try { osd_subst_env(path, orig_path); } - catch (...) { return error::OUT_OF_MEMORY; } + try { path = osd_subst_env(orig_path); } + catch (...) { return std::errc::not_enough_memory; } if (win_check_socket_path(path)) return win_open_socket(path, openflags, file, filesize); |