- Timestamp:
- Oct 26, 2010 9:48:58 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/isofs.cpp
r33148 r33453 36 36 * Destroys the patch cache. 37 37 * 38 * @param pFile 38 * @param pFile ISO handle. 39 39 */ 40 40 RTR3DECL(void) rtIsoFsDestroyPathCache(PRTISOFSFILE pFile) … … 62 62 63 63 /** 64 * 65 * 66 * @return int 67 * 68 * @param pList 69 * @param pszPath 70 * @param pHeader 64 * Adds a path entry to the path table list. 65 * 66 * @return IPRT status code. 67 * @param pList Path table list to add the path entry to. 68 * @param pszPath Path to add. 69 * @param pHeader Path header information to add. 71 70 */ 72 71 RTR3DECL(int) rtIsoFsAddToPathCache(PRTLISTNODE pList, const char *pszPath, … … 98 97 99 98 /** 100 * 101 * 102 * @return int103 * 104 * @param pList 105 * @param pNode 106 * @param pszPathNode 107 * @param ppszPath 99 * Retrieves the parent path of a given node, assuming that the path table 100 * (still) is in sync with the node's index. 101 * 102 * @return IPRT status code. 103 * @param pList Path table list to use. 104 * @param pNode Node of path table entry to lookup the full path for. 105 * @param pszPathNode Current (partial) parent path; needed for recursion. 106 * @param ppszPath Pointer to a pointer to store the retrieved full path to. 108 107 */ 109 108 RTR3DECL(int) rtIsoFsGetParentPathSub(PRTLISTNODE pList, PRTISOFSPATHTABLEENTRY pNode, … … 111 110 { 112 111 int rc = VINF_SUCCESS; 112 /* Do we have a parent? */ 113 113 if (pNode->header.parent_index > 1) 114 114 { 115 115 uint16_t idx = 1; 116 /* Get the parent of our current node (pNode) */ 116 117 PRTISOFSPATHTABLEENTRY pNodeParent = RTListNodeGetFirst(pList, RTISOFSPATHTABLEENTRY, Node); 117 118 while (idx++ < pNode->header.parent_index) 118 119 pNodeParent = RTListNodeGetNext(&pNodeParent->Node, RTISOFSPATHTABLEENTRY, Node); 120 /* Construct intermediate path (parent + current path). */ 119 121 char *pszPath; 120 122 if (RTStrAPrintf(&pszPath, "%s/%s", pNodeParent->path, pszPathNode)) 121 123 { 124 /* ... and do the same with the parent's parent until we reached the root. */ 122 125 rc = rtIsoFsGetParentPathSub(pList, pNodeParent, pszPath, ppszPath); 123 126 RTStrFree(pszPath); … … 126 129 rc = VERR_NO_MEMORY; 127 130 } 128 else 131 else /* No parent (left), this must be the root path then. */ 129 132 { 130 133 char *pszPath = RTStrDup(pszPathNode); … … 136 139 137 140 /** 138 * 139 * 140 * @return int 141 * 142 * @param pFile 141 * Updates the path table cache of an ISO file. 142 * 143 * @return IPRT status code. 144 * @param pFile ISO handle. 143 145 */ 144 146 RTR3DECL(int) rtIsoFsUpdatePathCache(PRTISOFSFILE pFile) … … 204 206 { 205 207 rc = rtIsoFsGetParentPathSub(&pFile->listPaths, pNode, 206 208 pNode->path, &pNode->path_full); 207 209 if (RT_SUCCESS(rc)) 208 210 pNode = RTListNodeGetPrev(&pNode->Node, RTISOFSPATHTABLEENTRY, Node); … … 213 215 214 216 215 /**216 *217 *218 * @return int219 *220 * @param pszFileName221 * @param pFile222 */223 217 RTR3DECL(int) RTIsoFsOpen(PRTISOFSFILE pFile, const char *pszFileName) 224 218 { … … 285 279 286 280 287 /**288 *289 *290 *291 * @param pFile292 */293 281 RTR3DECL(void) RTIsoFsClose(PRTISOFSFILE pFile) 294 282 { … … 303 291 /** 304 292 * Parses an extent given at the specified sector + size and 305 * returns a directory record. 306 * 307 * @return int 308 * 309 * @param pFile 310 * @param pszFileName 311 * @param uExtentSector 312 * @param cbExtent 313 * @param ppRec 293 * searches for a file name to return an allocated directory record. 294 * 295 * @return IPRT status code. 296 * @param pFile ISO handle. 297 * @param pszFileName Absolute file name to search for. 298 * @param uExtentSector Sector of extent. 299 * @param cbExtent Size (in bytes) of extent. 300 * @param ppRec Pointer to a pointer to return the 301 * directory record. Must be free'd with 302 * rtIsoFsFreeDirectoryRecord(). 314 303 */ 315 304 RTR3DECL(int) rtIsoFsFindEntry(PRTISOFSFILE pFile, const char *pszFileName, … … 401 390 402 391 /** 403 * 404 * 405 * @return int406 * 407 * @param pFile 408 * @param pszPath 409 * @param puSector 392 * Retrieves the sector of a file extent given by the 393 * full file path within the ISO. 394 * 395 * @return IPRT status code. 396 * @param pFile ISO handle. 397 * @param pszPath File path to resolve. 398 * @param puSector Pointer where to store the found sector to. 410 399 */ 411 400 RTR3DECL(int) rtIsoFsResolvePath(PRTISOFSFILE pFile, const char *pszPath, uint32_t *puSector) … … 454 443 455 444 /** 456 * 457 * 458 * @return int 459 * 460 * @param pFile 461 * @param pszPath 462 * @param ppRecord 445 * Allocates a new directory record. 446 * 447 * @return Pointer to the newly allocated directory record. 448 */ 449 RTR3DECL(PRTISOFSDIRRECORD) rtIsoFsCreateDirectoryRecord(void) 450 { 451 PRTISOFSDIRRECORD pRecord = (PRTISOFSDIRRECORD)RTMemAlloc(sizeof(RTISOFSDIRRECORD)); 452 return pRecord; 453 } 454 455 456 /** 457 * Frees a previously allocated directory record. 458 * 459 * @return IPRT status code. 460 */ 461 RTR3DECL(void) rtIsoFsFreeDirectoryRecord(PRTISOFSDIRRECORD pRecord) 462 { 463 RTMemFree(pRecord); 464 } 465 466 467 /** 468 * Returns an allocated directory record for a given file. 469 * 470 * @return IPRT status code. 471 * @param pFile ISO handle. 472 * @param pszPath File path to resolve. 473 * @param ppRecord Pointer to a pointer to return the 474 * directory record. Must be free'd with 475 * rtIsoFsFreeDirectoryRecord(). 463 476 */ 464 477 RTR3DECL(int) rtIsoFsGetDirectoryRecord(PRTISOFSFILE pFile, const char *pszPath, … … 479 492 { 480 493 size_t cbRead; 481 PRTISOFSDIRRECORD pRecord = (PRTISOFSDIRRECORD)RTMemAlloc(sizeof(RTISOFSDIRRECORD));494 PRTISOFSDIRRECORD pRecord = rtIsoFsCreateDirectoryRecord(); 482 495 if (pRecord) 483 496 { … … 489 502 } 490 503 if (RT_FAILURE(rc)) 491 RTMemFree(pRecord);504 rtIsoFsFreeDirectoryRecord(pRecord); 492 505 } 493 506 else … … 521 534 *pcbOffset = pFileRecord->extent_location * RTISOFS_SECTOR_SIZE; 522 535 *pcbLength = pFileRecord->extent_data_length; 523 RTMemFree(pFileRecord);524 } 525 RTMemFree(pDirRecord);536 rtIsoFsFreeDirectoryRecord(pFileRecord); 537 } 538 rtIsoFsFreeDirectoryRecord(pDirRecord); 526 539 } 527 540 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.