1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 19:43:06 +01:00

Extract IsPathSeparator to Platform

This commit is contained in:
Tulio Leao
2021-03-25 23:45:01 -03:00
parent f372117939
commit f15bbd220a
4 changed files with 16 additions and 12 deletions

View File

@@ -13,6 +13,7 @@
#endif
#include "../localisation/Language.h"
#include "../platform/Platform2.h"
#include "../platform/platform.h"
#include "../util/Util.h"
#include "File.h"
@@ -30,15 +31,6 @@ namespace Path
return safe_strcat_path(buffer, src, bufferSize);
}
static constexpr bool IsPathSeparator(char c)
{
#ifdef _WIN32
if (c == '\\')
return true;
#endif
return c == '/';
}
std::string Combine(std::string_view a, std::string_view b)
{
if (a.empty())
@@ -47,9 +39,9 @@ namespace Path
return std::string(a);
auto aEnd = a.back();
auto bBegin = b.front();
if (IsPathSeparator(aEnd))
if (Platform::IsPathSeparator(aEnd))
{
if (IsPathSeparator(bBegin))
if (Platform::IsPathSeparator(bBegin))
{
return std::string(a) + std::string(b.substr(1));
}
@@ -60,7 +52,7 @@ namespace Path
}
else
{
if (IsPathSeparator(bBegin))
if (Platform::IsPathSeparator(bBegin))
{
return std::string(a) + std::string(b);
}

View File

@@ -173,6 +173,11 @@ namespace Platform
}
return lastModified;
}
bool IsPathSeparator(char c)
{
return c == '/';
}
} // namespace Platform
#endif

View File

@@ -553,6 +553,12 @@ namespace Platform
}
return lastModified;
}
bool IsPathSeparator(char c)
{
return c == '\\' || c == '/';
}
} // namespace Platform
#endif

View File

@@ -35,6 +35,7 @@ namespace Platform
std::string GetCurrentExecutablePath();
std::string GetCurrentExecutableDirectory();
bool FileExists(const std::string path);
bool IsPathSeparator(char c);
uint64_t GetLastModified(const std::string& path);
rct2_time GetTimeLocal();
rct2_date GetDateLocal();