filesystem.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html.
  4. #ifndef OPENCV_UTILS_FILESYSTEM_HPP
  5. #define OPENCV_UTILS_FILESYSTEM_HPP
  6. namespace cv { namespace utils { namespace fs {
  7. CV_EXPORTS bool exists(const cv::String& path);
  8. CV_EXPORTS bool isDirectory(const cv::String& path);
  9. CV_EXPORTS void remove_all(const cv::String& path);
  10. CV_EXPORTS cv::String getcwd();
  11. /** Join path components */
  12. CV_EXPORTS cv::String join(const cv::String& base, const cv::String& path);
  13. /**
  14. * Generate a list of all files that match the globbing pattern.
  15. *
  16. * Result entries are prefixed by base directory path.
  17. *
  18. * @param directory base directory
  19. * @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results
  20. * @param[out] result result of globing.
  21. * @param recursive scan nested directories too
  22. * @param includeDirectories include directories into results list
  23. */
  24. CV_EXPORTS void glob(const cv::String& directory, const cv::String& pattern,
  25. CV_OUT std::vector<cv::String>& result,
  26. bool recursive = false, bool includeDirectories = false);
  27. /**
  28. * Generate a list of all files that match the globbing pattern.
  29. *
  30. * @param directory base directory
  31. * @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results
  32. * @param[out] result globbing result with relative paths from base directory
  33. * @param recursive scan nested directories too
  34. * @param includeDirectories include directories into results list
  35. */
  36. CV_EXPORTS void glob_relative(const cv::String& directory, const cv::String& pattern,
  37. CV_OUT std::vector<cv::String>& result,
  38. bool recursive = false, bool includeDirectories = false);
  39. CV_EXPORTS bool createDirectory(const cv::String& path);
  40. CV_EXPORTS bool createDirectories(const cv::String& path);
  41. #ifdef __OPENCV_BUILD
  42. // TODO
  43. //CV_EXPORTS cv::String getTempDirectory();
  44. /**
  45. * @brief Returns directory to store OpenCV cache files
  46. * Create sub-directory in common OpenCV cache directory if it doesn't exist.
  47. * @param sub_directory_name name of sub-directory. NULL or "" value asks to return root cache directory.
  48. * @param configuration_name optional name of configuration parameter name which overrides default behavior.
  49. * @return Path to cache directory. Returns empty string if cache directories support is not available. Returns "disabled" if cache disabled by user.
  50. */
  51. CV_EXPORTS cv::String getCacheDirectory(const char* sub_directory_name, const char* configuration_name = NULL);
  52. #endif
  53. }}} // namespace
  54. #endif // OPENCV_UTILS_FILESYSTEM_HPP