filesystem

标准库标头<filesystem>

此标头是文件系统支持图书馆。

在命名空间文件系统中定义

*。

路径%28C++17%29表示路径%28类%29

文件系统[医]错误%28C++17%29文件系统错误中引发的异常%28class%29

目录[医]输入%28C++17%29 a目录条目%28类%29

目录[医]迭代器%28C++17%29一个迭代器到目录%28class%29的内容

递归[医]目录[医]迭代器%28C++17%29到目录及其子目录的迭代器%28class%29

档案[医]状态%28C++17%29表示文件类型和权限%28class%29

空间[医]INFO%28C++17%29有关文件系统上可用空间的信息%28class%29

档案[医]类型%28C++17%29文件类型%28 enum%29

Perms%28C++17%29标识文件系统权限%28 enum%29

复制[医]选项%28C++17%29指定复制操作的语义%28 enum%29

目录[医]选项%28C++17%29选项用于迭代目录内容%28 enum%29

档案[医]时间[医]类型%28C++17%29表示文件时值%28

功能

u8path%28C++17%29从utf-8编码源%28函数%29创建路径。

绝对系统[医]完成%28C++17%29%28C++17%29构成一个绝对路径将路径转换为复制操作系统特定行为的绝对路径%28功能%29

标准弱[医]规范%28C++17%29构成规范路径%28功能%29

相对接近%28C++17%29构成相对路径%28函数%29

复制%28C++17%29拷贝文件或目录%28功能%29

复制[医]文件%28C++17%29拷贝文件内容%28功能%29

复制[医]符号链接%28C++17%29复制符号链接%28功能%29

创造[医]创制[医]目录%28C++17%29%28C++17%29创建新目录%28功能%29

创造[医]硬[医]链接%28C++17%29创建硬链接%28功能%29

创造[医]符号创建[医]目录[医]符号链接%28C++17%29%28C++17%29创建符号链接%28函数%29

电流[医]路径%28C++17%29返回当前工作目录%28功能%29

存在%28C++17%29检查路径是否引用现有文件系统对象%28功能%29

等效%28C++17%29检查两个路径是否引用同一个文件系统对象%28功能%29

档案[医]大小%28C++17%29返回文件%28函数%29的大小

硬[医]链接[医]计数%28C++17%29返回引用特定文件%28函数%29的硬链接数

最后[医]写[医]时间%28C++17%29获取或设置上次数据修改的时间%28函数%29

权限%28C++17%29修改文件访问权限%28功能%29

读[医]符号链接%28C++17%29获得符号链接%28功能%29的目标

移除[医]所有%28C++17%29%28C++17%29删除一个文件或空目录及其所有内容,递归%28函数%29

重命名%28C++17%29移动或重命名文件或目录%28功能%29

调整尺寸[医]文件%28C++17%29通过截断或零填充%28函数%29更改常规文件的大小。

空间%28C++17%29确定文件系统上可用的空闲空间%28功能%29

状态符号链接[医]状态%28C++17%29%28C++17%29确定文件属性确定文件属性,检查符号链接目标%28功能%29

温度[医]目录[医]路径%28C++17%29返回一个适合临时文件%28功能%29的目录

文件类型

是[医]块[医]文件%28C++17%29检查给定路径是否指向块设备%28功能%29

是[医]字[医]文件%28C++17%29检查给定路径是否指向字符设备%28功能%29

是[医]目录%28C++17%29检查给定路径是否指向目录%28函数%29

是[医]空%28C++17%29检查给定路径是指向空文件还是目录%28函数%29

是[医]FIFO%28C++17%29检查给定路径是否引用指定管道%28功能%29

是[医]其他%28C++17%29检查参数是否引用其他文件%28函数%29

是[医]正规化[医]文件%28C++17%29检查参数是否引用常规文件%28函数%29

是[医]套接字%28C++17%29检查参数是否引用了命名的IPC套接字%28功能%29

是[医]符号链接%28C++17%29检查参数是否引用符号链接%28函数%29

地位[医]已知%28C++17%29检查文件状态是否已知%28功能%29

简介

二次

namespace std::filesystem { // paths class path; // path non-member functions void swap(path& lhs, path& rhs) noexcept; size_t hash_value(const path& p) noexcept; bool operator==(const path& lhs, const path& rhs) noexcept; bool operator!=(const path& lhs, const path& rhs) noexcept; bool operator< (const path& lhs, const path& rhs) noexcept; bool operator<=(const path& lhs, const path& rhs) noexcept; bool operator> (const path& lhs, const path& rhs) noexcept; bool operator>=(const path& lhs, const path& rhs) noexcept; path operator/ (const path& lhs, const path& rhs // path inserter and extractor template <class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const path& p template <class charT, class traits> basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>& is, path& p // path factory functions template <class Source> path u8path(const Source& source template <class InputIterator> path u8path(InputIterator first, InputIterator last // filesystem errors class filesystem_error; // directory entries class directory_entry; // directory iterators class directory_iterator; // range access for directory iterators directory_iterator begin(directory_iterator iter) noexcept; directory_iterator end(const directory_iterator&) noexcept; // recursive directory iterators class recursive_directory_iterator; // range access for recursive directory iterators recursive_directory_iterator begin(recursive_directory_iterator iter) noexcept; recursive_directory_iterator end(const recursive_directory_iterator&) noexcept; // file status class file_status; struct space_info { uintmax_t capacity; uintmax_t free; uintmax_t available; }; // enumerations enum class file_type; enum class perms; enum class copy_options; enum class directory_options; using file_time_type = chrono::time_point<trivial-clock >; // filesystem operations path absolute(const path& p, const path& base = current_path() path canonical(const path& p, const path& base = current_path() path canonical(const path& p, error_code& ec path canonical(const path& p, const path& base, error_code& ec void copy(const path& from, const path& to void copy(const path& from, const path& to, error_code& ec) noexcept; void copy(const path& from, const path& to, copy_options options void copy(const path& from, const path& to, copy_options options, error_code& ec) noexcept; bool copy_file(const path& from, const path& to bool copy_file(const path& from, const path& to, error_code& ec) noexcept; bool copy_file(const path& from, const path& to, copy_options option bool copy_file(const path& from, const path& to, copy_options option, error_code& ec) noexcept; void copy_symlink(const path& existing_symlink, const path& new_symlink void copy_symlink(const path& existing_symlink, const path& new_symlink, error_code& ec) noexcept; bool create_directories(const path& p bool create_directories(const path& p, error_code& ec) noexcept; bool create_directory(const path& p bool create_directory(const path& p, error_code& ec) noexcept; bool create_directory(const path& p, const path& attributes bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept; void create_directory_symlink(const path& to, const path& new_symlink void create_directory_symlink(const path& to, const path& new_symlink, error_code& ec) noexcept; void create_hard_link(const path& to, const path& new_hard_link void create_hard_link(const path& to, const path& new_hard_link, error_code& ec) noexcept; void create_symlink(const path& to, const path& new_symlink void create_symlink(const path& to, const path& new_symlink, error_code& ec) noexcept; path current_path( path current_path(error_code& ec void current_path(const path& p void current_path(const path& p, error_code& ec) noexcept; bool exists(file_status s) noexcept; bool exists(const path& p bool exists(const path& p, error_code& ec) noexcept; bool equivalent(const path& p1, const path& p2 bool equivalent(const path& p1, const path& p2, error_code& ec) noexcept; uintmax_t file_size(const path& p uintmax_t file_size(const path& p, error_code& ec) noexcept; uintmax_t hard_link_count(const path& p uintmax_t hard_link_count(const path& p, error_code& ec) noexcept; bool is_block_file(file_status s) noexcept; bool is_block_file(const path& p bool is_block_file(const path& p, error_code& ec) noexcept; bool is_character_file(file_status s) noexcept; bool is_character_file(const path& p bool is_character_file(const path& p, error_code& ec) noexcept; bool is_directory(file_status s) noexcept; bool is_directory(const path& p bool is_directory(const path& p, error_code& ec) noexcept; bool is_empty(const path& p bool is_empty(const path& p, error_code& ec) noexcept; bool is_fifo(file_status s) noexcept; bool is_fifo(const path& p bool is_fifo(const path& p, error_code& ec) noexcept; bool is_other(file_status s) noexcept; bool is_other(const path& p bool is_other(const path& p, error_code& ec) noexcept; bool is_regular_file(file_status s) noexcept; bool is_regular_file(const path& p bool is_regular_file(const path& p, error_code& ec) noexcept; bool is_socket(file_status s) noexcept; bool is_socket(const path& p bool is_socket(const path& p, error_code& ec) noexcept; bool is_symlink(file_status s) noexcept; bool is_symlink(const path& p bool is_symlink(const path& p, error_code& ec) noexcept; file_time_type last_write_time(const path& p file_time_type last_write_time(const path& p, error_code& ec) noexcept; void last_write_time(const path& p, file_time_type new_time void last_write_time(const path& p, file_time_type new_time, error_code& ec) noexcept; void permissions(const path& p, perms prms void permissions(const path& p, perms prms, error_code& ec path proximate(const path& p, error_code& ec path proximate(const path& p, const path& base = current_path() path proximate(const path& p, const path& base, error_code& ec path read_symlink(const path& p path read_symlink(const path& p, error_code& ec path relative(const path& p, error_code& ec path relative(const path& p, const path& base = current_path() path relative(const path& p, const path& base, error_code& ec bool remove(const path& p bool remove(const path& p, error_code& ec) noexcept; uintmax_t remove_all(const path& p uintmax_t remove_all(const path& p, error_code& ec) noexcept; void rename(const path& from, const path& to void rename(const path& from, const path& to, error_code& ec) noexcept; void resize_file(const path& p, uintmax_t size void resize_file(const path& p, uintmax_t size, error_code& ec) noexcept; space_info space(const path& p space_info space(const path& p, error_code& ec) noexcept; file_status status(const path& p file_status status(const path& p, error_code& ec) noexcept; bool status_known(file_status s) noexcept; file_status symlink_status(const path& p file_status symlink_status(const path& p, error_code& ec) noexcept; path system_complete(const path& p path system_complete(const path& p, error_code& ec path temp_directory_path( path temp_directory_path(error_code& ec path weakly_canonical(const path& p path weakly_canonical(const path& p, error_code& ec }

二次

类std::filesystem::path

二次

class path { public: using value_type = /*see definition*/ ; using string_type = basic_string<value_type>; static constexpr value_type preferred_separator = /*see definition*/ ; // constructors and destructor path() noexcept; path(const path& p path(path&& p) noexcept; path(string_type&& source template <class Source> path(const Source& source template <class InputIterator> path(InputIterator first, InputIterator last template <class Source> path(const Source& source, const locale& loc template <class InputIterator> path(InputIterator first, InputIterator last, const locale& loc ~path( // assignments path& operator=(const path& p path& operator=(path&& p) noexcept; path& operator=(string_type&& source path& assign(string_type&& source template <class Source> path& operator=(const Source& source template <class Source> path& assign(const Source& source) template <class InputIterator> path& assign(InputIterator first, InputIterator last // appends path& operator/=(const path& p template <class Source> path& operator/=(const Source& source template <class Source> path& append(const Source& source template <class InputIterator> path& append(InputIterator first, InputIterator last // concatenation path& operator+=(const path& x path& operator+=(const string_type& x path& operator+=(basic_string_view<value_type> x path& operator+=(const value_type* x path& operator+=(value_type x template <class Source> path& operator+=(const Source& x template <class EcharT> path& operator+=(EcharT x template <class Source> path& concat(const Source& x template <class InputIterator> path& concat(InputIterator first, InputIterator last // modifiers void clear() noexcept; path& make_preferred( path& remove_filename( path& replace_filename(const path& replacement path& replace_extension(const path& replacement = path() void swap(path& rhs) noexcept; // native format observers const string_type& native() const noexcept; const value_type* c_str() const noexcept; operator string_type() const; template <class EcharT, class traits = char_traits<EcharT>, class Allocator = allocator<EcharT>> basic_string<EcharT, traits, Allocator> string(const Allocator& a = Allocator()) const; std::string string() const; std::wstring wstring() const; std::string u8string() const; std::u16string u16string() const; std::u32string u32string() const; // generic format observers template <class EcharT, class traits = char_traits<EcharT>, class Allocator = allocator<EcharT>> basic_string<EcharT, traits, Allocator> generic_string(const Allocator& a = Allocator()) const; std::string generic_string() const; std::wstring generic_wstring() const; std::string generic_u8string() const; std::u16string generic_u16string() const; std::u32string generic_u32string() const; // compare int compare(const path& p) const noexcept; int compare(const string_type& s) const; int compare(basic_string_view<value_type> s) const; int compare(const value_type* s) const; // decomposition path root_name() const; path root_directory() const; path root_path() const; path relative_path() const; path parent_path() const; path filename() const; path stem() const; path extension() const; // query bool empty() const noexcept; bool has_root_name() const; bool has_root_directory() const; bool has_root_path() const; bool has_relative_path() const; bool has_parent_path() const; bool has_filename() const; bool has_stem() const; bool has_extension() const; bool is_absolute() const; bool is_relative() const; // generation path lexically_normal() const; path lexically_relative(const path& base) const; path lexically_proximate(const path& base) const; // iterators class iterator; using const_iterator = iterator; iterator begin() const; iterator end() const; private: string_type pathstring; // exposition only };

二次

类std::filesystem::filesystem_error

二次

class filesystem_error : public system_error { public: filesystem_error(const string& what_arg, error_code ec filesystem_error(const string& what_arg, const path& p1, error_code ec filesystem_error(const string& what_arg, const path& p1, const path& p2, error_code ec const path& path1() const noexcept; const path& path2() const noexcept; const char* what() const noexcept override; };

二次

类std::filesystem::file_status

二次

class file_status { public: // constructors and destructor explicit file_status(file_type ft = file_type::none, perms prms = perms::unknown) noexcept; file_status(const file_status&) noexcept = default; file_status(file_status&&) noexcept = default; ~file_status( // assignments: file_status& operator=(const file_status&) noexcept = default; file_status& operator=(file_status&&) noexcept = default; // modifiers void type(file_type ft) noexcept; void permissions(perms prms) noexcept; // observers file_type type() const noexcept; perms permissions() const noexcept; };

二次

类std::directory_entry

二次

class directory_entry { public: // constructors and destructor explicit directory_entry(const path& p directory_entry() noexcept = default; directory_entry(const directory_entry&) = default; directory_entry(directory_entry&&) noexcept = default; ~directory_entry( // assignments: directory_entry& operator=(const directory_entry&) = default; directory_entry& operator=(directory_entry&&) noexcept = default; // modifiers void assign(const path& p void replace_filename(const path& p // observers const path& path() const noexcept; operator const path&() const noexcept; file_status status() const; file_status status(error_code& ec) const noexcept; file_status symlink_status() const; file_status symlink_status(error_code& ec) const noexcept; bool operator< (const directory_entry& rhs) const noexcept; bool operator==(const directory_entry& rhs) const noexcept; bool operator!=(const directory_entry& rhs) const noexcept; bool operator<=(const directory_entry& rhs) const noexcept; bool operator> (const directory_entry& rhs) const noexcept; bool operator>=(const directory_entry& rhs) const noexcept; private: path pathobject; // exposition only };

二次

类std::filesystem::directory_iterator

二次

class directory_iterator { public: using iterator_category = input_iterator_tag; using value_type = directory_entry; using difference_type = ptrdiff_t; using pointer = const directory_entry*; using reference = const directory_entry&; // member functions directory_iterator() noexcept; explicit directory_iterator(const path& p directory_iterator(const path& p, directory_options options directory_iterator(const path& p, error_code& ec) noexcept; directory_iterator(const path& p, directory_options options, error_code& ec) noexcept; directory_iterator(const directory_iterator& rhs directory_iterator(directory_iterator&& rhs) noexcept; ~directory_iterator( directory_iterator& operator=(const directory_iterator& rhs directory_iterator& operator=(directory_iterator&& rhs) noexcept; const directory_entry& operator*() const; const directory_entry* operator->() const; directory_iterator& operator++( directory_iterator& increment(error_code& ec) noexcept; // other members as required by input iterators };

二次

类std::filesystem::recursive_directory_iterator

二次

class recursive_directory_iterator { public: using iterator_category = input_iterator_tag; using value_type = directory_entry; using difference_type = ptrdiff_t; using pointer = const directory_entry*; using reference = const directory_entry&; // constructors and destructor recursive_directory_iterator() noexcept; explicit recursive_directory_iterator(const path& p recursive_directory_iterator(const path& p, directory_options options recursive_directory_iterator(const path& p, directory_options options, error_code& ec) noexcept; recursive_directory_iterator(const path& p, error_code& ec) noexcept; recursive_directory_iterator(const recursive_directory_iterator& rhs recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept; ~recursive_directory_iterator( // observers directory_options options() const; int depth() const; bool recursion_pending() const; const directory_entry& operator*() const; const directory_entry* operator->() const; // modifiers recursive_directory_iterator& operator=(const recursive_directory_iterator& rhs recursive_directory_iterator& operator=(recursive_directory_iterator&& rhs) noexcept; recursive_directory_iterator& operator++( recursive_directory_iterator& increment(error_code& ec) noexcept; void pop( void pop(error_code& ec void disable_recursion_pending( // other members as required by input iterators };

二次

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/报头/文件系统