From 1331283f9a2a57a0c20c020f437c4a3316938f0f Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 15 Mar 2020 13:50:56 +0100 Subject: [PATCH] Update third-party ghc::filesystem to version 1.3.0. (#10939) --- src/openrct2/thirdparty/filesystem.hpp | 71 ++++++++++++++------------ 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/src/openrct2/thirdparty/filesystem.hpp b/src/openrct2/thirdparty/filesystem.hpp index 8272ec5636..56b2f7180d 100644 --- a/src/openrct2/thirdparty/filesystem.hpp +++ b/src/openrct2/thirdparty/filesystem.hpp @@ -5,32 +5,24 @@ //--------------------------------------------------------------------------------------- // // Copyright (c) 2018, Steffen Schümann -// All rights reserved. // -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // -// 1. Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. // -// 2. Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors -// may be used to endorse or promote products derived from this software without -// specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. // //--------------------------------------------------------------------------------------- // @@ -177,7 +169,7 @@ //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ghc::filesystem version in decimal (major * 10000 + minor * 100 + patch) -#define GHC_FILESYSTEM_VERSION 10208L +#define GHC_FILESYSTEM_VERSION 10300L namespace ghc { namespace filesystem { @@ -677,7 +669,7 @@ private: file_status _symlink_status; uintmax_t _file_size = 0; #ifndef GHC_OS_WINDOWS - uintmax_t _hard_link_count; + uintmax_t _hard_link_count = 0; #endif time_t _last_write_time = 0; }; @@ -1086,7 +1078,7 @@ enum class portable_error { }; GHC_FS_API std::error_code make_error_code(portable_error err); #ifdef GHC_OS_WINDOWS -GHC_FS_API std::error_code make_system_error(DWORD err = 0); +GHC_FS_API std::error_code make_system_error(uint32_t err = 0); #else GHC_FS_API std::error_code make_system_error(int err = 0); #endif @@ -1141,7 +1133,7 @@ GHC_INLINE std::error_code make_error_code(portable_error err) } #ifdef GHC_OS_WINDOWS -GHC_INLINE std::error_code make_system_error(DWORD err) +GHC_INLINE std::error_code make_system_error(uint32_t err) { return std::error_code(err ? static_cast(err) : static_cast(::GetLastError()), std::system_category()); } @@ -1602,7 +1594,14 @@ GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, ec = detail::make_error_code(detail::portable_error::not_supported); return; } +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-function-type" +#endif static CreateSymbolicLinkW_fp api_call = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateSymbolicLinkW")); +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic pop +#endif if (api_call) { if (api_call(detail::fromUtf8(new_symlink.u8string()).c_str(), detail::fromUtf8(target_name.u8string()).c_str(), to_directory ? 1 : 0) == 0) { auto result = ::GetLastError(); @@ -1619,7 +1618,14 @@ GHC_INLINE void create_symlink(const path& target_name, const path& new_symlink, GHC_INLINE void create_hardlink(const path& target_name, const path& new_hardlink, std::error_code& ec) { +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-function-type" +#endif static CreateHardLinkW_fp api_call = reinterpret_cast(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW")); +#if defined(__GNUC__) && __GNUC__ >= 8 +#pragma GCC diagnostic pop +#endif if (api_call) { if (api_call(detail::fromUtf8(new_hardlink.u8string()).c_str(), detail::fromUtf8(target_name.u8string()).c_str(), NULL) == 0) { ec = detail::make_system_error(); @@ -2537,12 +2543,12 @@ GHC_INLINE path path::stem() const { impl_string_type fn = filename().string(); if (fn != "." && fn != "..") { - impl_string_type::size_type n = fn.rfind("."); + impl_string_type::size_type n = fn.rfind('.'); if (n != impl_string_type::npos && n != 0) { - return fn.substr(0, n); + return path{fn.substr(0, n)}; } } - return fn; + return path{fn}; } GHC_INLINE path path::extension() const @@ -3544,7 +3550,7 @@ GHC_INLINE path current_path(std::error_code& ec) #else size_t pathlen = static_cast(std::max(int(::pathconf(".", _PC_PATH_MAX)), int(PATH_MAX))); std::unique_ptr buffer(new char[pathlen + 1]); - if (::getcwd(buffer.get(), pathlen) == NULL) { + if (::getcwd(buffer.get(), pathlen) == nullptr) { ec = detail::make_system_error(); return path(); } @@ -4176,7 +4182,7 @@ GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) no ec.clear(); #ifdef GHC_OS_WINDOWS if (from != to) { - if (!MoveFileW(detail::fromUtf8(from.u8string()).c_str(), detail::fromUtf8(to.u8string()).c_str())) { + if (!MoveFileExW(detail::fromUtf8(from.u8string()).c_str(), detail::fromUtf8(to.u8string()).c_str(), (DWORD)MOVEFILE_REPLACE_EXISTING)) { ec = detail::make_system_error(); } } @@ -4252,6 +4258,7 @@ GHC_INLINE space_info space(const path& p, std::error_code& ec) noexcept } return {static_cast(sfs.f_blocks * sfs.f_frsize), static_cast(sfs.f_bfree * sfs.f_frsize), static_cast(sfs.f_bavail * sfs.f_frsize)}; #else + (void)p; ec = detail::make_error_code(detail::portable_error::not_supported); return {static_cast(-1), static_cast(-1), static_cast(-1)}; #endif