filesystem.hpp 3.2 KB

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