Changeset 74358 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Sep 19, 2018 8:01:43 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/win/fileio-win.cpp
r72845 r74358 5 5 6 6 /* 7 * Copyright (C) 2006-201 7Oracle Corporation7 * Copyright (C) 2006-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 47 47 #include "internal/fs.h" 48 48 #include "internal/path.h" 49 #include "internal-r3-win.h" /* For g_enmWinVer + kRTWinOSType_XXX */ 49 50 50 51 … … 288 289 /* 289 290 * Open/Create the file. 290 */ 291 PRTUTF16 pwszFilename; 292 rc = RTStrToUtf16(pszFilename, &pwszFilename); 291 * 292 * When opening files with paths longer than 260 chars, CreateFileW() will fail, unless 293 * you explicitly specify a prefix (see [1], RTPATH_WIN_LONG_PATH_PREFIX). 294 * 295 * Note: Relative paths are not supported, so check for this. 296 * 297 * [1] https://docs.microsoft.com/en-gb/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation 298 */ 299 PRTUTF16 pwszFilename = NULL; 300 if (g_enmWinVer >= kRTWinOSType_XP) /* Not sure since when the prefix is available, so play safe by default. */ 301 { 302 #define RTPATH_WIN_LONG_PATH_PREFIX "\\\\?\\" 303 304 if ( strlen(pszFilename) > 260 305 && !RTPathStartsWith(pszFilename, RTPATH_WIN_LONG_PATH_PREFIX) 306 && RTPathStartsWithRoot(pszFilename)) 307 { 308 char *pszFilenameWithPrefix = RTStrAPrintf2("%s%s", RTPATH_WIN_LONG_PATH_PREFIX, pszFilename); 309 if (pszFilenameWithPrefix) 310 { 311 rc = RTStrToUtf16(pszFilenameWithPrefix, &pwszFilename); 312 RTStrFree(pszFilenameWithPrefix); 313 } 314 else 315 rc = VERR_NO_MEMORY; 316 } 317 #undef RTPATH_WIN_LONG_PATH_PREFIX 318 } 319 320 if ( RT_SUCCESS(rc) 321 && !pwszFilename) 322 { 323 rc = RTStrToUtf16(pszFilename, &pwszFilename); 324 } 325 293 326 if (RT_FAILURE(rc)) 294 327 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.