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) {
1140
1140
if (!buf ) {
1141
1141
return NULL ;
1142
1142
}
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
+ }
1143
1152
1144
1153
// Convert result to UTF8
1145
- copyToNarrowFileSystemRepresentation (buf , (CFIndex )size , dstbuf );
1154
+ copyToNarrowFileSystemRepresentation (pathToConvert , (CFIndex )size , dstbuf );
1146
1155
free (buf );
1147
1156
return dstbuf ;
1148
1157
}
You can’t perform that action at this time.
0 commit comments