27#include <system_error>
40#define _AST_FS _AST fs_simple::
50 using string_type = std::string;
51 using char_type = char;
57 using std::system_error::system_error;
59 const std::string& what,
60 std::error_code ec=std::make_error_code(std::errc::operation_not_supported)
61 ): std::system_error(ec, what)
71 path(
const char_type* source) : path_(source)
73 path(
const string_type& source) : path_(source)
76 std::string string()
const{
return path_;}
79 const string_type& native()
const{
return path_;}
82 const char_type* c_str()
const{
return path_.c_str();}
85 static bool is_separator(char_type c)
88 return c ==
'/' || c ==
'\\';
94 static const char_type* separators()
103 static char_type preferred_separator()
113 path filename()
const
115 auto pos = path_.find_last_of(separators());
116 if (pos == string_type::npos)
return path_;
117 return path_.substr(pos + 1);
120 path extension()
const
122 auto name = filename().native();
123 auto pos = name.find_last_of(char_type(
'.'));
124 if (pos == string_type::npos)
return string_type();
125 return name.substr(pos);
130 auto name = filename().native();
131 auto pos = name.find_last_of(char_type(
'.'));
132 if (pos == string_type::npos)
return name;
133 return name.substr(0, pos);
136 path parent_path()
const
138 auto pos = path_.find_last_of(separators());
139 if (pos == string_type::npos)
return string_type();
140 return path_.substr(0, pos);
145 return path_.empty();
151 if (path_.empty())
return other;
152 if (other.path_.empty())
return *
this;
155 bool needs_separator = !is_separator(path_.back()) && !is_separator(other.path_.front());
156 if (needs_separator) {
157 return path_ + preferred_separator() + other.path_;
159 return path_ + other.path_;
164 *
this = *
this / other;
168 operator string_type()
const
196 file_type type()
const
251 return impl_ == other.impl_;
255 return !(*
this == other);
260 std::shared_ptr<impl> impl_;
263 void read_next_entry();
267 AST_UTIL_API
bool exists(
const path& p);
268 AST_UTIL_API uintmax_t file_size(
const path& p);
271 A_ALWAYS_INLINE
bool is_regular_file(
file_status s)
noexcept{
return s.type() == file_type::regular; }
272 A_ALWAYS_INLINE
bool is_directory(file_status s)
noexcept{
return s.type() == file_type::directory; }
273 A_ALWAYS_INLINE
bool is_directory(
const path& p)
noexcept{
return is_directory(status(p)); }
274 A_ALWAYS_INLINE
bool is_regular_file(
const path& p)
noexcept{
return is_regular_file(status(p)); }
277 AST_UTIL_API
bool create_directory(
const path& p)
noexcept;
278 AST_UTIL_API
bool create_directories(
const path& p)
noexcept;
279 AST_UTIL_API
bool remove(
const path& p)
noexcept;
280 AST_UTIL_API uintmax_t remove_all(
const path& p)
noexcept;
283 AST_UTIL_API
bool copy_file(
const path& from,
const path& to)
noexcept;
284 AST_UTIL_API
bool rename(
const path& old_p,
const path& new_p)
noexcept;
287 inline directory_iterator begin(directory_iterator iter)
noexcept
291 inline directory_iterator end(
const directory_iterator&)
noexcept
293 return directory_iterator();
303 inline bool operator==(
const path& left,
const path& right)
305 return (left.native() == right.native());
307 inline bool operator!=(
const path& left,
const path& right)
309 return (left.native() != right.native());
311 AST_UTIL_API space_info space(
const path& p);
314 AST_UTIL_API std::time_t last_write_time(
const path& p);
317 AST_UTIL_API path current_path() noexcept(false);
318 AST_UTIL_API path current_path(std::error_code& ec) noexcept;
319 AST_UTIL_API
void current_path(const path& new_path) noexcept(false);
320 AST_UTIL_API
void current_path(const path& new_path, std::error_code& ec) noexcept;
Unit none
无单位
定义 Unit.cpp:411
定义 FileSystemSimple.hpp:207
定义 FileSystemSimple.hpp:226
定义 FileSystemSimple.hpp:189
定义 FileSystemSimple.hpp:55
定义 FileSystemSimple.hpp:67
constexpr EDimension operator/(EDimension dim1, EDimension dim2) noexcept
量纲除法运算符
定义 Dimension.hpp:231
定义 FileSystemSimple.cpp:133
定义 FileSystemSimple.hpp:298