1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

build: made environment access a separate feature

This commit is contained in:
Maksim Shabunin
2024-10-17 23:35:38 +03:00
parent 2756c20e3e
commit 04818d6dd5
44 changed files with 176 additions and 275 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ static std::vector<cv::String>& _getDataSearchSubDirectory()
CV_EXPORTS void addDataSearchPath(const cv::String& path)
{
if (utils::fs::isDirectory(path))
if (!path.empty() && utils::fs::isDirectory(path))
_getDataSearchPath().push_back(path);
}
CV_EXPORTS void addDataSearchSubDirectory(const cv::String& subdir)
+6 -6
View File
@@ -447,8 +447,8 @@ cv::String getCacheDirectory(const char* sub_directory_name, const char* configu
#elif defined __ANDROID__
// no defaults
#elif defined __APPLE__
const char* tmpdir_env = getenv("TMPDIR");
if (tmpdir_env && utils::fs::isDirectory(tmpdir_env))
const std::string tmpdir_env = utils::getConfigurationParameterString("TMPDIR");
if (!tmpdir_env.empty() && utils::fs::isDirectory(tmpdir_env))
{
default_cache_path = tmpdir_env;
}
@@ -461,16 +461,16 @@ cv::String getCacheDirectory(const char* sub_directory_name, const char* configu
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
if (default_cache_path.empty())
{
const char* xdg_cache_env = getenv("XDG_CACHE_HOME");
if (xdg_cache_env && xdg_cache_env[0] && utils::fs::isDirectory(xdg_cache_env))
const std::string xdg_cache_env = utils::getConfigurationParameterString("XDG_CACHE_HOME");
if (!xdg_cache_env.empty() && utils::fs::isDirectory(xdg_cache_env))
{
default_cache_path = xdg_cache_env;
}
}
if (default_cache_path.empty())
{
const char* home_env = getenv("HOME");
if (home_env && home_env[0] && utils::fs::isDirectory(home_env))
const std::string home_env = utils::getConfigurationParameterString("HOME");
if (!home_env.empty() && utils::fs::isDirectory(home_env))
{
cv::String home_path = home_env;
cv::String home_cache_path = utils::fs::join(home_path, ".cache/");