Changeset 78100 in vbox
- Timestamp:
- Apr 10, 2019 4:52:24 PM (5 years ago)
- File:
-
- 1 edited
-
trunk/include/iprt/cpp/path.h (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/path.h
r76585 r78100 45 45 * 46 46 * @returns IPRT status code. 47 * @param rStrAbs Reference to the desti ation string.47 * @param rStrAbs Reference to the destination string. 48 48 * @param pszRelative The relative source string. 49 49 */ … … 54 54 if (RT_SUCCESS(rc)) 55 55 { 56 char *pszDst = rStrAbs.mutableRaw(); 57 rc = RTPathAbs(pszRelative, pszDst, rStrAbs.capacity()); 58 if (RT_FAILURE(rc)) 56 unsigned cTries = 8; 57 for (;;) 58 { 59 char *pszDst = rStrAbs.mutableRaw(); 60 size_t cbCap = rStrAbs.capacity(); 61 rc = RTPathAbsEx(NULL, pszRelative, RTPATH_STR_F_STYLE_HOST, pszDst, &cbCap); 62 if (RT_SUCCESS(rc)) 63 break; 59 64 *pszDst = '\0'; 65 if (rc != VERR_BUFFER_OVERFLOW) 66 break; 67 if (--cTries == 0) 68 break; 69 rc = rStrAbs.reserveNoThrow(RT_MIN(RT_ALIGN_Z(cbCap, 64), RTPATH_MAX)); 70 if (RT_FAILURE(rc)) 71 break; 72 } 60 73 rStrAbs.jolt(); 61 74 } … … 68 81 * 69 82 * @returns IPRT status code. 70 * @param rStrAbs Reference to the desti ation string.83 * @param rStrAbs Reference to the destination string. 71 84 * @param rStrRelative Reference to the relative source string. 72 85 */ … … 77 90 78 91 92 93 /** 94 * RTPathAbsEx() wrapper for working directly on a RTCString instance. 95 * 96 * @returns IPRT status code. 97 * @param rStrAbs Reference to the destination string. 98 * @param pszBase The base path, optional. 99 * @param pszRelative The relative source string. 100 * @param fFlags RTPATH_STR_F_STYLE_XXX and RTPATHABS_F_XXX flags. 101 */ 102 DECLINLINE(int) RTPathAbsExCxx(RTCString &rStrAbs, const char *pszBase, const char *pszRelative, uint32_t fFlags = RTPATH_STR_F_STYLE_HOST) 103 { 104 Assert(rStrAbs.c_str() != pszRelative); 105 int rc = rStrAbs.reserveNoThrow(RTPATH_MAX); 106 if (RT_SUCCESS(rc)) 107 { 108 unsigned cTries = 8; 109 for (;;) 110 { 111 char *pszDst = rStrAbs.mutableRaw(); 112 size_t cbCap = rStrAbs.capacity(); 113 rc = RTPathAbsEx(pszBase, pszRelative, fFlags, pszDst, &cbCap); 114 if (RT_SUCCESS(rc)) 115 break; 116 *pszDst = '\0'; 117 if (rc != VERR_BUFFER_OVERFLOW) 118 break; 119 if (--cTries == 0) 120 break; 121 rc = rStrAbs.reserveNoThrow(RT_MIN(RT_ALIGN_Z(cbCap, 64), RTPATH_MAX)); 122 if (RT_FAILURE(rc)) 123 break; 124 } 125 rStrAbs.jolt(); 126 } 127 return rc; 128 } 129 130 131 DECLINLINE(int) RTPathAbsExCxx(RTCString &rStrAbs, RTCString const &rStrBase, RTCString const &rStrRelative, uint32_t fFlags = RTPATH_STR_F_STYLE_HOST) 132 { 133 return RTPathAbsExCxx(rStrAbs, rStrBase.c_str(), rStrRelative.c_str(), fFlags); 134 } 135 136 137 DECLINLINE(int) RTPathAbsExCxx(RTCString &rStrAbs, const char *pszBase, RTCString const &rStrRelative, uint32_t fFlags = RTPATH_STR_F_STYLE_HOST) 138 { 139 return RTPathAbsExCxx(rStrAbs, pszBase, rStrRelative.c_str(), fFlags); 140 } 141 142 143 DECLINLINE(int) RTPathAbsExCxx(RTCString &rStrAbs, RTCString const &rStrBase, const char *pszRelative, uint32_t fFlags = RTPATH_STR_F_STYLE_HOST) 144 { 145 return RTPathAbsExCxx(rStrAbs, rStrBase.c_str(), pszRelative, fFlags); 146 } 147 148 149 79 150 /** 80 151 * RTPathAppPrivateNoArch() wrapper for working directly on a RTCString instance. 81 152 * 82 153 * @returns IPRT status code. 83 * @param rStrDst Reference to the desti ation string.154 * @param rStrDst Reference to the destination string. 84 155 */ 85 156 DECLINLINE(int) RTPathAppPrivateNoArchCxx(RTCString &rStrDst) … … 103 174 * 104 175 * @returns IPRT status code. 105 * @param rStrDst Reference to the desti ation string.176 * @param rStrDst Reference to the destination string. 106 177 * @param pszAppend One or more components to append to the path already 107 178 * present in @a rStrDst. … … 135 206 * 136 207 * @returns IPRT status code. 137 * @param rStrDst Reference to the desti ation string.208 * @param rStrDst Reference to the destination string. 138 209 * @param rStrAppend One or more components to append to the path already 139 210 * present in @a rStrDst.
Note:
See TracChangeset
for help on using the changeset viewer.

