mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 00:03:03 +04:00
[build][option] Build option to disable filesystem support.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "opencv2/core/utils/filesystem.hpp"
|
||||
|
||||
#include <opencv2/core/utils/configuration.private.hpp>
|
||||
#include "opencv2/core/utils/filesystem.private.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@@ -67,6 +68,7 @@ CV_EXPORTS void addDataSearchSubDirectory(const cv::String& subdir)
|
||||
_getDataSearchSubDirectory().push_back(subdir);
|
||||
}
|
||||
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
static bool isPathSep(char c)
|
||||
{
|
||||
return c == '/' || c == '\\';
|
||||
@@ -96,12 +98,14 @@ static bool isSubDirectory_(const cv::String& base_path, const cv::String& path)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool isSubDirectory(const cv::String& base_path, const cv::String& path)
|
||||
{
|
||||
bool res = isSubDirectory_(base_path, path);
|
||||
CV_LOG_VERBOSE(NULL, 0, "isSubDirectory(): base: " << base_path << " path: " << path << " => result: " << (res ? "TRUE" : "FALSE"));
|
||||
return res;
|
||||
}
|
||||
#endif //OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
|
||||
static cv::String getModuleLocation(const void* addr)
|
||||
{
|
||||
@@ -188,6 +192,7 @@ cv::String findDataFile(const cv::String& relative_path,
|
||||
const std::vector<String>* search_paths,
|
||||
const std::vector<String>* subdir_paths)
|
||||
{
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
configuration_parameter = configuration_parameter ? configuration_parameter : "OPENCV_DATA_PATH";
|
||||
CV_LOG_DEBUG(NULL, cv::format("utils::findDataFile('%s', %s)", relative_path.c_str(), configuration_parameter));
|
||||
|
||||
@@ -410,10 +415,18 @@ cv::String findDataFile(const cv::String& relative_path,
|
||||
#endif
|
||||
|
||||
return cv::String(); // not found
|
||||
#else // OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
CV_UNUSED(relative_path);
|
||||
CV_UNUSED(configuration_parameter);
|
||||
CV_UNUSED(search_paths);
|
||||
CV_UNUSED(subdir_paths);
|
||||
CV_Error(Error::StsNotImplemented, "File system support is disabled in this OpenCV build!");
|
||||
#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
}
|
||||
|
||||
cv::String findDataFile(const cv::String& relative_path, bool required, const char* configuration_parameter)
|
||||
{
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
CV_LOG_DEBUG(NULL, cv::format("cv::utils::findDataFile('%s', %s, %s)",
|
||||
relative_path.c_str(), required ? "true" : "false",
|
||||
configuration_parameter ? configuration_parameter : "NULL"));
|
||||
@@ -424,6 +437,12 @@ cv::String findDataFile(const cv::String& relative_path, bool required, const ch
|
||||
if (result.empty() && required)
|
||||
CV_Error(cv::Error::StsError, cv::format("OpenCV: Can't find required data file: %s", relative_path.c_str()));
|
||||
return result;
|
||||
#else // OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
CV_UNUSED(relative_path);
|
||||
CV_UNUSED(required);
|
||||
CV_UNUSED(configuration_parameter);
|
||||
CV_Error(Error::StsNotImplemented, "File system support is disabled in this OpenCV build!");
|
||||
#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
|
||||
#include "opencv2/core/utils/logger.hpp"
|
||||
#include "opencv2/core/utils/filesystem.hpp"
|
||||
#include "opencv2/core/utils/filesystem.private.hpp"
|
||||
|
||||
namespace cv { namespace samples {
|
||||
|
||||
@@ -49,6 +50,7 @@ CV_EXPORTS void addSamplesDataSearchSubDirectory(const cv::String& subdir)
|
||||
|
||||
cv::String findFile(const cv::String& relative_path, bool required, bool silentMode)
|
||||
{
|
||||
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
|
||||
CV_LOG_DEBUG(NULL, cv::format("cv::samples::findFile('%s', %s)", relative_path.c_str(), required ? "true" : "false"));
|
||||
cv::String result = cv::utils::findDataFile(relative_path,
|
||||
"OPENCV_SAMPLES_DATA_PATH",
|
||||
@@ -61,6 +63,12 @@ cv::String findFile(const cv::String& relative_path, bool required, bool silentM
|
||||
if (result.empty() && required)
|
||||
CV_Error(cv::Error::StsError, cv::format("OpenCV samples: Can't find required data file: %s", relative_path.c_str()));
|
||||
return result;
|
||||
#else
|
||||
CV_UNUSED(relative_path);
|
||||
CV_UNUSED(required);
|
||||
CV_UNUSED(silentMode);
|
||||
CV_Error(Error::StsNotImplemented, "File system support is disabled in this OpenCV build!");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user