mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
ocl: drop obsolete cache directories after upgrade of OpenCL driver
Entries with the same platform name, the same device name and with different driver versions are assumed obsolete.
This commit is contained in:
+32
-13
@@ -47,7 +47,6 @@
|
||||
#if defined _WIN32 || defined WINCE
|
||||
# include <windows.h>
|
||||
const char dir_separators[] = "/\\";
|
||||
const char native_separator = '\\';
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -136,7 +135,6 @@ namespace
|
||||
# include <dirent.h>
|
||||
# include <sys/stat.h>
|
||||
const char dir_separators[] = "/";
|
||||
const char native_separator = '/';
|
||||
#endif
|
||||
|
||||
static bool isDir(const cv::String& path, DIR* dir)
|
||||
@@ -225,34 +223,36 @@ static bool wildcmp(const char *string, const char *wild)
|
||||
return *wild == 0;
|
||||
}
|
||||
|
||||
static void glob_rec(const cv::String& directory, const cv::String& wildchart, std::vector<cv::String>& result, bool recursive)
|
||||
static void glob_rec(const cv::String& directory, const cv::String& wildchart, std::vector<cv::String>& result,
|
||||
bool recursive, bool includeDirectories, const cv::String& pathPrefix)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
|
||||
if ((dir = opendir (directory.c_str())) != 0)
|
||||
{
|
||||
/* find all the files and directories within directory */
|
||||
try
|
||||
{
|
||||
struct dirent *ent;
|
||||
while ((ent = readdir (dir)) != 0)
|
||||
{
|
||||
const char* name = ent->d_name;
|
||||
if((name[0] == 0) || (name[0] == '.' && name[1] == 0) || (name[0] == '.' && name[1] == '.' && name[2] == 0))
|
||||
continue;
|
||||
|
||||
cv::String path = directory + native_separator + name;
|
||||
cv::String path = cv::utils::fs::join(directory, name);
|
||||
cv::String entry = cv::utils::fs::join(pathPrefix, name);
|
||||
|
||||
if (isDir(path, dir))
|
||||
{
|
||||
if (recursive)
|
||||
glob_rec(path, wildchart, result, recursive);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (wildchart.empty() || wildcmp(name, wildchart.c_str()))
|
||||
result.push_back(path);
|
||||
glob_rec(path, wildchart, result, recursive, includeDirectories, entry);
|
||||
if (!includeDirectories)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (wildchart.empty() || wildcmp(name, wildchart.c_str()))
|
||||
result.push_back(entry);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
@@ -262,7 +262,10 @@ static void glob_rec(const cv::String& directory, const cv::String& wildchart, s
|
||||
}
|
||||
closedir(dir);
|
||||
}
|
||||
else CV_Error(CV_StsObjectNotFound, cv::format("could not open directory: %s", directory.c_str()));
|
||||
else
|
||||
{
|
||||
CV_Error_(CV_StsObjectNotFound, ("could not open directory: %s", directory.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
void cv::glob(String pattern, std::vector<String>& result, bool recursive)
|
||||
@@ -298,6 +301,22 @@ void cv::glob(String pattern, std::vector<String>& result, bool recursive)
|
||||
}
|
||||
}
|
||||
|
||||
glob_rec(path, wildchart, result, recursive);
|
||||
glob_rec(path, wildchart, result, recursive, false, path);
|
||||
std::sort(result.begin(), result.end());
|
||||
}
|
||||
|
||||
void cv::utils::fs::glob(const cv::String& directory, const cv::String& pattern,
|
||||
std::vector<cv::String>& result,
|
||||
bool recursive, bool includeDirectories)
|
||||
{
|
||||
glob_rec(directory, pattern, result, recursive, includeDirectories, directory);
|
||||
std::sort(result.begin(), result.end());
|
||||
}
|
||||
|
||||
void cv::utils::fs::glob_relative(const cv::String& directory, const cv::String& pattern,
|
||||
std::vector<cv::String>& result,
|
||||
bool recursive, bool includeDirectories)
|
||||
{
|
||||
glob_rec(directory, pattern, result, recursive, includeDirectories, cv::String());
|
||||
std::sort(result.begin(), result.end());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user