Changeset 47356 in vbox
- Timestamp:
- Jul 23, 2013 5:45:07 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 87502
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r47352 r47356 1771 1771 # define RTVfsFileGetSize RT_MANGLER(RTVfsFileGetSize) 1772 1772 # define RTVfsFileOpen RT_MANGLER(RTVfsFileOpen) 1773 # define RTVfsFileOpenNormal RT_MANGLER(RTVfsFileOpenNormal) 1773 1774 # define RTVfsFilePoll RT_MANGLER(RTVfsFilePoll) 1774 1775 # define RTVfsFileQueryInfo RT_MANGLER(RTVfsFileQueryInfo) … … 1791 1792 # define RTVfsIoStrmFromStdHandle RT_MANGLER(RTVfsIoStrmFromStdHandle) 1792 1793 # define RTVfsIoStrmIsAtEnd RT_MANGLER(RTVfsIoStrmIsAtEnd) 1794 # define RTVfsIoStrmOpenNormal RT_MANGLER(RTVfsIoStrmOpenNormal) 1793 1795 # define RTVfsIoStrmPoll RT_MANGLER(RTVfsIoStrmPoll) 1794 1796 # define RTVfsIoStrmQueryInfo RT_MANGLER(RTVfsIoStrmQueryInfo) -
trunk/include/iprt/vfs.h
r47351 r47356 453 453 454 454 /** 455 * Convenience function combining RTFileOpen with RTVfsIoStrmFromRTFile. 456 * 457 * @returns IPRT status code. 458 * @param pszFilename The path to the file in the normal file system. 459 * @param fOpen The flags to pass to RTFileOpen when opening the 460 * file, i.e. RTFILE_O_XXX. 461 * @param phVfsIos Where to return the VFS I/O stream handle. 462 */ 463 RTDECL(int) RTVfsIoStrmOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSIOSTREAM phVfsIos); 464 465 /** 455 466 * Create a VFS I/O stream handle from one of the standard handles. 456 467 * … … 706 717 707 718 /** 719 * Convenience function combining RTFileOpen with RTVfsFileFromRTFile. 720 * 721 * @returns IPRT status code. 722 * @param pszFilename The path to the file in the normal file system. 723 * @param fOpen The flags to pass to RTFileOpen when opening the 724 * file, i.e. RTFILE_O_XXX. 725 * @param phVfsFile Where to return the VFS file handle. 726 */ 727 RTDECL(int) RTVfsFileOpenNormal(const char *pszFilename, uint64_t fOpen, PRTVFSFILE phVfsFile); 728 729 /** 708 730 * Convert the VFS file handle to a VFS I/O stream handle. 709 731 * -
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.