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 110b57cec5SDimitry Andric/* 120b57cec5SDimitry Andric filesystem synopsis 130b57cec5SDimitry Andric 14349cc55cSDimitry Andric namespace std::filesystem { 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric class path; 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric void swap(path& lhs, path& rhs) noexcept; 190b57cec5SDimitry Andric size_t hash_value(const path& p) noexcept; 200b57cec5SDimitry Andric 210b57cec5SDimitry Andric bool operator==(const path& lhs, const path& rhs) noexcept; 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 280b57cec5SDimitry Andric path operator/ (const path& lhs, const path& rhs); 290b57cec5SDimitry Andric 300b57cec5SDimitry Andric // fs.path.io operators are friends of path. 310b57cec5SDimitry Andric template <class charT, class traits> 320b57cec5SDimitry Andric friend basic_ostream<charT, traits>& 330b57cec5SDimitry Andric operator<<(basic_ostream<charT, traits>& os, const path& p); 340b57cec5SDimitry Andric 350b57cec5SDimitry Andric template <class charT, class traits> 360b57cec5SDimitry Andric friend basic_istream<charT, traits>& 370b57cec5SDimitry Andric operator>>(basic_istream<charT, traits>& is, path& p); 380b57cec5SDimitry Andric 390b57cec5SDimitry Andric template <class Source> 400b57cec5SDimitry Andric path u8path(const Source& source); 410b57cec5SDimitry Andric template <class InputIterator> 420b57cec5SDimitry Andric path u8path(InputIterator first, InputIterator last); 430b57cec5SDimitry Andric 440b57cec5SDimitry Andric class filesystem_error; 450b57cec5SDimitry Andric class directory_entry; 460b57cec5SDimitry Andric 470b57cec5SDimitry Andric class directory_iterator; 480b57cec5SDimitry Andric 490b57cec5SDimitry Andric // enable directory_iterator range-based for statements 500b57cec5SDimitry Andric directory_iterator begin(directory_iterator iter) noexcept; 51349cc55cSDimitry Andric directory_iterator end(directory_iterator) noexcept; 520b57cec5SDimitry Andric 530b57cec5SDimitry Andric class recursive_directory_iterator; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric // enable recursive_directory_iterator range-based for statements 560b57cec5SDimitry Andric recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; 57349cc55cSDimitry Andric recursive_directory_iterator end(recursive_directory_iterator) noexcept; 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric class file_status; 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric struct space_info 620b57cec5SDimitry Andric { 630b57cec5SDimitry Andric uintmax_t capacity; 640b57cec5SDimitry Andric uintmax_t free; 650b57cec5SDimitry Andric uintmax_t available; 660b57cec5SDimitry Andric }; 670b57cec5SDimitry Andric 680b57cec5SDimitry Andric enum class file_type; 690b57cec5SDimitry Andric enum class perms; 700b57cec5SDimitry Andric enum class perm_options; 710b57cec5SDimitry Andric enum class copy_options; 720b57cec5SDimitry Andric enum class directory_options; 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric typedef chrono::time_point<trivial-clock> file_time_type; 750b57cec5SDimitry Andric 760b57cec5SDimitry Andric // operational functions 770b57cec5SDimitry Andric 780b57cec5SDimitry Andric path absolute(const path& p); 790b57cec5SDimitry Andric path absolute(const path& p, error_code &ec); 800b57cec5SDimitry Andric 810b57cec5SDimitry Andric path canonical(const path& p); 820b57cec5SDimitry Andric path canonical(const path& p, error_code& ec); 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric void copy(const path& from, const path& to); 850b57cec5SDimitry Andric void copy(const path& from, const path& to, error_code& ec); 860b57cec5SDimitry Andric void copy(const path& from, const path& to, copy_options options); 870b57cec5SDimitry Andric void copy(const path& from, const path& to, copy_options options, 880b57cec5SDimitry Andric error_code& ec); 890b57cec5SDimitry Andric 900b57cec5SDimitry Andric bool copy_file(const path& from, const path& to); 910b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, error_code& ec); 920b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, copy_options option); 930b57cec5SDimitry Andric bool copy_file(const path& from, const path& to, copy_options option, 940b57cec5SDimitry Andric error_code& ec); 950b57cec5SDimitry Andric 960b57cec5SDimitry Andric void copy_symlink(const path& existing_symlink, const path& new_symlink); 970b57cec5SDimitry Andric void copy_symlink(const path& existing_symlink, const path& new_symlink, 980b57cec5SDimitry Andric error_code& ec) noexcept; 990b57cec5SDimitry Andric 1000b57cec5SDimitry Andric bool create_directories(const path& p); 1010b57cec5SDimitry Andric bool create_directories(const path& p, error_code& ec); 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric bool create_directory(const path& p); 1040b57cec5SDimitry Andric bool create_directory(const path& p, error_code& ec) noexcept; 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric bool create_directory(const path& p, const path& attributes); 1070b57cec5SDimitry Andric bool create_directory(const path& p, const path& attributes, 1080b57cec5SDimitry Andric error_code& ec) noexcept; 1090b57cec5SDimitry Andric 1100b57cec5SDimitry Andric void create_directory_symlink(const path& to, const path& new_symlink); 1110b57cec5SDimitry Andric void create_directory_symlink(const path& to, const path& new_symlink, 1120b57cec5SDimitry Andric error_code& ec) noexcept; 1130b57cec5SDimitry Andric 1140b57cec5SDimitry Andric void create_hard_link(const path& to, const path& new_hard_link); 1150b57cec5SDimitry Andric void create_hard_link(const path& to, const path& new_hard_link, 1160b57cec5SDimitry Andric error_code& ec) noexcept; 1170b57cec5SDimitry Andric 1180b57cec5SDimitry Andric void create_symlink(const path& to, const path& new_symlink); 1190b57cec5SDimitry Andric void create_symlink(const path& to, const path& new_symlink, 1200b57cec5SDimitry Andric error_code& ec) noexcept; 1210b57cec5SDimitry Andric 1220b57cec5SDimitry Andric path current_path(); 1230b57cec5SDimitry Andric path current_path(error_code& ec); 1240b57cec5SDimitry Andric void current_path(const path& p); 1250b57cec5SDimitry Andric void current_path(const path& p, error_code& ec) noexcept; 1260b57cec5SDimitry Andric 1270b57cec5SDimitry Andric bool exists(file_status s) noexcept; 1280b57cec5SDimitry Andric bool exists(const path& p); 1290b57cec5SDimitry Andric bool exists(const path& p, error_code& ec) noexcept; 1300b57cec5SDimitry Andric 1310b57cec5SDimitry Andric bool equivalent(const path& p1, const path& p2); 1320b57cec5SDimitry Andric bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; 1330b57cec5SDimitry Andric 1340b57cec5SDimitry Andric uintmax_t file_size(const path& p); 1350b57cec5SDimitry Andric uintmax_t file_size(const path& p, error_code& ec) noexcept; 1360b57cec5SDimitry Andric 1370b57cec5SDimitry Andric uintmax_t hard_link_count(const path& p); 1380b57cec5SDimitry Andric uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; 1390b57cec5SDimitry Andric 1400b57cec5SDimitry Andric bool is_block_file(file_status s) noexcept; 1410b57cec5SDimitry Andric bool is_block_file(const path& p); 1420b57cec5SDimitry Andric bool is_block_file(const path& p, error_code& ec) noexcept; 1430b57cec5SDimitry Andric 1440b57cec5SDimitry Andric bool is_character_file(file_status s) noexcept; 1450b57cec5SDimitry Andric bool is_character_file(const path& p); 1460b57cec5SDimitry Andric bool is_character_file(const path& p, error_code& ec) noexcept; 1470b57cec5SDimitry Andric 1480b57cec5SDimitry Andric bool is_directory(file_status s) noexcept; 1490b57cec5SDimitry Andric bool is_directory(const path& p); 1500b57cec5SDimitry Andric bool is_directory(const path& p, error_code& ec) noexcept; 1510b57cec5SDimitry Andric 1520b57cec5SDimitry Andric bool is_empty(const path& p); 1530b57cec5SDimitry Andric bool is_empty(const path& p, error_code& ec) noexcept; 1540b57cec5SDimitry Andric 1550b57cec5SDimitry Andric bool is_fifo(file_status s) noexcept; 1560b57cec5SDimitry Andric bool is_fifo(const path& p); 1570b57cec5SDimitry Andric bool is_fifo(const path& p, error_code& ec) noexcept; 1580b57cec5SDimitry Andric 1590b57cec5SDimitry Andric bool is_other(file_status s) noexcept; 1600b57cec5SDimitry Andric bool is_other(const path& p); 1610b57cec5SDimitry Andric bool is_other(const path& p, error_code& ec) noexcept; 1620b57cec5SDimitry Andric 1630b57cec5SDimitry Andric bool is_regular_file(file_status s) noexcept; 1640b57cec5SDimitry Andric bool is_regular_file(const path& p); 1650b57cec5SDimitry Andric bool is_regular_file(const path& p, error_code& ec) noexcept; 1660b57cec5SDimitry Andric 1670b57cec5SDimitry Andric bool is_socket(file_status s) noexcept; 1680b57cec5SDimitry Andric bool is_socket(const path& p); 1690b57cec5SDimitry Andric bool is_socket(const path& p, error_code& ec) noexcept; 1700b57cec5SDimitry Andric 1710b57cec5SDimitry Andric bool is_symlink(file_status s) noexcept; 1720b57cec5SDimitry Andric bool is_symlink(const path& p); 1730b57cec5SDimitry Andric bool is_symlink(const path& p, error_code& ec) noexcept; 1740b57cec5SDimitry Andric 1750b57cec5SDimitry Andric file_time_type last_write_time(const path& p); 1760b57cec5SDimitry Andric file_time_type last_write_time(const path& p, error_code& ec) noexcept; 1770b57cec5SDimitry Andric void last_write_time(const path& p, file_time_type new_time); 1780b57cec5SDimitry Andric void last_write_time(const path& p, file_time_type new_time, 1790b57cec5SDimitry Andric error_code& ec) noexcept; 1800b57cec5SDimitry Andric 1810b57cec5SDimitry Andric void permissions(const path& p, perms prms, 1820b57cec5SDimitry Andric perm_options opts=perm_options::replace); 1830b57cec5SDimitry Andric void permissions(const path& p, perms prms, error_code& ec) noexcept; 1840b57cec5SDimitry Andric void permissions(const path& p, perms prms, perm_options opts, 1850b57cec5SDimitry Andric error_code& ec); 1860b57cec5SDimitry Andric 1870b57cec5SDimitry Andric path proximate(const path& p, error_code& ec); 1880b57cec5SDimitry Andric path proximate(const path& p, const path& base = current_path()); 1890b57cec5SDimitry Andric path proximate(const path& p, const path& base, error_code &ec); 1900b57cec5SDimitry Andric 1910b57cec5SDimitry Andric path read_symlink(const path& p); 1920b57cec5SDimitry Andric path read_symlink(const path& p, error_code& ec); 1930b57cec5SDimitry Andric 1940b57cec5SDimitry Andric path relative(const path& p, error_code& ec); 1950b57cec5SDimitry Andric path relative(const path& p, const path& base=current_path()); 1960b57cec5SDimitry Andric path relative(const path& p, const path& base, error_code& ec); 1970b57cec5SDimitry Andric 1980b57cec5SDimitry Andric bool remove(const path& p); 1990b57cec5SDimitry Andric bool remove(const path& p, error_code& ec) noexcept; 2000b57cec5SDimitry Andric 2010b57cec5SDimitry Andric uintmax_t remove_all(const path& p); 2020b57cec5SDimitry Andric uintmax_t remove_all(const path& p, error_code& ec); 2030b57cec5SDimitry Andric 2040b57cec5SDimitry Andric void rename(const path& from, const path& to); 2050b57cec5SDimitry Andric void rename(const path& from, const path& to, error_code& ec) noexcept; 2060b57cec5SDimitry Andric 2070b57cec5SDimitry Andric void resize_file(const path& p, uintmax_t size); 2080b57cec5SDimitry Andric void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; 2090b57cec5SDimitry Andric 2100b57cec5SDimitry Andric space_info space(const path& p); 2110b57cec5SDimitry Andric space_info space(const path& p, error_code& ec) noexcept; 2120b57cec5SDimitry Andric 2130b57cec5SDimitry Andric file_status status(const path& p); 2140b57cec5SDimitry Andric file_status status(const path& p, error_code& ec) noexcept; 2150b57cec5SDimitry Andric 2160b57cec5SDimitry Andric bool status_known(file_status s) noexcept; 2170b57cec5SDimitry Andric 2180b57cec5SDimitry Andric file_status symlink_status(const path& p); 2190b57cec5SDimitry Andric file_status symlink_status(const path& p, error_code& ec) noexcept; 2200b57cec5SDimitry Andric 2210b57cec5SDimitry Andric path temp_directory_path(); 2220b57cec5SDimitry Andric path temp_directory_path(error_code& ec); 2230b57cec5SDimitry Andric 2240b57cec5SDimitry Andric path weakly_canonical(path const& p); 2250b57cec5SDimitry Andric path weakly_canonical(path const& p, error_code& ec); 2260b57cec5SDimitry Andric 227349cc55cSDimitry Andric} // namespace std::filesystem 2280b57cec5SDimitry Andric 229349cc55cSDimitry Andrictemplate <> 230349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; 231349cc55cSDimitry Andrictemplate <> 232349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; 233349cc55cSDimitry Andric 234349cc55cSDimitry Andrictemplate <> 235349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true; 236349cc55cSDimitry Andrictemplate <> 237349cc55cSDimitry Andricinline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; 2380b57cec5SDimitry Andric 2390b57cec5SDimitry Andric*/ 2400b57cec5SDimitry Andric 241fe6060f1SDimitry Andric#include <__config> 242*0eae32dcSDimitry Andric#include <__filesystem/copy_options.h> 243*0eae32dcSDimitry Andric#include <__filesystem/directory_entry.h> 244*0eae32dcSDimitry Andric#include <__filesystem/directory_iterator.h> 245*0eae32dcSDimitry Andric#include <__filesystem/directory_options.h> 246*0eae32dcSDimitry Andric#include <__filesystem/file_status.h> 247*0eae32dcSDimitry Andric#include <__filesystem/file_time_type.h> 248*0eae32dcSDimitry Andric#include <__filesystem/file_type.h> 249*0eae32dcSDimitry Andric#include <__filesystem/filesystem_error.h> 250*0eae32dcSDimitry Andric#include <__filesystem/operations.h> 251*0eae32dcSDimitry Andric#include <__filesystem/path_iterator.h> 252*0eae32dcSDimitry Andric#include <__filesystem/path.h> 253*0eae32dcSDimitry Andric#include <__filesystem/perm_options.h> 254*0eae32dcSDimitry Andric#include <__filesystem/perms.h> 255*0eae32dcSDimitry Andric#include <__filesystem/recursive_directory_iterator.h> 256*0eae32dcSDimitry Andric#include <__filesystem/space_info.h> 257*0eae32dcSDimitry Andric#include <__filesystem/u8path.h> 258fe6060f1SDimitry Andric#include <compare> 2590b57cec5SDimitry Andric#include <version> 2600b57cec5SDimitry Andric 261e8d8bef9SDimitry Andric#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) 262349cc55cSDimitry Andric# error "The Filesystem library is not supported since libc++ has been configured with LIBCXX_ENABLE_FILESYSTEM disabled" 263e8d8bef9SDimitry Andric#endif 264e8d8bef9SDimitry Andric 2650b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2660b57cec5SDimitry Andric#pragma GCC system_header 2670b57cec5SDimitry Andric#endif 2680b57cec5SDimitry Andric 2690b57cec5SDimitry Andric#endif // _LIBCPP_FILESYSTEM 270