Merge branch 'master' of github.com:gulrak/filesystem

This commit is contained in:
Steffen Schuemann 2019-10-03 10:02:05 +02:00
commit 8302328ef9

View File

@ -204,8 +204,10 @@ public:
#endif #endif
}; };
#if __cplusplus < 201703L
template <typename char_type> template <typename char_type>
constexpr char_type path_helper_base<char_type>::preferred_separator; constexpr char_type path_helper_base<char_type>::preferred_separator;
#endif
// 30.10.8 class path // 30.10.8 class path
class GHC_FS_API_CLASS path class GHC_FS_API_CLASS path
@ -1211,7 +1213,7 @@ namespace detail {
GHC_INLINE bool in_range(uint32_t c, uint32_t lo, uint32_t hi) GHC_INLINE bool in_range(uint32_t c, uint32_t lo, uint32_t hi)
{ {
return ((uint32_t)(c - lo) < (hi - lo + 1)); return (static_cast<uint32_t>(c - lo) < (hi - lo + 1));
} }
GHC_INLINE bool is_surrogate(uint32_t c) GHC_INLINE bool is_surrogate(uint32_t c)
@ -1279,7 +1281,7 @@ GHC_INLINE bool validUtf8(const std::string& utf8String)
unsigned utf8_state = S_STRT; unsigned utf8_state = S_STRT;
std::uint32_t codepoint = 0; std::uint32_t codepoint = 0;
while (iter < utf8String.end()) { while (iter < utf8String.end()) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_RJCT) { if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast<uint8_t>(*iter++), codepoint)) == S_RJCT) {
return false; return false;
} }
} }
@ -1310,14 +1312,14 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
unsigned utf8_state = S_STRT; unsigned utf8_state = S_STRT;
std::uint32_t codepoint = 0; std::uint32_t codepoint = 0;
while (iter < utf8String.end()) { while (iter < utf8String.end()) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_STRT) { if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast<uint8_t>(*iter++), codepoint)) == S_STRT) {
if (codepoint <= 0xffff) { if (codepoint <= 0xffff) {
result += (typename StringType::value_type)codepoint; result += static_cast<typename StringType::value_type>(codepoint);
} }
else { else {
codepoint -= 0x10000; codepoint -= 0x10000;
result += (typename StringType::value_type)((codepoint >> 10) + 0xd800); result += static_cast<typename StringType::value_type>((codepoint >> 10) + 0xd800);
result += (typename StringType::value_type)((codepoint & 0x3ff) + 0xdc00); result += static_cast<typename StringType::value_type>((codepoint & 0x3ff) + 0xdc00);
} }
codepoint = 0; codepoint = 0;
} }
@ -1325,7 +1327,7 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
#ifdef GHC_RAISE_UNICODE_ERRORS #ifdef GHC_RAISE_UNICODE_ERRORS
throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence));
#else #else
result += (typename StringType::value_type)0xfffd; result += static_cast<typename StringType::value_type>(0xfffd);
utf8_state = S_STRT; utf8_state = S_STRT;
codepoint = 0; codepoint = 0;
#endif #endif
@ -1335,7 +1337,7 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
#ifdef GHC_RAISE_UNICODE_ERRORS #ifdef GHC_RAISE_UNICODE_ERRORS
throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence));
#else #else
result += (typename StringType::value_type)0xfffd; result += static_cast<typename StringType::value_type>(0xfffd);
#endif #endif
} }
return result; return result;
@ -1350,7 +1352,7 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
unsigned utf8_state = S_STRT; unsigned utf8_state = S_STRT;
std::uint32_t codepoint = 0; std::uint32_t codepoint = 0;
while (iter < utf8String.end()) { while (iter < utf8String.end()) {
if ((utf8_state = consumeUtf8Fragment(utf8_state, (uint8_t)*iter++, codepoint)) == S_STRT) { if ((utf8_state = consumeUtf8Fragment(utf8_state, static_cast<uint8_t>(*iter++), codepoint)) == S_STRT) {
result += static_cast<typename StringType::value_type>(codepoint); result += static_cast<typename StringType::value_type>(codepoint);
codepoint = 0; codepoint = 0;
} }
@ -1358,7 +1360,7 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
#ifdef GHC_RAISE_UNICODE_ERRORS #ifdef GHC_RAISE_UNICODE_ERRORS
throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence));
#else #else
result += (typename StringType::value_type)0xfffd; result += static_cast<typename StringType::value_type>(0xfffd);
utf8_state = S_STRT; utf8_state = S_STRT;
codepoint = 0; codepoint = 0;
#endif #endif
@ -1368,7 +1370,7 @@ inline StringType fromUtf8(const std::string& utf8String, const typename StringT
#ifdef GHC_RAISE_UNICODE_ERRORS #ifdef GHC_RAISE_UNICODE_ERRORS
throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence)); throw filesystem_error("Illegal byte sequence for unicode character.", utf8String, std::make_error_code(std::errc::illegal_byte_sequence));
#else #else
result += (typename StringType::value_type)0xfffd; result += static_cast<typename StringType::value_type>(0xfffd);
#endif #endif
} }
return result; return result;
@ -1756,7 +1758,7 @@ GHC_INLINE path resolveSymlink(const path& p, std::error_code& ec)
#else #else
size_t bufferSize = 256; size_t bufferSize = 256;
while (true) { while (true) {
std::vector<char> buffer(bufferSize, (char)0); std::vector<char> buffer(bufferSize, static_cast<char>(0));
auto rc = ::readlink(p.c_str(), buffer.data(), buffer.size()); auto rc = ::readlink(p.c_str(), buffer.data(), buffer.size());
if (rc < 0) { if (rc < 0) {
ec = detail::make_system_error(); ec = detail::make_system_error();