filesystem.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /** @brief Converts path p to a canonical absolute path
  12. * Symlinks are processed if there is support for them on running platform.
  13. *
  14. * @param path input path. Target file/directory should exist.
  15. */
  16. CV_EXPORTS cv::String canonical(const cv::String& path);
  17. /** Join path components */
  18. CV_EXPORTS cv::String join(const cv::String& base, const cv::String& path);
  19. /**
  20. * Generate a list of all files that match the globbing pattern.
  21. *
  22. * Result entries are prefixed by base directory path.
  23. *
  24. * @param directory base directory
  25. * @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results
  26. * @param[out] result result of globing.
  27. * @param recursive scan nested directories too
  28. * @param includeDirectories include directories into results list
  29. */
  30. CV_EXPORTS void glob(const cv::String& directory, const cv::String& pattern,
  31. CV_OUT std::vector<cv::String>& result,
  32. bool recursive = false, bool includeDirectories = false);
  33. /**
  34. * Generate a list of all files that match the globbing pattern.
  35. *
  36. * @param directory base directory
  37. * @param pattern filter pattern (based on '*'/'?' symbols). Use empty string to disable filtering and return all results
  38. * @param[out] result globbing result with relative paths from base directory
  39. * @param recursive scan nested directories too
  40. * @param includeDirectories include directories into results list
  41. */
  42. CV_EXPORTS void glob_relative(const cv::String& directory, const cv::String& pattern,
  43. CV_OUT std::vector<cv::String>& result,
  44. bool recursive = false, bool includeDirectories = false);
  45. CV_EXPORTS bool createDirectory(const cv::String& path);
  46. CV_EXPORTS bool createDirectories(const cv::String& path);
  47. #ifdef __OPENCV_BUILD
  48. // TODO
  49. //CV_EXPORTS cv::String getTempDirectory();
  50. /**
  51. * @brief Returns directory to store OpenCV cache files
  52. * Create sub-directory in common OpenCV cache directory if it doesn't exist.
  53. * @param sub_directory_name name of sub-directory. NULL or "" value asks to return root cache directory.
  54. * @param configuration_name optional name of configuration parameter name which overrides default behavior.
  55. * @return Path to cache directory. Returns empty string if cache directories support is not available. Returns "disabled" if cache disabled by user.
  56. */
  57. CV_EXPORTS cv::String getCacheDirectory(const char* sub_directory_name, const char* configuration_name = NULL);
  58. #endif
  59. }}} // namespace
  60. #endif // OPENCV_UTILS_FILESYSTEM_HPP