Changeset 46971 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jul 4, 2013 7:46:39 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86979
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/zip/tar.cpp
r46518 r46971 136 136 /** The open mode. */ 137 137 uint32_t fOpenMode; 138 /** The link flag. */ 139 char linkflag; 138 140 } RTTARFILEINTERNAL; 139 141 /** Pointer to the internal data of a tar file. */ … … 1621 1623 uint64_t offCur = RTFileTell(pInt->hTarFile); 1622 1624 if (!( pInt->pFileCache->offStart <= offCur 1623 && offCur < pInt->pFileCache->offStart + sizeof(RTTARRECORD) + pInt->pFileCache->cbSize))1625 && offCur <= pInt->pFileCache->offStart + sizeof(RTTARRECORD) + pInt->pFileCache->cbSize)) 1624 1626 return VERR_INVALID_STATE; 1625 1627 1626 1628 /* Seek to the next file header. */ 1627 1629 uint64_t offNext = RT_ALIGN(pInt->pFileCache->offStart + sizeof(RTTARRECORD) + pInt->pFileCache->cbSize, sizeof(RTTARRECORD)); 1628 rc = RTFileSeek(pInt->hTarFile, offNext - offCur, RTFILE_SEEK_CURRENT, NULL); 1629 if (RT_FAILURE(rc)) 1630 return rc; 1630 if (pInt->pFileCache->cbSize != 0) 1631 { 1632 rc = RTFileSeek(pInt->hTarFile, offNext - offCur, RTFILE_SEEK_CURRENT, NULL); 1633 if (RT_FAILURE(rc)) 1634 return rc; 1635 } 1636 else 1637 { 1638 /* Else delete the last open file cache. Might be recreated below. */ 1639 rtDeleteTarFileInternal(pInt->pFileCache); 1640 pInt->pFileCache = NULL; 1641 } 1631 1642 1632 1643 /* Again check the current filename to fill the cache with the new value. */ … … 1652 1663 if (pInt->pFileCache) 1653 1664 { 1654 /* Are we still direct behind that header? */ 1655 if (pInt->pFileCache->offStart + sizeof(RTTARRECORD) == RTFileTell(pInt->hTarFile)) 1665 if (pInt->pFileCache->offStart + sizeof(RTTARRECORD) < RTFileTell(pInt->hTarFile)) 1666 { 1667 /* Else delete the last open file cache. Might be recreated below. */ 1668 rtDeleteTarFileInternal(pInt->pFileCache); 1669 pInt->pFileCache = NULL; 1670 } 1671 else/* Are we still direct behind that header? */ 1656 1672 { 1657 1673 /* Yes, so the streaming can start. Just return the cached file … … 1660 1676 if (ppszFilename) 1661 1677 *ppszFilename = RTStrDup(pInt->pFileCache->pszFilename); 1662 return VINF_SUCCESS;1663 }1664 1665 /* Else delete the last open file cache. Might be recreated below. */1666 rtDeleteTarFileInternal(pInt->pFileCache);1667 pInt->pFileCache = NULL; 1678 if (pInt->pFileCache->linkflag == LF_DIR) 1679 return VINF_TAR_DIR_PATH; 1680 else 1681 return VINF_SUCCESS; 1682 } 1683 1668 1684 } 1669 1685 … … 1683 1699 /* We support normal files only */ 1684 1700 if ( record.h.linkflag == LF_OLDNORMAL 1685 || record.h.linkflag == LF_NORMAL) 1701 || record.h.linkflag == LF_NORMAL 1702 || record.h.linkflag == LF_DIR) 1686 1703 { 1687 1704 pFileInt = rtCreateTarFileInternal(pInt, record.h.name, fOpen); … … 1696 1713 /* The start is -512 from here. */ 1697 1714 pFileInt->offStart = RTFileTell(pInt->hTarFile) - sizeof(RTTARRECORD); 1715 /* remember the type of a file */ 1716 pFileInt->linkflag = record.h.linkflag; 1698 1717 1699 1718 /* Copy the new file structure to our cache. */ … … 1701 1720 if (ppszFilename) 1702 1721 *ppszFilename = RTStrDup(pFileInt->pszFilename); 1722 1723 if (pFileInt->linkflag == LF_DIR) 1724 { 1725 rc = VINF_TAR_DIR_PATH; 1726 } 1703 1727 } 1704 1728 } while (0);
Note:
See TracChangeset
for help on using the changeset viewer.