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:
@@ -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)
|
||||
|
||||
@@ -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/");
|
||||
|
||||
Reference in New Issue
Block a user