summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules
diff options
context:
space:
mode:
author npwoods <npwoods@mess.org>2022-06-15 06:57:23 -0400
committer GitHub <noreply@github.com>2022-06-15 20:57:23 +1000
commit699630ed167692e6d8d953caadd228bbd87c19aa (patch)
tree3b85ee6f8ceb4bcc5e97419206bb89200185faf4 /src/osd/modules
parentfe1e26a9fb437de24661a5cb16f82ec94cdb14fc (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')
-rw-r--r--src/osd/modules/file/posixdir.cpp6
-rw-r--r--src/osd/modules/file/posixfile.cpp2
-rw-r--r--src/osd/modules/file/winfile.cpp2
-rw-r--r--src/osd/modules/file/winrtfile.cpp4
-rw-r--r--src/osd/modules/render/bgfx/chainmanager.cpp6
-rw-r--r--src/osd/modules/render/bgfx/effectmanager.cpp3
-rw-r--r--src/osd/modules/render/bgfx/shadermanager.cpp4
7 files changed, 11 insertions, 16 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);
diff --git a/src/osd/modules/render/bgfx/chainmanager.cpp b/src/osd/modules/render/bgfx/chainmanager.cpp
index afbb7a99500..b9bee6d87a8 100644
--- a/src/osd/modules/render/bgfx/chainmanager.cpp
+++ b/src/osd/modules/render/bgfx/chainmanager.cpp
@@ -73,8 +73,7 @@ void chain_manager::refresh_available_chains()
m_available_chains.clear();
m_available_chains.push_back(chain_desc("none", ""));
- std::string chains_path;
- osd_subst_env(chains_path, util::string_format("%s" PATH_SEPARATOR "chains", m_options.bgfx_path()));
+ const std::string chains_path = osd_subst_env(util::string_format("%s" PATH_SEPARATOR "chains", m_options.bgfx_path()));
find_available_chains(chains_path, "");
destroy_unloaded_chains();
@@ -151,8 +150,7 @@ bgfx_chain* chain_manager::load_chain(std::string name, uint32_t screen_index)
{
name = name + ".json";
}
- std::string path;
- osd_subst_env(path, util::string_format("%s" PATH_SEPARATOR "chains" PATH_SEPARATOR, m_options.bgfx_path()));
+ std::string path = osd_subst_env(util::string_format("%s" PATH_SEPARATOR "chains" PATH_SEPARATOR, m_options.bgfx_path()));
path += name;
bx::FileReader reader;
diff --git a/src/osd/modules/render/bgfx/effectmanager.cpp b/src/osd/modules/render/bgfx/effectmanager.cpp
index 98bc9a72097..8fc2899482a 100644
--- a/src/osd/modules/render/bgfx/effectmanager.cpp
+++ b/src/osd/modules/render/bgfx/effectmanager.cpp
@@ -31,8 +31,7 @@ static bool prepare_effect_document(std::string &name, osd_options &options, rap
full_name = full_name + ".json";
}
- std::string path;
- osd_subst_env(path, util::string_format("%s" PATH_SEPARATOR "effects" PATH_SEPARATOR, options.bgfx_path()));
+ std::string path = osd_subst_env(util::string_format("%s" PATH_SEPARATOR "effects" PATH_SEPARATOR, options.bgfx_path()));
path += full_name;
bx::FileReader reader;
diff --git a/src/osd/modules/render/bgfx/shadermanager.cpp b/src/osd/modules/render/bgfx/shadermanager.cpp
index dd131e719a5..484c14c8936 100644
--- a/src/osd/modules/render/bgfx/shadermanager.cpp
+++ b/src/osd/modules/render/bgfx/shadermanager.cpp
@@ -116,9 +116,7 @@ std::string shader_manager::make_path_string(osd_options &options, std::string n
fatalerror("Unknown BGFX renderer type %d", bgfx::getRendererType());
}
shader_path += PATH_SEPARATOR;
- osd_subst_env(shader_path, shader_path);
-
- return shader_path;
+ return osd_subst_env(shader_path);
}
const bgfx::Memory* shader_manager::load_mem(std::string name)