10b57cec5SDimitry Andric// -*- C++ -*- 2349cc55cSDimitry Andric//===----------------------------------------------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric#ifndef _LIBCPP_FILESYSTEM 100b57cec5SDimitry Andric#define _LIBCPP_FILESYSTEM 11*81ad6265SDimitry Andric 120b57cec5SDimitry Andric/* 130b57cec5SDimitry Andric filesystem synopsis 140b57cec5SDimitry Andric 15349cc55cSDimitry Andric namespace std::filesystem { 160b57cec5SDimitry Andric 170b57cec5SDimitry Andric class path; 180b57cec5SDimitry Andric 190b57cec5SDimitry Andric void swap(path& lhs, path& rhs) noexcept; 200b57cec5SDimitry Andric size_t hash_value(const path& p) noexcept; 210b57cec5SDimitry Andric 220b57cec5SDimitry Andric bool operator==(const path& lhs, const path& rhs) noexcept; 230b57cec5SDimitry Andric bool operator!=(const path& lhs, const path& rhs) noexcept; 240b57cec5SDimitry Andric bool operator< (const path& lhs, const path& rhs) noexcept; 250b57cec5SDimitry Andric bool operator<=(const path& lhs, const path& rhs) noexcept; 260b57cec5SDimitry Andric bool operator> (const path& lhs, const path& rhs) noexcept; 270b57cec5SDimitry Andric bool operator>=(const path& lhs, const path& rhs) noexcept; 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric path operator/ (const path& lhs, const path& rhs); 300b57cec5SDimitry Andric 310b57cec5SDimitry Andric // fs.path.io operators are friends of path. 320b57cec5SDimitry Andric template <class charT, class traits> 330b57cec5SDimitry Andric friend basic_ostream<charT, traits>& 340b57cec5SDimitry Andric operator<<(basic_ostream<charT, traits>& os, const path& p); 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric template <class charT, class traits> 370b57cec5SDimitry Andric friend basic_istream<charT, traits>& 380b57cec5SDimitry Andric operator>>(basic_istream<charT, traits>& is, path& p); 390b57cec5SDimitry Andric 400b57cec5SDimitry Andric template <class Source> 410b57cec5SDimitry Andric path u8path(const Source& source); 420b57cec5SDimitry Andric template <class InputIterator> 430b57cec5SDimitry Andric path u8path(InputIterator first, InputIterator last); 440b57cec5SDimitry Andric 450b57cec5SDimitry Andric class filesystem_error; 460b57cec5SDimitry Andric class directory_entry; 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric class directory_iterator; 490b57cec5SDimitry Andric 500b57cec5SDimitry Andric // enable directory_iterator range-based for statements 510b57cec5SDimitry Andric directory_iterator begin(directory_iterator iter) noexcept; 52349cc55cSDimitry Andric directory_iterator end(directory_iterator) noexcept; 530b57cec5SDimitry Andric 540b57cec5SDimitry Andric class recursive_directory_iterator; 550b57cec5SDimitry Andric 560b57cec5SDimitry Andric // enable recursive_directory_iterator range-based for statements 570b57cec5SDimitry Andric recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; 58349cc55cSDimitry Andric recursive_directory_iterator end(recursive_directory_iterator) noexcept; 590b57cec5SDimitry Andric 600b57cec5SDimitry Andric class file_status; 610b57cec5SDimitry Andric 620b57cec5SDimitry Andric struct space_info 630b57cec5SDimitry Andric { 640b57cec5SDimitry Andric uintmax_t capacity; 650b57cec5SDimitry Andric uintmax_t free; 660b57cec5SDimitry Andric uintmax_t available; 670b57cec5SDimitry Andric }; 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric enum class file_type; 700b57cec5SDimitry Andric enum class perms; 710b57cec5SDimitry Andric enum class perm_options; 720b57cec5SDimitry Andric enum class copy_options; 730b57cec5SDimitry Andric enum class directory_options; 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric typedef chrono::time_point<trivial-clock> file_time_type; 760b57cec5SDimitry Andric 770b57cec5SDimitry Andric // operational functions 780b57cec5SDimitry Andric 790b57cec5SDimitry Andric path absolute(const path& p); 800b57cec5SDimitry Andric path absolute(const path& p, error_code &ec); 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric path canonical(const path& p); 830b57cec5SDimitry Andric path canonical(const path& p, error_code& ec); 840b57cec5SDimitry Andric 850b57cec5SDimitry Andric void copy(const path& from, const path& to); 860b57cec5SDimitry Andric void copy(const path& from, const path& to, error_code& ec); 870b57cec5SDimitry Andric void copy(const path& from, const path& to, copy_options options); 880b57cec5SDimitry Andric void copy(const path& from, const path& to, copy_options options, 890b57cec5SDimitry Andric error_code& ec); 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric bool copy_file(const path& from, const path& to); 920b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, error_code& ec); 930b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, copy_options option); 940b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, copy_options option, 950b57cec5SDimitry Andric error_code& ec); 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric void copy_symlink(const path& existing_symlink, const path& new_symlink); 980b57cec5SDimitry Andric void copy_symlink(const path& existing_symlink, const path& new_symlink, 990b57cec5SDimitry Andric error_code& ec) noexcept; 1000b57cec5SDimitry Andric 1010b57cec5SDimitry Andric bool create_directories(const path& p); 1020b57cec5SDimitry Andric bool create_directories(const path& p, error_code& ec); 1030b57cec5SDimitry Andric 1040b57cec5SDimitry Andric bool create_directory(const path& p); 1050b57cec5SDimitry Andric bool create_directory(const path& p, error_code& ec) noexcept; 1060b57cec5SDimitry Andric 1070b57cec5SDimitry Andric bool create_directory(const path& p, const path& attributes); 1080b57cec5SDimitry Andric bool create_directory(const path& p, const path& attributes, 1090b57cec5SDimitry Andric error_code& ec) noexcept; 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric void create_directory_symlink(const path& to, const path& new_symlink); 1120b57cec5SDimitry Andric void create_directory_symlink(const path& to, const path& new_symlink, 1130b57cec5SDimitry Andric error_code& ec) noexcept; 1140b57cec5SDimitry Andric 1150b57cec5SDimitry Andric void create_hard_link(const path& to, const path& new_hard_link); 1160b57cec5SDimitry Andric void create_hard_link(const path& to, const path& new_hard_link, 1170b57cec5SDimitry Andric error_code& ec) noexcept; 1180b57cec5SDimitry Andric 1190b57cec5SDimitry Andric void create_symlink(const path& to, const path& new_symlink); 1200b57cec5SDimitry Andric void create_symlink(const path& to, const path& new_symlink, 1210b57cec5SDimitry Andric error_code& ec) noexcept; 1220b57cec5SDimitry Andric 1230b57cec5SDimitry Andric path current_path(); 1240b57cec5SDimitry Andric path current_path(error_code& ec); 1250b57cec5SDimitry Andric void current_path(const path& p); 1260b57cec5SDimitry Andric void current_path(const path& p, error_code& ec) noexcept; 1270b57cec5SDimitry Andric 1280b57cec5SDimitry Andric bool exists(file_status s) noexcept; 1290b57cec5SDimitry Andric bool exists(const path& p); 1300b57cec5SDimitry Andric bool exists(const path& p, error_code& ec) noexcept; 1310b57cec5SDimitry Andric 1320b57cec5SDimitry Andric bool equivalent(const path& p1, const path& p2); 1330b57cec5SDimitry Andric bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; 1340b57cec5SDimitry Andric 1350b57cec5SDimitry Andric uintmax_t file_size(const path& p); 1360b57cec5SDimitry Andric uintmax_t file_size(const path& p, error_code& ec) noexcept; 1370b57cec5SDimitry Andric 1380b57cec5SDimitry Andric uintmax_t hard_link_count(const path& p); 1390b57cec5SDimitry Andric uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; 1400b57cec5SDimitry Andric 1410b57cec5SDimitry Andric bool is_block_file(file_status s) noexcept; 1420b57cec5SDimitry Andric bool is_block_file(const path& p); 1430b57cec5SDimitry Andric bool is_block_file(const path& p, error_code& ec) noexcept; 1440b57cec5SDimitry Andric 1450b57cec5SDimitry Andric bool is_character_file(file_status s) noexcept; 1460b57cec5SDimitry Andric bool is_character_file(const path& p); 1470b57cec5SDimitry Andric bool is_character_file(const path& p, error_code& ec) noexcept; 1480b57cec5SDimitry Andric 1490b57cec5SDimitry Andric bool is_directory(file_status s) noexcept; 1500b57cec5SDimitry Andric bool is_directory(const path& p); 1510b57cec5SDimitry Andric bool is_directory(const path& p, error_code& ec) noexcept; 1520b57cec5SDimitry Andric 1530b57cec5SDimitry Andric bool is_empty(const path& p); 1540b57cec5SDimitry Andric bool is_empty(const path& p, error_code& ec) noexcept; 1550b57cec5SDimitry Andric 1560b57cec5SDimitry Andric bool is_fifo(file_status s) noexcept; 1570b57cec5SDimitry Andric bool is_fifo(const path& p); 1580b57cec5SDimitry Andric bool is_fifo(const path& p, error_code& ec) noexcept; 1590b57cec5SDimitry Andric 1600b57cec5SDimitry Andric bool is_other(file_status s) noexcept; 1610b57cec5SDimitry Andric bool is_other(const path& p); 1620b57cec5SDimitry Andric bool is_other(const path& p, error_code& ec) noexcept; 1630b57cec5SDimitry Andric 1640b57cec5SDimitry Andric bool is_regular_file(file_status s) noexcept; 1650b57cec5SDimitry Andric bool is_regular_file(const path& p); 1660b57cec5SDimitry Andric bool is_regular_file(const path& p, error_code& ec) noexcept; 1670b57cec5SDimitry Andric 1680b57cec5SDimitry Andric bool is_socket(file_status s) noexcept; 1690b57cec5SDimitry Andric bool is_socket(const path& p); 1700b57cec5SDimitry Andric bool is_socket(const path& p, error_code& ec) noexcept; 1710b57cec5SDimitry Andric 1720b57cec5SDimitry Andric bool is_symlink(file_status s) noexcept; 1730b57cec5SDimitry Andric bool is_symlink(const path& p); 1740b57cec5SDimitry Andric bool is_symlink(const path& p, error_code& ec) noexcept; 1750b57cec5SDimitry Andric 1760b57cec5SDimitry Andric file_time_type last_write_time(const path& p); 1770b57cec5SDimitry Andric file_time_type last_write_time(const path& p, error_code& ec) noexcept; 1780b57cec5SDimitry Andric void last_write_time(const path& p, file_time_type new_time); 1790b57cec5SDimitry Andric void last_write_time(const path& p, file_time_type new_time, 1800b57cec5SDimitry Andric error_code& ec) noexcept; 1810b57cec5SDimitry Andric 1820b57cec5SDimitry Andric void permissions(const path& p, perms prms, 1830b57cec5SDimitry Andric perm_options opts=perm_options::replace); 1840b57cec5SDimitry Andric void permissions(const path& p, perms prms, error_code& ec) noexcept; 1850b57cec5SDimitry Andric void permissions(const path& p, perms prms, perm_options opts, 1860b57cec5SDimitry Andric error_code& ec); 1870b57cec5SDimitry Andric 1880b57cec5SDimitry Andric path proximate(const path& p, error_code& ec); 1890b57cec5SDimitry Andric path proximate(const path& p, const path& base = current_path()); 1900b57cec5SDimitry Andric path proximate(const path& p, const path& base, error_code &ec); 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andric path read_symlink(const path& p); 1930b57cec5SDimitry Andric path read_symlink(const path& p, error_code& ec); 1940b57cec5SDimitry Andric 1950b57cec5SDimitry Andric path relative(const path& p, error_code& ec); 1960b57cec5SDimitry Andric path relative(const path& p, const path& base=current_path()); 1970b57cec5SDimitry Andric path relative(const path& p, const path& base, error_code& ec); 1980b57cec5SDimitry Andric 1990b57cec5SDimitry Andric bool remove(const path& p); 2000b57cec5SDimitry Andric bool remove(const path& p, error_code& ec) noexcept; 2010b57cec5SDimitry Andric 2020b57cec5SDimitry Andric uintmax_t remove_all(const path& p); 2030b57cec5SDimitry Andric uintmax_t remove_all(const path& p, error_code& ec); 2040b57cec5SDimitry Andric 2050b57cec5SDimitry Andric void rename(const path& from, const path& to); 2060b57cec5SDimitry Andric void rename(const path& from, const path& to, error_code& ec) noexcept; 2070b57cec5SDimitry Andric 2080b57cec5SDimitry Andric void resize_file(const path& p, uintmax_t size); 2090b57cec5SDimitry Andric void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; 2100b57cec5SDimitry Andric 2110b57cec5SDimitry Andric space_info space(const path& p); 2120b57cec5SDimitry Andric space_info space(const path& p, error_code& ec) noexcept; 2130b57cec5SDimitry Andric 2140b57cec5SDimitry Andric file_status status(const path& p); 2150b57cec5SDimitry Andric file_status status(const path& p, error_code& ec) noexcept; 2160b57cec5SDimitry Andric 2170b57cec5SDimitry Andric bool status_known(file_status s) noexcept; 2180b57cec5SDimitry Andric 2190b57cec5SDimitry Andric file_status symlink_status(const path& p); 2200b57cec5SDimitry Andric file_status symlink_status(const path& p, error_code& ec) noexcept; 2210b57cec5SDimitry Andric 2220b57cec5SDimitry Andric path temp_directory_path(); 2230b57cec5SDimitry Andric path temp_directory_path(error_code& ec); 2240b57cec5SDimitry Andric 2250b57cec5SDimitry Andric path weakly_canonical(path const& p); 2260b57cec5SDimitry Andric path weakly_canonical(path const& p, error_code& ec); 2270b57cec5SDimitry Andric 228349cc55cSDimitry Andric} // namespace std::filesystem 2290b57cec5SDimitry Andric 230349cc55cSDimitry Andrictemplate <> 231349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; 232349cc55cSDimitry Andrictemplate <> 233349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; 234349cc55cSDimitry Andric 235349cc55cSDimitry Andrictemplate <> 236349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true; 237349cc55cSDimitry Andrictemplate <> 238349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; 2390b57cec5SDimitry Andric 2400b57cec5SDimitry Andric*/ 2410b57cec5SDimitry Andric 242*81ad6265SDimitry Andric#include <__assert> // all public C++ headers provide the assertion handler 243fe6060f1SDimitry Andric#include <__config> 2440eae32dcSDimitry Andric#include <__filesystem/copy_options.h> 2450eae32dcSDimitry Andric#include <__filesystem/directory_entry.h> 2460eae32dcSDimitry Andric#include <__filesystem/directory_iterator.h> 2470eae32dcSDimitry Andric#include <__filesystem/directory_options.h> 2480eae32dcSDimitry Andric#include <__filesystem/file_status.h> 2490eae32dcSDimitry Andric#include <__filesystem/file_time_type.h> 2500eae32dcSDimitry Andric#include <__filesystem/file_type.h> 2510eae32dcSDimitry Andric#include <__filesystem/filesystem_error.h> 2520eae32dcSDimitry Andric#include <__filesystem/operations.h> 2530eae32dcSDimitry Andric#include <__filesystem/path.h> 25404eeddc0SDimitry Andric#include <__filesystem/path_iterator.h> 2550eae32dcSDimitry Andric#include <__filesystem/perm_options.h> 2560eae32dcSDimitry Andric#include <__filesystem/perms.h> 2570eae32dcSDimitry Andric#include <__filesystem/recursive_directory_iterator.h> 2580eae32dcSDimitry Andric#include <__filesystem/space_info.h> 2590eae32dcSDimitry Andric#include <__filesystem/u8path.h> 2600b57cec5SDimitry Andric#include <version> 2610b57cec5SDimitry Andric 262*81ad6265SDimitry Andric// standard-mandated includes 263*81ad6265SDimitry Andric#include <compare> 264*81ad6265SDimitry Andric 265e8d8bef9SDimitry Andric#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) 266*81ad6265SDimitry Andric# error "The <filesystem> library is not supported since libc++ has been configured without support for a filesystem." 267e8d8bef9SDimitry Andric#endif 268e8d8bef9SDimitry Andric 2690b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2700b57cec5SDimitry Andric# pragma GCC system_header 2710b57cec5SDimitry Andric#endif 2720b57cec5SDimitry Andric 2730b57cec5SDimitry Andric#endif // _LIBCPP_FILESYSTEM 274