PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
native_path.h
1#pragma once
2
3#include <algorithm>
4#include <filesystem>
5
6namespace pixelbullet::filesystem
7{
8[[nodiscard]] inline std::filesystem::path to_native_file_io_path(const std::filesystem::path& path)
9{
10#ifdef _WIN32
11 if (!path.is_absolute())
12 {
13 return path;
14 }
15
16 std::wstring native_path = path.native();
17 std::replace(native_path.begin(), native_path.end(), L'/', L'\\');
18 if (native_path.rfind(L"\\\\?\\", 0u) == 0u)
19 {
20 return path;
21 }
22 if (native_path.rfind(L"\\\\", 0u) == 0u)
23 {
24 return std::filesystem::path(L"\\\\?\\UNC" + native_path.substr(1u));
25 }
26 return std::filesystem::path(L"\\\\?\\" + native_path);
27#else
28 return path;
29#endif
30}
31} // namespace pixelbullet::filesystem