Changeset 47356 in vbox for trunk/src/VBox/Runtime/common/vfs/vfsstdfile.cpp
- Timestamp:
- Jul 23, 2013 5:45:07 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 87502
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/vfs/vfsstdfile.cpp
r44529 r47356 419 419 420 420 421 /** 422 * Internal worker for RTVfsFileFromRTFile and RTVfsFileOpenNormal. 423 * 424 * @returns IRPT status code. 425 * @param hFile The IPRT file handle. 426 * @param fOpen The RTFILE_O_XXX flags. 427 * @param fLeaveOpen Whether to leave it open or close it. 428 * @param phVfsFile Where to return the handle. 429 */ 430 static int rtVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile) 431 { 432 PRTVFSSTDFILE pThis; 433 RTVFSFILE hVfsFile; 434 int rc = RTVfsNewFile(&g_rtVfsStdFileOps, sizeof(RTVFSSTDFILE), fOpen, NIL_RTVFS, NIL_RTVFSLOCK, 435 &hVfsFile, (void **)&pThis); 436 if (RT_FAILURE(rc)) 437 return rc; 438 439 pThis->hFile = hFile; 440 pThis->fLeaveOpen = fLeaveOpen; 441 *phVfsFile = hVfsFile; 442 return VINF_SUCCESS; 443 } 444 445 421 446 RTDECL(int) RTVfsFileFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSFILE phVfsFile) 422 447 { … … 430 455 431 456 /* 432 * Set up some fake fOpen flags .457 * Set up some fake fOpen flags if necessary and create a VFS file handle. 433 458 */ 434 459 if (!fOpen) 435 460 fOpen = RTFILE_O_READWRITE | RTFILE_O_DENY_NONE | RTFILE_O_OPEN_CREATE; 436 461 462 return rtVfsFileFromRTFile(hFile, fOpen, fLeaveOpen, phVfsFile); 463 } 464 465 466 RTDECL(int) RTVfsFileOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile) 467 { 437 468 /* 438 * Create the handle.469 * Open the file the normal way and pass it to RTVfsFileFromRTFile. 439 470 */ 440 PRTVFSSTDFILE pThis; 441 RTVFSFILE hVfsFile; 442 rc = RTVfsNewFile(&g_rtVfsStdFileOps, sizeof(RTVFSSTDFILE), fOpen, NIL_RTVFS, NIL_RTVFSLOCK, &hVfsFile, (void **)&pThis); 443 if (RT_FAILURE(rc)) 444 return rc; 445 446 pThis->hFile = hFile; 447 pThis->fLeaveOpen = fLeaveOpen; 448 *phVfsFile = hVfsFile; 449 return VINF_SUCCESS; 450 } 451 452 453 RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos) 471 RTFILE hFile; 472 int rc = RTFileOpen(&hFile, pszFilename, fOpen); 473 if (RT_SUCCESS(rc)) 474 { 475 /* 476 * Create a VFS file handle. 477 */ 478 rc = rtVfsFileFromRTFile(hFile, fOpen, false /*fLeaveOpen*/, phVfsFile); 479 if (RT_FAILURE(rc)) 480 RTFileClose(hFile); 481 } 482 return rc; 483 } 484 485 486 RTDECL(int) RTVfsIoStrmFromRTFile(RTFILE hFile, uint64_t fOpen, bool fLeaveOpen, PRTVFSIOSTREAM phVfsIos) 454 487 { 455 488 RTVFSFILE hVfsFile; … … 460 493 } 461 494 495 496 RTDECL(int) RTVfsIoStrmOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSIOSTREAM phVfsIos) 497 { 498 RTVFSFILE hVfsFile; 499 int rc = RTVfsFileOpenNormal(pszFilename, fOpen, &hVfsFile); 500 if (RT_SUCCESS(rc)) 501 *phVfsIos = RTVfsFileToIoStream(hVfsFile); 502 return rc; 503 } 504 505
Note:
See TracChangeset
for help on using the changeset viewer.