1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-23 07:43:01 +01:00

Update third-party ghc::filesystem to version 1.3.0. (#10939)

This commit is contained in:
Aaron van Geffen
2020-03-15 13:50:56 +01:00
committed by GitHub
parent 18ebe73dfa
commit 1331283f9a

View File

@@ -5,32 +5,24 @@
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// //
// Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com> // Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
// All rights reserved.
// //
// Redistribution and use in source and binary forms, with or without modification, // Permission is hereby granted, free of charge, to any person obtaining a copy
// are permitted provided that the following conditions are met: // 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 // The above copyright notice and this permission notice shall be included in all
// list of conditions and the following disclaimer. // copies or substantial portions of the Software.
// //
// 2. Redistributions in binary form must reproduce the above copyright notice, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// this list of conditions and the following disclaimer in the documentation // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// and/or other materials provided with the distribution. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// 3. Neither the name of the copyright holder nor the names of its contributors // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// may be used to endorse or promote products derived from this software without // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// specific prior written permission. // SOFTWARE.
//
// 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.
// //
//--------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------
// //
@@ -177,7 +169,7 @@
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ghc::filesystem version in decimal (major * 10000 + minor * 100 + patch) // ghc::filesystem version in decimal (major * 10000 + minor * 100 + patch)
#define GHC_FILESYSTEM_VERSION 10208L #define GHC_FILESYSTEM_VERSION 10300L
namespace ghc { namespace ghc {
namespace filesystem { namespace filesystem {
@@ -677,7 +669,7 @@ private:
file_status _symlink_status; file_status _symlink_status;
uintmax_t _file_size = 0; uintmax_t _file_size = 0;
#ifndef GHC_OS_WINDOWS #ifndef GHC_OS_WINDOWS
uintmax_t _hard_link_count; uintmax_t _hard_link_count = 0;
#endif #endif
time_t _last_write_time = 0; 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); GHC_FS_API std::error_code make_error_code(portable_error err);
#ifdef GHC_OS_WINDOWS #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 #else
GHC_FS_API std::error_code make_system_error(int err = 0); GHC_FS_API std::error_code make_system_error(int err = 0);
#endif #endif
@@ -1141,7 +1133,7 @@ GHC_INLINE std::error_code make_error_code(portable_error err)
} }
#ifdef GHC_OS_WINDOWS #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<int>(err) : static_cast<int>(::GetLastError()), std::system_category()); return std::error_code(err ? static_cast<int>(err) : static_cast<int>(::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); ec = detail::make_error_code(detail::portable_error::not_supported);
return; 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<CreateSymbolicLinkW_fp>(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateSymbolicLinkW")); static CreateSymbolicLinkW_fp api_call = reinterpret_cast<CreateSymbolicLinkW_fp>(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateSymbolicLinkW"));
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
if (api_call) { if (api_call) {
if (api_call(detail::fromUtf8<std::wstring>(new_symlink.u8string()).c_str(), detail::fromUtf8<std::wstring>(target_name.u8string()).c_str(), to_directory ? 1 : 0) == 0) { if (api_call(detail::fromUtf8<std::wstring>(new_symlink.u8string()).c_str(), detail::fromUtf8<std::wstring>(target_name.u8string()).c_str(), to_directory ? 1 : 0) == 0) {
auto result = ::GetLastError(); 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) 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<CreateHardLinkW_fp>(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW")); static CreateHardLinkW_fp api_call = reinterpret_cast<CreateHardLinkW_fp>(GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "CreateHardLinkW"));
#if defined(__GNUC__) && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
if (api_call) { if (api_call) {
if (api_call(detail::fromUtf8<std::wstring>(new_hardlink.u8string()).c_str(), detail::fromUtf8<std::wstring>(target_name.u8string()).c_str(), NULL) == 0) { if (api_call(detail::fromUtf8<std::wstring>(new_hardlink.u8string()).c_str(), detail::fromUtf8<std::wstring>(target_name.u8string()).c_str(), NULL) == 0) {
ec = detail::make_system_error(); ec = detail::make_system_error();
@@ -2537,12 +2543,12 @@ GHC_INLINE path path::stem() const
{ {
impl_string_type fn = filename().string(); impl_string_type fn = filename().string();
if (fn != "." && fn != "..") { 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) { 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 GHC_INLINE path path::extension() const
@@ -3544,7 +3550,7 @@ GHC_INLINE path current_path(std::error_code& ec)
#else #else
size_t pathlen = static_cast<size_t>(std::max(int(::pathconf(".", _PC_PATH_MAX)), int(PATH_MAX))); size_t pathlen = static_cast<size_t>(std::max(int(::pathconf(".", _PC_PATH_MAX)), int(PATH_MAX)));
std::unique_ptr<char[]> buffer(new char[pathlen + 1]); std::unique_ptr<char[]> buffer(new char[pathlen + 1]);
if (::getcwd(buffer.get(), pathlen) == NULL) { if (::getcwd(buffer.get(), pathlen) == nullptr) {
ec = detail::make_system_error(); ec = detail::make_system_error();
return path(); return path();
} }
@@ -4176,7 +4182,7 @@ GHC_INLINE void rename(const path& from, const path& to, std::error_code& ec) no
ec.clear(); ec.clear();
#ifdef GHC_OS_WINDOWS #ifdef GHC_OS_WINDOWS
if (from != to) { if (from != to) {
if (!MoveFileW(detail::fromUtf8<std::wstring>(from.u8string()).c_str(), detail::fromUtf8<std::wstring>(to.u8string()).c_str())) { if (!MoveFileExW(detail::fromUtf8<std::wstring>(from.u8string()).c_str(), detail::fromUtf8<std::wstring>(to.u8string()).c_str(), (DWORD)MOVEFILE_REPLACE_EXISTING)) {
ec = detail::make_system_error(); 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<uintmax_t>(sfs.f_blocks * sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bfree * sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bavail * sfs.f_frsize)}; return {static_cast<uintmax_t>(sfs.f_blocks * sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bfree * sfs.f_frsize), static_cast<uintmax_t>(sfs.f_bavail * sfs.f_frsize)};
#else #else
(void)p;
ec = detail::make_error_code(detail::portable_error::not_supported); ec = detail::make_error_code(detail::portable_error::not_supported);
return {static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1)}; return {static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1), static_cast<uintmax_t>(-1)};
#endif #endif