upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/file_system.cpp
diff options
context:
space:
mode:
authorgabrielsteglich <63128571+gabrielsteglich@users.noreply.github.com>2026-11-23 16:37:22 -0300
committergabrielsteglich <63128571+gabrielsteglich@users.noreply.github.com>2026-11-23 16:37:22 -0300
commit17f41ec69c472ff3283284b8df6c589e561b74cd (patch)
tree38bdb571ac904b98069743d30f8995bb3c0cbf97 /runtime/shims/file_system.cpp
parent867d922f09b86583859796a174df89555fb32da8 (diff)
Open long backing paths for guest file shims
Diffstat (limited to 'runtime/shims/file_system.cpp')
-rw-r--r--runtime/shims/file_system.cpp83
1 files changed, 55 insertions, 28 deletions
diff --git a/runtime/shims/file_system.cpp b/runtime/shims/file_system.cpp
index a7b64d75c..4175156e8 100644
--- a/runtime/shims/file_system.cpp
+++ b/runtime/shims/file_system.cpp
@@ -119,6 +119,29 @@ bool lies_under(const std::wstring& path, const std::filesystem::path& root) {
119 return p.compare(0, base.size(), base) == 0 && (p.size() == base.size() || p[base.size()] == L'\\'); 119 return p.compare(0, base.size(), base) == 0 && (p.size() == base.size() || p[base.size()] == L'\\');
120} 120}
121 121
122// The console shim may resolve even a short guest name to an extended-length host path. GetFullPathNameW
123// applies the ordinary DOS path rules (including trailing dots and spaces) before the extended prefix disables
124// that normalization. The headroom is for CreateDirectoryW's shorter limit on an unprefixed directory name.
125std::filesystem::path win32_io_path(const std::filesystem::path& path) {
126 const auto& native = path.native();
127 constexpr size_t kDirectoryPathLimit = MAX_PATH - 12;
128 if (native.size() < kDirectoryPathLimit || !path.is_absolute() ||
129 native.starts_with(L"\\\\?\\") || native.starts_with(L"\\\\.\\"))
130 return path;
131
132 const DWORD capacity = ::GetFullPathNameW(native.c_str(), 0, nullptr, nullptr);
133 if (capacity == 0) return path;
134 std::wstring full(capacity, L'\0');
135 const DWORD size = ::GetFullPathNameW(native.c_str(), capacity, full.data(), nullptr);
136 if (size == 0 || size >= capacity) return path;
137 full.resize(size);
138
139 // DOS device names such as NUL can normalize to a device path. Leave those to the native API as before.
140 if (full.starts_with(L"\\\\.\\")) return path;
141 if (full.starts_with(L"\\\\")) return std::filesystem::path(L"\\\\?\\UNC\\" + full.substr(2));
142 return std::filesystem::path(L"\\\\?\\" + full);
143}
144
122// "G:\x" is the installed package, like "GAME:\x", and "T:\x" a scratch folder the title may write to, the way the 145// "G:\x" is the installed package, like "GAME:\x", and "T:\x" a scratch folder the title may write to, the way the
123// other console layers map those two drives (RT-218). Only the executable can say which spelling the title uses, so 146// other console layers map those two drives (RT-218). Only the executable can say which spelling the title uses, so
124// a host drive of the same letter must keep working: a path under --game-dir or the overlay (a package on drive G:, 147// a host drive of the same letter must keep working: a path under --game-dir or the overlay (a package on drive G:,
@@ -151,7 +174,7 @@ Parsed parse_console(const std::wstring& path, std::vector<std::wstring>& parts)
151 const std::filesystem::path overlay = roots().overlay; 174 const std::filesystem::path overlay = roots().overlay;
152 const DWORD last_error = ::GetLastError(); 175 const DWORD last_error = ::GetLastError();
153 std::error_code ec; 176 std::error_code ec;
154 if (!overlay.empty()) std::filesystem::create_directories(overlay / kScratchDir, ec); 177 if (!overlay.empty()) std::filesystem::create_directories(win32_io_path(overlay / kScratchDir), ec);
155 ::SetLastError(last_error); 178 ::SetLastError(last_error);
156 } 179 }
157 const size_t floor = parts.size(); // ".." may not climb out of the drive's own root 180 const size_t floor = parts.size(); // ".." may not climb out of the drive's own root
@@ -194,6 +217,10 @@ std::filesystem::path join(const std::filesystem::path& root, const std::vector<
194 return p; 217 return p;
195} 218}
196 219
220std::filesystem::path disk_path(const std::filesystem::path& root, const std::vector<std::wstring>& parts) {
221 return win32_io_path(join(root, parts));
222}
223
197bool drive_root(const std::wstring& path, const std::vector<std::wstring>& parts) { 224bool drive_root(const std::wstring& path, const std::vector<std::wstring>& parts) {
198 size_t prefix_length = 0; 225 size_t prefix_length = 0;
199 return parts.empty() || (parts.size() == 1 && console_drive(path, prefix_length) == Drive::Scratch); 226 return parts.empty() || (parts.size() == 1 && console_drive(path, prefix_length) == Drive::Scratch);
@@ -224,11 +251,13 @@ bool deleted(const std::filesystem::path& overlay, const std::vector<std::wstrin
224 // Only regular files are deletion markers; parent directories inside .gta6rt-deleted/ exist only to hold markers 251 // Only regular files are deletion markers; parent directories inside .gta6rt-deleted/ exist only to hold markers
225 // for nested deleted files and must not hide the corresponding ancestor directories in the package. 252 // for nested deleted files and must not hide the corresponding ancestor directories in the package.
226 const std::filesystem::path m = marker(overlay, parts); 253 const std::filesystem::path m = marker(overlay, parts);
227 return std::filesystem::is_regular_file(m, ec) || std::filesystem::is_regular_file(m / kRemovedDirMarker, ec); 254 return std::filesystem::is_regular_file(win32_io_path(m), ec) ||
255 std::filesystem::is_regular_file(win32_io_path(m / kRemovedDirMarker), ec);
228} 256}
229 257
230// Writes an empty hidden marker file. On failure `error` holds the reason. 258// Writes an empty hidden marker file. On failure `error` holds the reason.
231bool write_marker(const std::filesystem::path& mark, DWORD& error) { 259bool write_marker(const std::filesystem::path& path, DWORD& error) {
260 const std::filesystem::path mark = win32_io_path(path);
232 std::error_code ec; 261 std::error_code ec;
233 std::filesystem::create_directories(mark.parent_path(), ec); 262 std::filesystem::create_directories(mark.parent_path(), ec);
234 if (ec) { 263 if (ec) {
@@ -247,7 +276,7 @@ bool write_marker(const std::filesystem::path& mark, DWORD& error) {
247 276
248// Flushes a file the shim wrote on the title's behalf, for MOVEFILE_WRITE_THROUGH. On failure `error` holds the reason. 277// Flushes a file the shim wrote on the title's behalf, for MOVEFILE_WRITE_THROUGH. On failure `error` holds the reason.
249bool flush_file(const std::filesystem::path& path, DWORD& error) { 278bool flush_file(const std::filesystem::path& path, DWORD& error) {
250 const HANDLE h = ::CreateFileW(path.c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, 279 const HANDLE h = ::CreateFileW(win32_io_path(path).c_str(), GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
251 nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); 280 nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
252 if (h == INVALID_HANDLE_VALUE) { 281 if (h == INVALID_HANDLE_VALUE) {
253 error = ::GetLastError(); 282 error = ::GetLastError();
@@ -276,14 +305,14 @@ View view(const Roots& r, const std::vector<std::wstring>& parts) {
276 return v; 305 return v;
277 } 306 }
278 if (!r.overlay.empty()) { 307 if (!r.overlay.empty()) {
279 const std::filesystem::path p = join(r.overlay, parts); 308 const std::filesystem::path p = disk_path(r.overlay, parts);
280 if (std::filesystem::exists(p, ec)) { 309 if (std::filesystem::exists(p, ec)) {
281 v.in_overlay = true; 310 v.in_overlay = true;
282 v.kind = std::filesystem::is_directory(p, ec) ? Kind::Directory : Kind::File; 311 v.kind = std::filesystem::is_directory(p, ec) ? Kind::Directory : Kind::File;
283 } 312 }
284 } 313 }
285 if (!r.game.empty() && !deleted(r.overlay, parts)) { 314 if (!r.game.empty() && !deleted(r.overlay, parts)) {
286 const std::filesystem::path p = join(r.game, parts); 315 const std::filesystem::path p = disk_path(r.game, parts);
287 if (std::filesystem::exists(p, ec)) { 316 if (std::filesystem::exists(p, ec)) {
288 v.in_package = true; 317 v.in_package = true;
289 if (v.kind == Kind::None) v.kind = std::filesystem::is_directory(p, ec) ? Kind::Directory : Kind::File; 318 if (v.kind == Kind::None) v.kind = std::filesystem::is_directory(p, ec) ? Kind::Directory : Kind::File;
@@ -310,7 +339,7 @@ std::vector<std::wstring> parent_of(const std::vector<std::wstring>& parts) {
310bool empty_in_view(const Roots& r, const std::vector<std::wstring>& parts) { 339bool empty_in_view(const Roots& r, const std::vector<std::wstring>& parts) {
311 std::error_code ec; 340 std::error_code ec;
312 if (!r.overlay.empty()) { 341 if (!r.overlay.empty()) {
313 const std::filesystem::path p = join(r.overlay, parts); 342 const std::filesystem::path p = disk_path(r.overlay, parts);
314 for (auto it = std::filesystem::directory_iterator(p, ec); !ec && it != std::filesystem::directory_iterator(); 343 for (auto it = std::filesystem::directory_iterator(p, ec); !ec && it != std::filesystem::directory_iterator();
315 it.increment(ec)) { 344 it.increment(ec)) {
316 if (parts.empty() && internal_dir(it->path().filename().c_str())) continue; 345 if (parts.empty() && internal_dir(it->path().filename().c_str())) continue;
@@ -319,7 +348,7 @@ bool empty_in_view(const Roots& r, const std::vector<std::wstring>& parts) {
319 } 348 }
320 ec.clear(); 349 ec.clear();
321 if (!r.game.empty()) { 350 if (!r.game.empty()) {
322 const std::filesystem::path p = join(r.game, parts); 351 const std::filesystem::path p = disk_path(r.game, parts);
323 for (auto it = std::filesystem::directory_iterator(p, ec); !ec && it != std::filesystem::directory_iterator(); 352 for (auto it = std::filesystem::directory_iterator(p, ec); !ec && it != std::filesystem::directory_iterator();
324 it.increment(ec)) { 353 it.increment(ec)) {
325 std::vector<std::wstring> child = parts; 354 std::vector<std::wstring> child = parts;
@@ -350,7 +379,7 @@ Target read_target(const std::wstring& path) {
350 379
351 std::error_code ec; 380 std::error_code ec;
352 if (!r.overlay.empty()) { 381 if (!r.overlay.empty()) {
353 const std::filesystem::path overlay_path = join(r.overlay, parts); 382 const std::filesystem::path overlay_path = disk_path(r.overlay, parts);
354 if (std::filesystem::exists(overlay_path, ec)) { 383 if (std::filesystem::exists(overlay_path, ec)) {
355 Target t; 384 Target t;
356 t.path = overlay_path; 385 t.path = overlay_path;
@@ -361,7 +390,7 @@ Target read_target(const std::wstring& path) {
361 if (deleted(r.overlay, parts)) return fail(ERROR_FILE_NOT_FOUND); 390 if (deleted(r.overlay, parts)) return fail(ERROR_FILE_NOT_FOUND);
362 391
363 Target t; 392 Target t;
364 t.path = join(r.game, parts); 393 t.path = disk_path(r.game, parts);
365 return t; 394 return t;
366} 395}
367 396
@@ -388,7 +417,7 @@ Target write_target(const std::wstring& path, bool copy_up) {
388 if (!scratch && !is_folder(r, parent_of(parts))) return fail(ERROR_PATH_NOT_FOUND); 417 if (!scratch && !is_folder(r, parent_of(parts))) return fail(ERROR_PATH_NOT_FOUND);
389 418
390 Target t; 419 Target t;
391 t.path = join(r.overlay, parts); 420 t.path = disk_path(r.overlay, parts);
392 421
393 std::error_code ec; 422 std::error_code ec;
394 std::filesystem::create_directories(t.path.parent_path(), ec); 423 std::filesystem::create_directories(t.path.parent_path(), ec);
@@ -400,7 +429,7 @@ Target write_target(const std::wstring& path, bool copy_up) {
400 // A deleted package file is not there to copy: copying it up would bring the name back, and an open that keeps 429 // A deleted package file is not there to copy: copying it up would bring the name back, and an open that keeps
401 // the contents (OPEN_EXISTING, TRUNCATE_EXISTING) has to fail on it instead. CREATE_ALWAYS and CREATE_NEW still 430 // the contents (OPEN_EXISTING, TRUNCATE_EXISTING) has to fail on it instead. CREATE_ALWAYS and CREATE_NEW still
402 // make a new overlay file, which reads prefer over the package and so over the marker. 431 // make a new overlay file, which reads prefer over the package and so over the marker.
403 const std::filesystem::path package_path = join(r.game, parts); 432 const std::filesystem::path package_path = disk_path(r.game, parts);
404 // One copy-up at a time: a second thread writing the same file waits here and then finds the first one's copy, so 433 // One copy-up at a time: a second thread writing the same file waits here and then finds the first one's copy, so
405 // it neither fails on the taken name nor collides with that file's open through a rename of its own. 434 // it neither fails on the taken name nor collides with that file's open through a rename of its own.
406 static std::mutex s_copy_mutex; 435 static std::mutex s_copy_mutex;
@@ -412,9 +441,9 @@ Target write_target(const std::wstring& path, bool copy_up) {
412 // not a truncated file that reads would prefer over the package. 441 // not a truncated file that reads would prefer over the package.
413 static unsigned s_copies = 0; // under s_copy_mutex 442 static unsigned s_copies = 0; // under s_copy_mutex
414 const std::filesystem::path staging = r.overlay / kCopyDir; 443 const std::filesystem::path staging = r.overlay / kCopyDir;
415 std::filesystem::create_directories(staging, ec); 444 std::filesystem::create_directories(win32_io_path(staging), ec);
416 const std::filesystem::path tmp = 445 const std::filesystem::path tmp =
417 staging / (std::to_wstring(::GetCurrentProcessId()) + L"-" + std::to_wstring(++s_copies)); 446 win32_io_path(staging / (std::to_wstring(::GetCurrentProcessId()) + L"-" + std::to_wstring(++s_copies)));
418 // Use CopyFileW for staging because MSVC's std::filesystem::copy_file calls CopyFile2, which Wine 9 lacks. 447 // Use CopyFileW for staging because MSVC's std::filesystem::copy_file calls CopyFile2, which Wine 9 lacks.
419 if (ec) { 448 if (ec) {
420 t.error = static_cast<DWORD>(ec.value()); 449 t.error = static_cast<DWORD>(ec.value());
@@ -530,7 +559,7 @@ bool collect(const std::wstring& pattern, const std::vector<std::wstring>& parts
530 if (!r.overlay.empty()) { 559 if (!r.overlay.empty()) {
531 const std::filesystem::path marks = marker(r.overlay, dirs); 560 const std::filesystem::path marks = marker(r.overlay, dirs);
532 WIN32_FIND_DATAW m{}; 561 WIN32_FIND_DATAW m{};
533 const HANDLE mh = ::FindFirstFileW((marks / L"*").c_str(), &m); 562 const HANDLE mh = ::FindFirstFileW(win32_io_path(marks / L"*").c_str(), &m);
534 if (mh != INVALID_HANDLE_VALUE) { 563 if (mh != INVALID_HANDLE_VALUE) {
535 has_markers = true; 564 has_markers = true;
536 do { 565 do {
@@ -547,7 +576,7 @@ bool collect(const std::wstring& pattern, const std::vector<std::wstring>& parts
547 // markers of a nested delete. A missing sentinel is that ordinary answer (status() reports not_found 576 // markers of a nested delete. A missing sentinel is that ordinary answer (status() reports not_found
548 // with an error code set); any other error leaves the decision to deleted() per entry. 577 // with an error code set); any other error leaves the decision to deleted() per entry.
549 std::error_code ec; 578 std::error_code ec;
550 const auto st = std::filesystem::status(marks / m.cFileName / kRemovedDirMarker, ec); 579 const auto st = std::filesystem::status(win32_io_path(marks / m.cFileName / kRemovedDirMarker), ec);
551 if (st.type() == std::filesystem::file_type::regular) deleted_here.insert(ascii_key(m.cFileName)); 580 if (st.type() == std::filesystem::file_type::regular) deleted_here.insert(ascii_key(m.cFileName));
552 else if (st.type() != std::filesystem::file_type::not_found && ec) markers_exact = false; 581 else if (st.type() != std::filesystem::file_type::not_found && ec) markers_exact = false;
553 } while (::FindNextFileW(mh, &m)); 582 } while (::FindNextFileW(mh, &m));
@@ -580,10 +609,8 @@ bool collect(const std::wstring& pattern, const std::vector<std::wstring>& parts
580 609
581 auto add_root = [&](const std::filesystem::path& root, bool overlay_root) { 610 auto add_root = [&](const std::filesystem::path& root, bool overlay_root) {
582 if (root.empty()) return; 611 if (root.empty()) return;
583 std::filesystem::path search = join(root, dirs);
584 search /= leaf;
585 WIN32_FIND_DATAW found{}; 612 WIN32_FIND_DATAW found{};
586 const HANDLE h = ::FindFirstFileW(search.c_str(), &found); 613 const HANDLE h = ::FindFirstFileW(win32_io_path(join(root, dirs) / leaf).c_str(), &found);
587 if (h == INVALID_HANDLE_VALUE) return; 614 if (h == INVALID_HANDLE_VALUE) return;
588 do { 615 do {
589 if (overlay_root && internal_dir(found.cFileName)) continue; 616 if (overlay_root && internal_dir(found.cFileName)) continue;
@@ -917,13 +944,13 @@ BOOL WINAPI delete_file_w(LPCWSTR name) {
917 944
918 bool removed = false; 945 bool removed = false;
919 std::error_code ec; 946 std::error_code ec;
920 const std::filesystem::path overlay_path = join(r.overlay, parts); 947 const std::filesystem::path overlay_path = disk_path(r.overlay, parts);
921 if (std::filesystem::exists(overlay_path, ec)) { 948 if (std::filesystem::exists(overlay_path, ec)) {
922 if (!::DeleteFileW(overlay_path.c_str())) return FALSE; 949 if (!::DeleteFileW(overlay_path.c_str())) return FALSE;
923 removed = true; 950 removed = true;
924 } 951 }
925 if (!r.game.empty() && !deleted(r.overlay, parts)) { 952 if (!r.game.empty() && !deleted(r.overlay, parts)) {
926 const std::filesystem::path package_path = join(r.game, parts); 953 const std::filesystem::path package_path = disk_path(r.game, parts);
927 if (std::filesystem::exists(package_path, ec)) { 954 if (std::filesystem::exists(package_path, ec)) {
928 if (std::filesystem::is_directory(package_path, ec)) { 955 if (std::filesystem::is_directory(package_path, ec)) {
929 SetLastError(ERROR_ACCESS_DENIED); 956 SetLastError(ERROR_ACCESS_DENIED);
@@ -982,7 +1009,7 @@ BOOL create_directory(LPCWSTR template_name, LPCWSTR name, LPSECURITY_ATTRIBUTES
982 if (view(r, parts).kind != Kind::None) return fail_bool(ERROR_ALREADY_EXISTS); // "GAME:" included 1009 if (view(r, parts).kind != Kind::None) return fail_bool(ERROR_ALREADY_EXISTS); // "GAME:" included
983 if (!is_folder(r, parent_of(parts))) return fail_bool(ERROR_PATH_NOT_FOUND); 1010 if (!is_folder(r, parent_of(parts))) return fail_bool(ERROR_PATH_NOT_FOUND);
984 1011
985 const std::filesystem::path target = join(r.overlay, parts); 1012 const std::filesystem::path target = disk_path(r.overlay, parts);
986 std::error_code ec; 1013 std::error_code ec;
987 std::filesystem::create_directories(target.parent_path(), ec); 1014 std::filesystem::create_directories(target.parent_path(), ec);
988 if (ec) return fail_bool(static_cast<DWORD>(ec.value())); 1015 if (ec) return fail_bool(static_cast<DWORD>(ec.value()));
@@ -1028,7 +1055,7 @@ BOOL WINAPI remove_directory_w(LPCWSTR name) {
1028 if (v.kind == Kind::File) return fail_bool(ERROR_DIRECTORY); 1055 if (v.kind == Kind::File) return fail_bool(ERROR_DIRECTORY);
1029 if (!empty_in_view(r, parts)) return fail_bool(ERROR_DIR_NOT_EMPTY); 1056 if (!empty_in_view(r, parts)) return fail_bool(ERROR_DIR_NOT_EMPTY);
1030 1057
1031 if (v.in_overlay && !::RemoveDirectoryW(join(r.overlay, parts).c_str())) return FALSE; // its error 1058 if (v.in_overlay && !::RemoveDirectoryW(disk_path(r.overlay, parts).c_str())) return FALSE; // its error
1032 if (v.in_package) { 1059 if (v.in_package) {
1033 // The package folder stays where it is; the marker hides it, and its files are already hidden one by one. 1060 // The package folder stays where it is; the marker hides it, and its files are already hidden one by one.
1034 DWORD error = 0; 1061 DWORD error = 0;
@@ -1062,7 +1089,7 @@ BOOL WINAPI move_file_ex_w(LPCWSTR from, LPCWSTR to, DWORD flags) {
1062 if (drive_root(from, src) || drive_root(to, dst)) return fail_bool(ERROR_ACCESS_DENIED); 1089 if (drive_root(from, src) || drive_root(to, dst)) return fail_bool(ERROR_ACCESS_DENIED);
1063 const View from_view = view(r, src); 1090 const View from_view = view(r, src);
1064 if (from_view.kind == Kind::None) return fail_bool(ERROR_FILE_NOT_FOUND); 1091 if (from_view.kind == Kind::None) return fail_bool(ERROR_FILE_NOT_FOUND);
1065 const std::filesystem::path overlay_from = join(r.overlay, src), overlay_to = join(r.overlay, dst); 1092 const std::filesystem::path overlay_from = disk_path(r.overlay, src), overlay_to = disk_path(r.overlay, dst);
1066 if (same_entry(src, dst)) { 1093 if (same_entry(src, dst)) {
1067 // The destination is the source, so it is not "already there". The host succeeds at a move onto the same 1094 // The destination is the source, so it is not "already there". The host succeeds at a move onto the same
1068 // name and changes nothing, and renames when only the case differs. Here the case of a name is the overlay's 1095 // name and changes nothing, and renames when only the case differs. Here the case of a name is the overlay's
@@ -1076,7 +1103,7 @@ BOOL WINAPI move_file_ex_w(LPCWSTR from, LPCWSTR to, DWORD flags) {
1076 std::error_code same_ec; 1103 std::error_code same_ec;
1077 std::filesystem::create_directories(overlay_to.parent_path(), same_ec); 1104 std::filesystem::create_directories(overlay_to.parent_path(), same_ec);
1078 if (same_ec) return fail_bool(static_cast<DWORD>(same_ec.value())); 1105 if (same_ec) return fail_bool(static_cast<DWORD>(same_ec.value()));
1079 if (!::CopyFileW(join(r.game, src).c_str(), overlay_to.c_str(), TRUE)) return FALSE; 1106 if (!::CopyFileW(disk_path(r.game, src).c_str(), overlay_to.c_str(), TRUE)) return FALSE;
1080 DWORD flush_error = 0; 1107 DWORD flush_error = 0;
1081 if ((flags & MOVEFILE_WRITE_THROUGH) != 0 && !flush_file(overlay_to, flush_error)) return fail_bool(flush_error); 1108 if ((flags & MOVEFILE_WRITE_THROUGH) != 0 && !flush_file(overlay_to, flush_error)) return fail_bool(flush_error);
1082 return TRUE; 1109 return TRUE;
@@ -1107,7 +1134,7 @@ BOOL WINAPI move_file_ex_w(LPCWSTR from, LPCWSTR to, DWORD flags) {
1107 // The host never sees a move here, only a copy and a marker, so MOVEFILE_WRITE_THROUGH is honoured by 1134 // The host never sees a move here, only a copy and a marker, so MOVEFILE_WRITE_THROUGH is honoured by
1108 // flushing both before returning, as MoveFileEx does for its own copy and delete. 1135 // flushing both before returning, as MoveFileEx does for its own copy and delete.
1109 const BOOL fail_if_exists = (flags & MOVEFILE_REPLACE_EXISTING) == 0; 1136 const BOOL fail_if_exists = (flags & MOVEFILE_REPLACE_EXISTING) == 0;
1110 if (!::CopyFileW(join(r.game, src).c_str(), overlay_to.c_str(), fail_if_exists)) return FALSE; 1137 if (!::CopyFileW(disk_path(r.game, src).c_str(), overlay_to.c_str(), fail_if_exists)) return FALSE;
1111 if (write_through && !flush_file(overlay_to, error)) return fail_bool(error); 1138 if (write_through && !flush_file(overlay_to, error)) return fail_bool(error);
1112 } 1139 }
1113 if (from_view.in_package) { 1140 if (from_view.in_package) {
@@ -1157,7 +1184,7 @@ bool copy_destination(LPCWSTR to, bool fail_if_exists, std::filesystem::path& ou
1157 if (v.kind == Kind::File && fail_if_exists) return false; 1184 if (v.kind == Kind::File && fail_if_exists) return false;
1158 error = ERROR_PATH_NOT_FOUND; 1185 error = ERROR_PATH_NOT_FOUND;
1159 if (!is_folder(r, parent_of(parts))) return false; 1186 if (!is_folder(r, parent_of(parts))) return false;
1160 out = join(r.overlay, parts); 1187 out = disk_path(r.overlay, parts);
1161 std::error_code ec; 1188 std::error_code ec;
1162 std::filesystem::create_directories(out.parent_path(), ec); 1189 std::filesystem::create_directories(out.parent_path(), ec);
1163 if (ec) { 1190 if (ec) {
@@ -1316,7 +1343,7 @@ BOOL WINAPI set_file_attributes_w(LPCWSTR name, DWORD attributes) {
1316 1343
1317 // The attributes belong to the overlay copy: a package file is copied up and a package folder mirrored first, 1344 // The attributes belong to the overlay copy: a package file is copied up and a package folder mirrored first,
1318 // so the package keeps its own attributes and reads, which prefer the overlay, see the new ones. 1345 // so the package keeps its own attributes and reads, which prefer the overlay, see the new ones.
1319 const std::filesystem::path target = join(r.overlay, parts); 1346 const std::filesystem::path target = disk_path(r.overlay, parts);
1320 if (!v.in_overlay) { 1347 if (!v.in_overlay) {
1321 std::error_code ec; 1348 std::error_code ec;
1322 if (v.kind == Kind::Directory) { 1349 if (v.kind == Kind::Directory) {