Skip to content

Commit

Permalink
Building using C++20 on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kneth committed Jul 4, 2024
1 parent dd4992e commit 40a43ad
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Fixed `Table::remove_object_recursive` which wouldn't recursively follow links through a single `Mixed` property. This feature is exposed publicly on `Table` but no SDK currently uses it, so this is considered internal. ([#7829](https://github.com/realm/realm-core/issues/7829), likely since the introduction of Mixed)
* Upload completion is now tracked in a multiprocess-compatible manner ([PR #7796](https://github.com/realm/realm-core/pull/7796)).
* The local realm will assume the the client file ident of the fresh realm during a client reset. ([PR #7850](https://github.com/realm/realm-core/pull/7850))
* Building using C++20 on Windows.

----------------------------------------------

Expand Down
20 changes: 20 additions & 0 deletions src/realm/util/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ std::string make_temp_dir()
}
break;
}
#if __cplusplus < 202002L
return path.u8string();
#else
return path.string();
#endif

#else // POSIX.1-2008 version

Expand Down Expand Up @@ -374,7 +378,11 @@ std::string make_temp_file(const char* prefix)
throw SystemError(error, get_last_error_msg("GetTempFileName() failed: ", error));
}

#ifdef __cplusplus < 202002L
return std::filesystem::path(buffer).u8string();
#else
return std::filesystem::path(buffer).string();
#endif

#else // POSIX.1-2008 version

Expand Down Expand Up @@ -1573,7 +1581,11 @@ std::string File::get_path() const
std::string File::resolve(const std::string& path, const std::string& base_dir)
{
#if REALM_HAVE_STD_FILESYSTEM
#ifdef __cplusplus < 202002L
return (u8path(base_dir) / u8path(path)).lexically_normal().u8string();
#else
return (u8path(base_dir) / u8path(path)).lexically_normal().string();
#endif
#else
char dir_sep = '/';
std::string path_2 = path;
Expand Down Expand Up @@ -1615,7 +1627,11 @@ std::string File::resolve(const std::string& path, const std::string& base_dir)
std::string File::parent_dir(const std::string& path)
{
#if REALM_HAVE_STD_FILESYSTEM
#ifdef __cplusplus < 202002L
return u8path(path).parent_path().u8string(); // Throws
#else
return u8path(path).parent_path().string(); // Throws
#endif
#else
auto is_sep = [](char c) -> bool {
return c == '/' || c == '\\';
Expand Down Expand Up @@ -1864,7 +1880,11 @@ bool DirScanner::next(std::string& name)
const std::filesystem::directory_iterator end;
if (m_iterator == end)
return false;
#ifdef __cplusplus < 202002L
name = m_iterator->path().filename().u8string();
#else
name = m_iterator->path().filename().string();
#endif
m_iterator++;
return true;
}
Expand Down

0 comments on commit 40a43ad

Please sign in to comment.