- Timestamp:
- Apr 12, 2018 10:17:37 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/nt/dirrel-r3-nt.cpp
r69795 r71844 187 187 188 188 189 /** 190 * Helper for cooking up a path string for rtDirOpenRelativeOrHandle. 191 * 192 * @returns IPRT status code. 193 * @param pszDst The destination buffer. 194 * @param cbDst The size of the destination buffer. 195 * @param pThis The directory this is relative to. 196 * @param pNtPath The NT path with a possibly relative path. 197 * @param fRelative Whether @a pNtPath is relative or not. 198 * @param pszPath The input path. 199 */ 200 static int rtDirRelJoinPathForDirOpen(char *pszDst, size_t cbDst, PRTDIRINTERNAL pThis, 201 PUNICODE_STRING pNtPath, bool fRelative, const char *pszPath) 202 { 203 int rc; 204 if (fRelative) 205 { 206 size_t cchRel = 0; 207 rc = RTUtf16CalcUtf8LenEx(pNtPath->Buffer, pNtPath->Length / sizeof(RTUTF16), &cchRel); 208 AssertRC(rc); 209 if (RT_SUCCESS(rc)) 210 { 211 if (pThis->cchPath + cchRel < cbDst) 212 { 213 size_t cchBase = pThis->cchPath; 214 memcpy(pszDst, pThis->pszPath, cchBase); 215 pszDst += cchBase; 216 cbDst -= cchBase; 217 rc = RTUtf16ToUtf8Ex(pNtPath->Buffer, pNtPath->Length / sizeof(RTUTF16), &pszDst, cbDst, NULL); 218 } 219 else 220 rc = VERR_FILENAME_TOO_LONG; 221 } 222 } 223 else 224 { 225 /** @todo would be better to convert pNtName to DOS/WIN path here, 226 * as it is absolute and doesn't need stuff resolved. */ 227 rc = RTPathJoin(pszDst, cbDst, pThis->pszPath, pszPath); 228 } 229 return rc; 230 } 189 231 190 232 RTDECL(int) RTDirRelDirOpen(RTDIR hDir, const char *pszDir, RTDIR *phDir) … … 210 252 if (RT_SUCCESS(rc)) 211 253 { 212 rc = rtDirOpenRelativeOrHandle(phDir, pszDirAndFilter, enmFilter, fFlags, (uintptr_t)hRoot, &NtName); 254 char szAbsDirAndFilter[RTPATH_MAX]; 255 rc = rtDirRelJoinPathForDirOpen(szAbsDirAndFilter, sizeof(szAbsDirAndFilter), pThis, 256 &NtName, hRoot != NULL, pszDirAndFilter); 257 if (RT_SUCCESS(rc)) 258 rc = rtDirOpenRelativeOrHandle(phDir, szAbsDirAndFilter, enmFilter, fFlags, (uintptr_t)hRoot, &NtName); 213 259 RTNtPathFree(&NtName, NULL); 214 260 } … … 294 340 else 295 341 { 296 rc = rtDirOpenRelativeOrHandle(phSubDir, pszRelPath, RTDIRFILTER_NONE, 0 /*fFlags*/, 297 (uintptr_t)hNewDir, NULL /*pvNativeRelative*/); 342 char szAbsDirAndFilter[RTPATH_MAX]; 343 rc = rtDirRelJoinPathForDirOpen(szAbsDirAndFilter, sizeof(szAbsDirAndFilter), pThis, 344 &NtName, hRoot != NULL, pszRelPath); 345 if (RT_SUCCESS(rc)) 346 rc = rtDirOpenRelativeOrHandle(phSubDir, pszRelPath, RTDIRFILTER_NONE, 0 /*fFlags*/, 347 (uintptr_t)hNewDir, NULL /*pvNativeRelative*/); 298 348 if (RT_FAILURE(rc)) 299 349 NtClose(hNewDir);
Note:
See TracChangeset
for help on using the changeset viewer.