OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
OCV_OPTION(ENABLE_FLAKE8 "Add target with Python flake8 checker" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
+OCV_OPTION(OPENCV_DISABLE_FILESYSTEM_SUPPORT "Disable filesystem support" OFF)
if(ENABLE_IMPL_COLLECTION)
add_definitions(-DCV_COLLECT_IMPL_DATA)
endif()
+if(OPENCV_DISABLE_FILESYSTEM_SUPPORT)
+ add_definitions(-DOPENCV_HAVE_FILESYSTEM_SUPPORT=0)
+endif()
+
set(OPENCV_MATHJAX_RELPATH "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0" CACHE STRING "URI to a MathJax installation")
# ----------------------------------------------------------------------------
status(" ccache:" OPENCV_COMPILER_IS_CCACHE THEN YES ELSE NO)
status(" Precompiled headers:" PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS THEN YES ELSE NO)
+if(OPENCV_DISABLE_FILESYSTEM_SUPPORT)
+ status(" Filesystem support is disabled")
+endif()
+
# ========================== Dependencies ============================
ocv_get_all_libs(deps_modules deps_extra deps_3rdparty)
status(" Extra dependencies:" ${deps_extra})
#include "precomp.hpp"
#include "opencv2/core/utils/filesystem.hpp"
+#include "opencv2/core/utils/filesystem.private.hpp"
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
#if defined _WIN32 || defined WINCE
# include <windows.h>
const char dir_separators[] = "/\\";
}
-#else
+#else // defined _WIN32 || defined WINCE
# include <dirent.h>
# include <sys/stat.h>
const char dir_separators[] = "/";
-#endif
+#endif // defined _WIN32 || defined WINCE
+#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
+
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
static bool isDir(const cv::String& path, DIR* dir)
{
#if defined _WIN32 || defined _WIN32_WCE
return is_dir != 0;
#endif
}
+#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
bool cv::utils::fs::isDirectory(const cv::String& path)
{
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
CV_INSTRUMENT_REGION();
return isDir(path, NULL);
+#else
+ CV_UNUSED(path);
+ CV_Error(Error::StsNotImplemented, "File system support is disabled in this OpenCV build!");
+#endif
}
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
static bool wildcmp(const char *string, const char *wild)
{
// Based on wildcmp written by Jack Handy - <A href="mailto:jakkhandy@hotmail.com">jakkhandy@hotmail.com</A>
CV_Error_(CV_StsObjectNotFound, ("could not open directory: %s", directory.c_str()));
}
}
+#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
void cv::glob(String pattern, std::vector<String>& result, bool recursive)
{
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
CV_INSTRUMENT_REGION();
result.clear();
glob_rec(path, wildchart, result, recursive, false, path);
std::sort(result.begin(), result.end());
+#else // OPENCV_HAVE_FILESYSTEM_SUPPORT
+ CV_UNUSED(pattern);
+ CV_UNUSED(result);
+ CV_UNUSED(recursive);
+ CV_Error(Error::StsNotImplemented, "File system support is disabled in this OpenCV build!");
+#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
}
void cv::utils::fs::glob(const cv::String& directory, const cv::String& pattern,
std::vector<cv::String>& result,
bool recursive, bool includeDirectories)
{
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
glob_rec(directory, pattern, result, recursive, includeDirectories, directory);
std::sort(result.begin(), result.end());
+#else // OPENCV_HAVE_FILESYSTEM_SUPPORT
+ CV_UNUSED(directory);
+ CV_UNUSED(pattern);
+ CV_UNUSED(result);
+ CV_UNUSED(recursive);
+ CV_UNUSED(includeDirectories);
+ CV_Error(Error::StsNotImplemented, "File system support is disabled in this OpenCV build!");
+#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
}
void cv::utils::fs::glob_relative(const cv::String& directory, const cv::String& pattern,
std::vector<cv::String>& result,
bool recursive, bool includeDirectories)
{
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
glob_rec(directory, pattern, result, recursive, includeDirectories, cv::String());
std::sort(result.begin(), result.end());
+#else // OPENCV_HAVE_FILESYSTEM_SUPPORT
+ CV_UNUSED(directory);
+ CV_UNUSED(pattern);
+ CV_UNUSED(result);
+ CV_UNUSED(recursive);
+ CV_UNUSED(includeDirectories);
+ CV_Error(Error::StsNotImplemented, "File system support is disabled in this OpenCV build!");
+#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
}
#include <opencv2/core/utils/tls.hpp>
#include <opencv2/core/utils/instrumentation.hpp>
+#include <opencv2/core/utils/filesystem.private.hpp>
+
namespace cv {
static void _initSystem()
String tempfile( const char* suffix )
{
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
String fname;
#ifndef NO_GETENV
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
return fname + suffix;
}
return fname;
+#else // OPENCV_HAVE_FILESYSTEM_SUPPORT
+ CV_UNUSED(suffix);
+ CV_Error(Error::StsNotImplemented, "File system support is disabled in this OpenCV build!");
+#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
}
static ErrorCallback customErrorCallback = 0;
#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
_getDataSearchSubDirectory().push_back(subdir);
}
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
static bool isPathSep(char c)
{
return c == '/' || c == '\\';
}
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)
{
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));
#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"));
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
#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 {
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",
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
}
#include "opencv2/core/utils/buffer_area.private.hpp"
#include "test_utils_tls.impl.hpp"
+#include "opencv2/core/utils/filesystem.private.hpp"
namespace opencv_test { namespace {
}
}
-
+#if OPENCV_HAVE_FILESYSTEM_SUPPORT
TEST(Samples, findFile)
{
cv::utils::logging::LogLevel prev = cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_VERBOSE);
ASSERT_ANY_THROW(path = samples::findFile("non-existed.file", true));
cv::utils::logging::setLogLevel(prev);
}
+#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
template <typename T>
inline bool buffers_overlap(T * first, size_t first_num, T * second, size_t second_num)
CV_Assert(plugin_backend_factory);
return plugin_backend_factory->getCapturePluginVersion(version_ABI, version_API);
#else
+ CV_UNUSED(backend_factory);
CV_UNUSED(version_ABI);
CV_UNUSED(version_API);
CV_Error(Error::StsBadFunc, "Plugins are not available in this build");
CV_Assert(plugin_backend_factory);
return plugin_backend_factory->getWriterPluginVersion(version_ABI, version_API);
#else
+ CV_UNUSED(backend_factory);
CV_UNUSED(version_ABI);
CV_UNUSED(version_API);
CV_Error(Error::StsBadFunc, "Plugins are not available in this build");