Skip to content

Commit 3346afb

Browse files
committed
[GR-78886] Fix Windows native long path preparation
1 parent 21015d9 commit 3346afb

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

  • graalpython/python-libposix/src

‎graalpython/python-libposix/src/posix.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,9 @@ static int win_path_init(win_path_t *result, const wchar_t *path) {
250250
return 0;
251251
}
252252

253-
DWORD full_size = GetFullPathNameW(path, 0, NULL, NULL);
254-
if (full_size == 0) {
255-
// Let the actual filesystem operation report the error for this path.
256-
return 0;
257-
}
253+
// GetFullPathNameW can reject a zero-sized probe for long paths when process-wide long-path
254+
// support is unavailable, so begin with MAX_PATH and grow from its insufficient-buffer result.
255+
DWORD full_size = MAX_PATH;
258256
wchar_t *full_path = NULL;
259257
DWORD full_len;
260258
for (;;) {
@@ -292,6 +290,12 @@ static int win_path_init(win_path_t *result, const wchar_t *path) {
292290
return 0;
293291
}
294292

293+
if (full_len >= 4 && full_path[0] == L'\\' && full_path[1] == L'\\' && full_path[2] == L'?' && full_path[3] == L'\\') {
294+
result->value = full_path;
295+
result->allocated = full_path;
296+
return 0;
297+
}
298+
295299
const wchar_t *prefix;
296300
size_t prefix_len;
297301
size_t source_offset;

0 commit comments

Comments
 (0)