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);
132 auto name = filename().native();
133 auto pos = name.find_last_of(char_type(
'.'));
134 if (pos == string_type::npos)
return name;
135 return name.substr(0, pos);
138 path parent_path()
const
140 auto pos = path_.find_last_of(separators());
141 if (pos == string_type::npos)
return string_type();
142 return path_.substr(0, pos);
145 bool is_absolute()
const
147 if (path_.empty())
return false;
151 if (path_.size() >= 2 && is_separator(path_[0]) && is_separator(path_[1]))
155 if (path_.size() >= 3
156 && ((path_[0] >=
'A' && path_[0] <=
'Z') || (path_[0] >=
'a' && path_[0] <=
'z'))
158 && is_separator(path_[2]))
162 if (is_separator(path_[0]))
168 return is_separator(path_[0]);
172 bool is_relative()
const
174 return !is_absolute();
179 return path_.empty();
185 if (path_.empty())
return other;
186 if (other.path_.empty())
return *
this;
189 bool needs_separator = !is_separator(path_.back()) && !is_separator(other.path_.front());
190 if (needs_separator) {
191 return path_ + preferred_separator() + other.path_;
193 return path_ + other.path_;
196 path& operator/=(
const path& other)
198 *
this = *
this / other;
202 operator string_type()
const
230 file_type type()
const
285 return impl_ == other.impl_;
289 return !(*
this == other);
294 std::shared_ptr<impl> impl_;
297 void read_next_entry();
301 AST_UTIL_API
bool exists(
const path& p);
302 AST_UTIL_API uintmax_t file_size(
const path& p);
305 A_ALWAYS_INLINE
bool is_regular_file(
file_status s)
noexcept{
return s.type() == file_type::regular; }
306 A_ALWAYS_INLINE
bool is_directory(file_status s)
noexcept{
return s.type() == file_type::directory; }
307 A_ALWAYS_INLINE
bool is_directory(
const path& p)
noexcept{
return is_directory(status(p)); }
308 A_ALWAYS_INLINE
bool is_regular_file(
const path& p)
noexcept{
return is_regular_file(status(p)); }
311 AST_UTIL_API
bool create_directory(
const path& p)
noexcept;
312 AST_UTIL_API
bool create_directories(
const path& p)
noexcept;
313 AST_UTIL_API
bool remove(
const path& p)
noexcept;
314 AST_UTIL_API uintmax_t remove_all(
const path& p)
noexcept;
317 AST_UTIL_API
bool copy_file(
const path& from,
const path& to)
noexcept;
318 AST_UTIL_API
bool rename(
const path& old_p,
const path& new_p)
noexcept;
321 inline directory_iterator begin(directory_iterator iter)
noexcept
325 inline directory_iterator end(
const directory_iterator&)
noexcept
327 return directory_iterator();
337 inline bool operator==(
const path& left,
const path& right)
339 return (left.native() == right.native());
341 inline bool operator!=(
const path& left,
const path& right)
343 return (left.native() != right.native());
345 AST_UTIL_API space_info space(
const path& p);
348 AST_UTIL_API std::time_t last_write_time(
const path& p);
351 AST_UTIL_API path current_path() noexcept(false);
352 AST_UTIL_API path current_path(std::error_code& ec) noexcept;
353 AST_UTIL_API
void current_path(const path& new_path) noexcept(false);
354 AST_UTIL_API
void current_path(const path& new_path, std::error_code& ec) noexcept;
Unit none
无单位
定义 Unit.cpp:421
定义 FileSystemSimple.hpp:241
定义 FileSystemSimple.hpp:260
定义 FileSystemSimple.hpp:223
定义 FileSystemSimple.hpp:55
定义 FileSystemSimple.hpp:67
path stem() const
获取文件名的无扩展名部分
定义 FileSystemSimple.hpp:130
constexpr EDimension operator/(EDimension dim1, EDimension dim2) noexcept
量纲除法运算符
定义 Dimension.hpp:232
定义 FileSystemSimple.cpp:133
定义 FileSystemSimple.hpp:332