File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1140,9 +1140,18 @@ CF_EXPORT char *_NS_getcwd(char *dstbuf, size_t size) {
11401140 if (!buf ) {
11411141 return NULL ;
11421142 }
1143+
1144+ // Strip UNC-style prefixes (\\?\ and \\.\) from the wide character buffer
1145+ wchar_t * pathToConvert = buf ;
1146+ size_t pathLen = wcslen (buf );
1147+ if (pathLen >= 4 && buf [0 ] == L'\\' && buf [1 ] == L'\\' && buf [3 ] == L'\\' &&
1148+ (buf [2 ] == L'?' || buf [2 ] == L'.' )) {
1149+ // Skip the UNC prefix by advancing the pointer
1150+ pathToConvert = buf + 4 ;
1151+ }
11431152
11441153 // Convert result to UTF8
1145- copyToNarrowFileSystemRepresentation (buf , (CFIndex )size , dstbuf );
1154+ copyToNarrowFileSystemRepresentation (pathToConvert , (CFIndex )size , dstbuf );
11461155 free (buf );
11471156 return dstbuf ;
11481157}
You can’t perform that action at this time.
0 commit comments