1998a5c88SEric Fiselier// -*- C++ -*- 2eb8650a7SLouis Dionne//===----------------------------------------------------------------------===// 3998a5c88SEric Fiselier// 457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information. 657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7998a5c88SEric Fiselier// 8998a5c88SEric Fiselier//===----------------------------------------------------------------------===// 9998a5c88SEric Fiselier#ifndef _LIBCPP_FILESYSTEM 10998a5c88SEric Fiselier#define _LIBCPP_FILESYSTEM 11*385cc25aSLouis Dionne 12998a5c88SEric Fiselier/* 13998a5c88SEric Fiselier filesystem synopsis 14998a5c88SEric Fiselier 151fa27f2aSJoe Loser namespace std::filesystem { 16998a5c88SEric Fiselier 17998a5c88SEric Fiselier class path; 18998a5c88SEric Fiselier 19998a5c88SEric Fiselier void swap(path& lhs, path& rhs) noexcept; 20998a5c88SEric Fiselier size_t hash_value(const path& p) noexcept; 21998a5c88SEric Fiselier 22998a5c88SEric Fiselier bool operator==(const path& lhs, const path& rhs) noexcept; 23998a5c88SEric Fiselier bool operator!=(const path& lhs, const path& rhs) noexcept; 24998a5c88SEric Fiselier bool operator< (const path& lhs, const path& rhs) noexcept; 25998a5c88SEric Fiselier bool operator<=(const path& lhs, const path& rhs) noexcept; 26998a5c88SEric Fiselier bool operator> (const path& lhs, const path& rhs) noexcept; 27998a5c88SEric Fiselier bool operator>=(const path& lhs, const path& rhs) noexcept; 28998a5c88SEric Fiselier 29998a5c88SEric Fiselier path operator/ (const path& lhs, const path& rhs); 30998a5c88SEric Fiselier 31998a5c88SEric Fiselier // fs.path.io operators are friends of path. 32998a5c88SEric Fiselier template <class charT, class traits> 33998a5c88SEric Fiselier friend basic_ostream<charT, traits>& 34998a5c88SEric Fiselier operator<<(basic_ostream<charT, traits>& os, const path& p); 35998a5c88SEric Fiselier 36998a5c88SEric Fiselier template <class charT, class traits> 37998a5c88SEric Fiselier friend basic_istream<charT, traits>& 38998a5c88SEric Fiselier operator>>(basic_istream<charT, traits>& is, path& p); 39998a5c88SEric Fiselier 40998a5c88SEric Fiselier template <class Source> 41998a5c88SEric Fiselier path u8path(const Source& source); 42998a5c88SEric Fiselier template <class InputIterator> 43998a5c88SEric Fiselier path u8path(InputIterator first, InputIterator last); 44998a5c88SEric Fiselier 45998a5c88SEric Fiselier class filesystem_error; 46998a5c88SEric Fiselier class directory_entry; 47998a5c88SEric Fiselier 48998a5c88SEric Fiselier class directory_iterator; 49998a5c88SEric Fiselier 50998a5c88SEric Fiselier // enable directory_iterator range-based for statements 51998a5c88SEric Fiselier directory_iterator begin(directory_iterator iter) noexcept; 521fa27f2aSJoe Loser directory_iterator end(directory_iterator) noexcept; 53998a5c88SEric Fiselier 54998a5c88SEric Fiselier class recursive_directory_iterator; 55998a5c88SEric Fiselier 56998a5c88SEric Fiselier // enable recursive_directory_iterator range-based for statements 57998a5c88SEric Fiselier recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; 581fa27f2aSJoe Loser recursive_directory_iterator end(recursive_directory_iterator) noexcept; 59998a5c88SEric Fiselier 60998a5c88SEric Fiselier class file_status; 61998a5c88SEric Fiselier 62998a5c88SEric Fiselier struct space_info 63998a5c88SEric Fiselier { 64998a5c88SEric Fiselier uintmax_t capacity; 65998a5c88SEric Fiselier uintmax_t free; 66998a5c88SEric Fiselier uintmax_t available; 67998a5c88SEric Fiselier }; 68998a5c88SEric Fiselier 69998a5c88SEric Fiselier enum class file_type; 70998a5c88SEric Fiselier enum class perms; 71998a5c88SEric Fiselier enum class perm_options; 72998a5c88SEric Fiselier enum class copy_options; 73998a5c88SEric Fiselier enum class directory_options; 74998a5c88SEric Fiselier 75998a5c88SEric Fiselier typedef chrono::time_point<trivial-clock> file_time_type; 76998a5c88SEric Fiselier 77998a5c88SEric Fiselier // operational functions 78998a5c88SEric Fiselier 79998a5c88SEric Fiselier path absolute(const path& p); 80998a5c88SEric Fiselier path absolute(const path& p, error_code &ec); 81998a5c88SEric Fiselier 82998a5c88SEric Fiselier path canonical(const path& p); 83998a5c88SEric Fiselier path canonical(const path& p, error_code& ec); 84998a5c88SEric Fiselier 85998a5c88SEric Fiselier void copy(const path& from, const path& to); 86998a5c88SEric Fiselier void copy(const path& from, const path& to, error_code& ec); 87998a5c88SEric Fiselier void copy(const path& from, const path& to, copy_options options); 88998a5c88SEric Fiselier void copy(const path& from, const path& to, copy_options options, 89998a5c88SEric Fiselier error_code& ec); 90998a5c88SEric Fiselier 91998a5c88SEric Fiselier bool copy_file(const path& from, const path& to); 92998a5c88SEric Fiselier bool copy_file(const path& from, const path& to, error_code& ec); 93998a5c88SEric Fiselier bool copy_file(const path& from, const path& to, copy_options option); 94998a5c88SEric Fiselier bool copy_file(const path& from, const path& to, copy_options option, 95998a5c88SEric Fiselier error_code& ec); 96998a5c88SEric Fiselier 97998a5c88SEric Fiselier void copy_symlink(const path& existing_symlink, const path& new_symlink); 98998a5c88SEric Fiselier void copy_symlink(const path& existing_symlink, const path& new_symlink, 99998a5c88SEric Fiselier error_code& ec) noexcept; 100998a5c88SEric Fiselier 101998a5c88SEric Fiselier bool create_directories(const path& p); 102998a5c88SEric Fiselier bool create_directories(const path& p, error_code& ec); 103998a5c88SEric Fiselier 104998a5c88SEric Fiselier bool create_directory(const path& p); 105998a5c88SEric Fiselier bool create_directory(const path& p, error_code& ec) noexcept; 106998a5c88SEric Fiselier 107998a5c88SEric Fiselier bool create_directory(const path& p, const path& attributes); 108998a5c88SEric Fiselier bool create_directory(const path& p, const path& attributes, 109998a5c88SEric Fiselier error_code& ec) noexcept; 110998a5c88SEric Fiselier 111998a5c88SEric Fiselier void create_directory_symlink(const path& to, const path& new_symlink); 112998a5c88SEric Fiselier void create_directory_symlink(const path& to, const path& new_symlink, 113998a5c88SEric Fiselier error_code& ec) noexcept; 114998a5c88SEric Fiselier 115998a5c88SEric Fiselier void create_hard_link(const path& to, const path& new_hard_link); 116998a5c88SEric Fiselier void create_hard_link(const path& to, const path& new_hard_link, 117998a5c88SEric Fiselier error_code& ec) noexcept; 118998a5c88SEric Fiselier 119998a5c88SEric Fiselier void create_symlink(const path& to, const path& new_symlink); 120998a5c88SEric Fiselier void create_symlink(const path& to, const path& new_symlink, 121998a5c88SEric Fiselier error_code& ec) noexcept; 122998a5c88SEric Fiselier 123998a5c88SEric Fiselier path current_path(); 124998a5c88SEric Fiselier path current_path(error_code& ec); 125998a5c88SEric Fiselier void current_path(const path& p); 126998a5c88SEric Fiselier void current_path(const path& p, error_code& ec) noexcept; 127998a5c88SEric Fiselier 128998a5c88SEric Fiselier bool exists(file_status s) noexcept; 129998a5c88SEric Fiselier bool exists(const path& p); 130998a5c88SEric Fiselier bool exists(const path& p, error_code& ec) noexcept; 131998a5c88SEric Fiselier 132998a5c88SEric Fiselier bool equivalent(const path& p1, const path& p2); 133998a5c88SEric Fiselier bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; 134998a5c88SEric Fiselier 135998a5c88SEric Fiselier uintmax_t file_size(const path& p); 136998a5c88SEric Fiselier uintmax_t file_size(const path& p, error_code& ec) noexcept; 137998a5c88SEric Fiselier 138998a5c88SEric Fiselier uintmax_t hard_link_count(const path& p); 139998a5c88SEric Fiselier uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; 140998a5c88SEric Fiselier 141998a5c88SEric Fiselier bool is_block_file(file_status s) noexcept; 142998a5c88SEric Fiselier bool is_block_file(const path& p); 143998a5c88SEric Fiselier bool is_block_file(const path& p, error_code& ec) noexcept; 144998a5c88SEric Fiselier 145998a5c88SEric Fiselier bool is_character_file(file_status s) noexcept; 146998a5c88SEric Fiselier bool is_character_file(const path& p); 147998a5c88SEric Fiselier bool is_character_file(const path& p, error_code& ec) noexcept; 148998a5c88SEric Fiselier 149998a5c88SEric Fiselier bool is_directory(file_status s) noexcept; 150998a5c88SEric Fiselier bool is_directory(const path& p); 151998a5c88SEric Fiselier bool is_directory(const path& p, error_code& ec) noexcept; 152998a5c88SEric Fiselier 153998a5c88SEric Fiselier bool is_empty(const path& p); 154998a5c88SEric Fiselier bool is_empty(const path& p, error_code& ec) noexcept; 155998a5c88SEric Fiselier 156998a5c88SEric Fiselier bool is_fifo(file_status s) noexcept; 157998a5c88SEric Fiselier bool is_fifo(const path& p); 158998a5c88SEric Fiselier bool is_fifo(const path& p, error_code& ec) noexcept; 159998a5c88SEric Fiselier 160998a5c88SEric Fiselier bool is_other(file_status s) noexcept; 161998a5c88SEric Fiselier bool is_other(const path& p); 162998a5c88SEric Fiselier bool is_other(const path& p, error_code& ec) noexcept; 163998a5c88SEric Fiselier 164998a5c88SEric Fiselier bool is_regular_file(file_status s) noexcept; 165998a5c88SEric Fiselier bool is_regular_file(const path& p); 166998a5c88SEric Fiselier bool is_regular_file(const path& p, error_code& ec) noexcept; 167998a5c88SEric Fiselier 168998a5c88SEric Fiselier bool is_socket(file_status s) noexcept; 169998a5c88SEric Fiselier bool is_socket(const path& p); 170998a5c88SEric Fiselier bool is_socket(const path& p, error_code& ec) noexcept; 171998a5c88SEric Fiselier 172998a5c88SEric Fiselier bool is_symlink(file_status s) noexcept; 173998a5c88SEric Fiselier bool is_symlink(const path& p); 174998a5c88SEric Fiselier bool is_symlink(const path& p, error_code& ec) noexcept; 175998a5c88SEric Fiselier 176998a5c88SEric Fiselier file_time_type last_write_time(const path& p); 177998a5c88SEric Fiselier file_time_type last_write_time(const path& p, error_code& ec) noexcept; 178998a5c88SEric Fiselier void last_write_time(const path& p, file_time_type new_time); 179998a5c88SEric Fiselier void last_write_time(const path& p, file_time_type new_time, 180998a5c88SEric Fiselier error_code& ec) noexcept; 181998a5c88SEric Fiselier 182998a5c88SEric Fiselier void permissions(const path& p, perms prms, 183998a5c88SEric Fiselier perm_options opts=perm_options::replace); 184998a5c88SEric Fiselier void permissions(const path& p, perms prms, error_code& ec) noexcept; 185998a5c88SEric Fiselier void permissions(const path& p, perms prms, perm_options opts, 186998a5c88SEric Fiselier error_code& ec); 187998a5c88SEric Fiselier 188998a5c88SEric Fiselier path proximate(const path& p, error_code& ec); 189998a5c88SEric Fiselier path proximate(const path& p, const path& base = current_path()); 190998a5c88SEric Fiselier path proximate(const path& p, const path& base, error_code &ec); 191998a5c88SEric Fiselier 192998a5c88SEric Fiselier path read_symlink(const path& p); 193998a5c88SEric Fiselier path read_symlink(const path& p, error_code& ec); 194998a5c88SEric Fiselier 195998a5c88SEric Fiselier path relative(const path& p, error_code& ec); 196998a5c88SEric Fiselier path relative(const path& p, const path& base=current_path()); 197998a5c88SEric Fiselier path relative(const path& p, const path& base, error_code& ec); 198998a5c88SEric Fiselier 199998a5c88SEric Fiselier bool remove(const path& p); 200998a5c88SEric Fiselier bool remove(const path& p, error_code& ec) noexcept; 201998a5c88SEric Fiselier 202998a5c88SEric Fiselier uintmax_t remove_all(const path& p); 203998a5c88SEric Fiselier uintmax_t remove_all(const path& p, error_code& ec); 204998a5c88SEric Fiselier 205998a5c88SEric Fiselier void rename(const path& from, const path& to); 206998a5c88SEric Fiselier void rename(const path& from, const path& to, error_code& ec) noexcept; 207998a5c88SEric Fiselier 208998a5c88SEric Fiselier void resize_file(const path& p, uintmax_t size); 209998a5c88SEric Fiselier void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; 210998a5c88SEric Fiselier 211998a5c88SEric Fiselier space_info space(const path& p); 212998a5c88SEric Fiselier space_info space(const path& p, error_code& ec) noexcept; 213998a5c88SEric Fiselier 214998a5c88SEric Fiselier file_status status(const path& p); 215998a5c88SEric Fiselier file_status status(const path& p, error_code& ec) noexcept; 216998a5c88SEric Fiselier 217998a5c88SEric Fiselier bool status_known(file_status s) noexcept; 218998a5c88SEric Fiselier 219998a5c88SEric Fiselier file_status symlink_status(const path& p); 220998a5c88SEric Fiselier file_status symlink_status(const path& p, error_code& ec) noexcept; 221998a5c88SEric Fiselier 222998a5c88SEric Fiselier path temp_directory_path(); 223998a5c88SEric Fiselier path temp_directory_path(error_code& ec); 224998a5c88SEric Fiselier 225998a5c88SEric Fiselier path weakly_canonical(path const& p); 226998a5c88SEric Fiselier path weakly_canonical(path const& p, error_code& ec); 227998a5c88SEric Fiselier 2281fa27f2aSJoe Loser} // namespace std::filesystem 229998a5c88SEric Fiselier 2301fa27f2aSJoe Losertemplate <> 2311fa27f2aSJoe Loserinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::directory_iterator> = true; 2321fa27f2aSJoe Losertemplate <> 2331fa27f2aSJoe Loserinline constexpr bool std::ranges::enable_borrowed_range<std::filesystem::recursive_directory_iterator> = true; 2341fa27f2aSJoe Loser 2351fa27f2aSJoe Losertemplate <> 2361fa27f2aSJoe Loserinline constexpr bool std::ranges::enable_view<std::filesystem::directory_iterator> = true; 2371fa27f2aSJoe Losertemplate <> 2381fa27f2aSJoe Loserinline constexpr bool std::ranges::enable_view<std::filesystem::recursive_directory_iterator> = true; 239998a5c88SEric Fiselier 240998a5c88SEric Fiselier*/ 241998a5c88SEric Fiselier 242*385cc25aSLouis Dionne#include <__assert> // all public C++ headers provide the assertion handler 24323f1cd9eSNikolas Klauser#include <__config> 2447056250fSNikolas Klauser#include <__filesystem/copy_options.h> 2457056250fSNikolas Klauser#include <__filesystem/directory_entry.h> 2467056250fSNikolas Klauser#include <__filesystem/directory_iterator.h> 2477056250fSNikolas Klauser#include <__filesystem/directory_options.h> 2487056250fSNikolas Klauser#include <__filesystem/file_status.h> 2497056250fSNikolas Klauser#include <__filesystem/file_time_type.h> 2507056250fSNikolas Klauser#include <__filesystem/file_type.h> 2517056250fSNikolas Klauser#include <__filesystem/filesystem_error.h> 2527056250fSNikolas Klauser#include <__filesystem/operations.h> 2537056250fSNikolas Klauser#include <__filesystem/path.h> 2544d81a46fSArthur O'Dwyer#include <__filesystem/path_iterator.h> 2557056250fSNikolas Klauser#include <__filesystem/perm_options.h> 2567056250fSNikolas Klauser#include <__filesystem/perms.h> 2577056250fSNikolas Klauser#include <__filesystem/recursive_directory_iterator.h> 2587056250fSNikolas Klauser#include <__filesystem/space_info.h> 2597056250fSNikolas Klauser#include <__filesystem/u8path.h> 2602d0f1fa4SArthur O'Dwyer#include <compare> 261f56972e2SMarshall Clow#include <version> 262998a5c88SEric Fiselier 263933518ffSLouis Dionne#if defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) 2644e656885SMark de Wever# error "The Filesystem library is not supported since libc++ has been configured with LIBCXX_ENABLE_FILESYSTEM disabled" 265933518ffSLouis Dionne#endif 266933518ffSLouis Dionne 267998a5c88SEric Fiselier#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 268998a5c88SEric Fiselier# pragma GCC system_header 269998a5c88SEric Fiselier#endif 270998a5c88SEric Fiselier 271998a5c88SEric Fiselier#endif // _LIBCPP_FILESYSTEM 272