Changeset 69757 in vbox
- Timestamp:
- Nov 19, 2017 3:15:36 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119157
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/dir.h
r69756 r69757 448 448 449 449 /** 450 * Wrapper around RTDirReadEx that does the directory entry buffer handling. 451 * 452 * Call RTDirReadExAFree to free the buffers allocated by this function. 453 * 454 * @returns IPRT status code, see RTDirReadEx() for details. 455 * 456 * @param hDir Handle to the open directory. 457 * @param ppDirEntry Pointer to the directory entry pointer. Initialize this 458 * to NULL before the first call. 459 * @param pcbDirEntry Where the API caches the allocation size. Set this to 460 * zero before the first call. 461 * @param enmAddAttr See RTDirReadEx. 462 * @param fFlags See RTDirReadEx. 463 */ 464 RTDECL(int) RTDirReadExA(RTDIR hDir, PRTDIRENTRYEX *ppDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAddAttr, uint32_t fFlags); 465 466 /** 467 * Frees the buffer allocated by RTDirReadExA. 468 * 469 * @param ppDirEntry Pointer to the directory entry pointer. 470 * @param pcbDirEntry Where the API caches the allocation size. 471 */ 472 RTDECL(void) RTDirReadExAFree(PRTDIRENTRYEX *ppDirEntry, size_t *pcbDirEntry); 473 474 /** 450 475 * Resolves RTDIRENTRYTYPE_UNKNOWN values returned by RTDirRead. 451 476 * -
trunk/include/iprt/mangling.h
r69745 r69757 767 767 # define RTDirRead RT_MANGLER(RTDirRead) 768 768 # define RTDirReadEx RT_MANGLER(RTDirReadEx) 769 # define RTDirReadExA RT_MANGLER(RTDirReadExA) 770 # define RTDirReadExAFree RT_MANGLER(RTDirReadExAFree) 769 771 # define RTDirRemove RT_MANGLER(RTDirRemove) 770 772 # define RTDirRemoveRecursive RT_MANGLER(RTDirRemoveRecursive) -
trunk/src/VBox/Runtime/r3/dir.cpp
r69753 r69757 795 795 } 796 796 797 798 RTDECL(int) RTDirReadExA(RTDIR hDir, PRTDIRENTRYEX *ppDirEntry, size_t *pcbDirEntry, RTFSOBJATTRADD enmAddAttr, uint32_t fFlags) 799 { 800 PRTDIRENTRYEX pDirEntry = *ppDirEntry; 801 size_t cbDirEntry = *pcbDirEntry; 802 if (pDirEntry != NULL && cbDirEntry >= sizeof(RTDIRENTRYEX)) 803 { /* likely */ } 804 else 805 { 806 Assert(pDirEntry == NULL); 807 Assert(cbDirEntry == 0); 808 809 cbDirEntry = RT_ALIGN_Z(sizeof(RTDIRENTRYEX), 16); 810 *ppDirEntry = pDirEntry = (PRTDIRENTRYEX)RTMemTmpAlloc(cbDirEntry); 811 if (pDirEntry) 812 *pcbDirEntry = cbDirEntry; 813 else 814 { 815 *pcbDirEntry = 0; 816 return VERR_NO_TMP_MEMORY; 817 } 818 } 819 820 for (;;) 821 { 822 int rc = RTDirReadEx(hDir, pDirEntry, &cbDirEntry, enmAddAttr, fFlags); 823 if (rc != VERR_BUFFER_OVERFLOW) 824 return rc; 825 826 /* Grow the buffer. */ 827 RTMemTmpFree(pDirEntry); 828 cbDirEntry = RT_MAX(RT_ALIGN_Z(cbDirEntry, 64), *pcbDirEntry + 64); 829 *ppDirEntry = pDirEntry = (PRTDIRENTRYEX)RTMemTmpAlloc(cbDirEntry); 830 if (pDirEntry) 831 *pcbDirEntry = cbDirEntry; 832 else 833 { 834 *pcbDirEntry = 0; 835 return VERR_NO_TMP_MEMORY; 836 } 837 } 838 } 839 840 841 RTDECL(void) RTDirReadExAFree(PRTDIRENTRYEX *ppDirEntry, size_t *pcbDirEntry) 842 { 843 PRTDIRENTRYEX pDirEntry = *ppDirEntry; 844 if (pDirEntry != NULL && *pcbDirEntry >= sizeof(*pcbDirEntry)) 845 RTMemTmpFree(pDirEntry); 846 else 847 { 848 Assert(pDirEntry == NULL); 849 Assert(*pcbDirEntry == 0); 850 } 851 *ppDirEntry = NULL; 852 *pcbDirEntry = 0; 853 } 854
Note:
See TracChangeset
for help on using the changeset viewer.