File: Add misc useful API from C++17.

This commit is contained in:
Jared Boone 2016-10-01 10:44:11 -07:00
parent b9e475cbf4
commit 86f672af2b
2 changed files with 14 additions and 0 deletions

View File

@ -251,6 +251,10 @@ path& path::replace_extension(const path& replacement) {
return *this;
}
bool operator<(const path& lhs, const path& rhs) {
return lhs.native() < rhs.native();
}
bool operator>(const path& lhs, const path& rhs) {
return lhs.native() > rhs.native();
}
@ -276,6 +280,10 @@ directory_iterator& directory_iterator::operator++() {
return *this;
}
bool is_directory(const file_status s) {
return (s & AM_DIR);
}
bool is_regular_file(const file_status s) {
return !(s & AM_DIR);
}

View File

@ -158,6 +158,7 @@ private:
string_type _s;
};
bool operator<(const path& lhs, const path& rhs);
bool operator>(const path& lhs, const path& rhs);
using file_status = BYTE;
@ -178,6 +179,10 @@ struct directory_entry : public FILINFO {
return fattrib;
}
std::uintmax_t size() const {
return fsize;
};
const std::filesystem::path path() const noexcept { return { fname }; };
};
@ -221,6 +226,7 @@ inline directory_iterator end(const directory_iterator&) noexcept { return { };
inline bool operator!=(const directory_iterator& lhs, const directory_iterator& rhs) { return lhs.impl != rhs.impl; };
bool is_directory(const file_status s);
bool is_regular_file(const file_status s);
space_info space(const path& p);