- Timestamp:
- Jul 4, 2013 7:46:39 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86979
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/err.h
r46403 r46971 1696 1696 /** Too long name or link string. */ 1697 1697 #define VERR_TAR_NAME_TOO_LONG (-947) 1698 /** A directory entry in the archive. */ 1699 #define VINF_TAR_DIR_PATH (925) 1698 1700 /** @} */ 1699 1701 -
trunk/src/VBox/Main/src-server/ApplianceImplIO.cpp
r46611 r46971 304 304 if (RT_SUCCESS(rc)) 305 305 { 306 fFound = !strcmp(pszFilename, RTPathFilename(pszLocation)); 306 if (rc == VINF_TAR_DIR_PATH) 307 { 308 break; 309 } 310 311 fFound = !RTStrICmp(pszFilename, pszLocation); 312 307 313 RTStrFree(pszFilename); 308 314 if (fFound) -
trunk/src/VBox/Main/src-server/ApplianceImplImport.cpp
r46754 r46971 809 809 { 810 810 throw setError(VBOX_E_FILE_ERROR, 811 tr("Could not open the current file in the archive (%Rrc)"), vrc); 811 tr("Could not open the current file in the OVA package (%Rrc)"), vrc); 812 } 813 else 814 { 815 if (vrc == VINF_TAR_DIR_PATH) 816 { 817 throw setError(VBOX_E_FILE_ERROR, 818 tr("Empty directory folder (%s) isn't allowed in the OVA package (%Rrc)"), 819 pszFilename, 820 vrc); 821 } 812 822 } 813 823 … … 1077 1087 break; 1078 1088 } 1089 1090 Utf8Str extension(RTPathExt(pszFilename)); 1091 1092 if (!extension.endsWith(".ovf",Utf8Str::CaseInsensitive)) 1093 { 1094 vrc = VERR_FILE_NOT_FOUND; 1095 rc = setError(VBOX_E_FILE_ERROR, 1096 tr("First file in the OVA package must have the extension 'ovf'. " 1097 "But the file '%s' has the different extension (%Rrc)"), 1098 pszFilename, 1099 vrc); 1100 break; 1101 } 1102 1079 1103 pTarIo = TarCreateInterface(); 1080 1104 if (!pTarIo) … … 1141 1165 size_t cbSize = 0; 1142 1166 int vrc = ShaReadBuf(strFilename.c_str(), &pvTmpBuf, &cbSize, pIfIo, pStorage); 1143 if ( 1167 if (RT_FAILURE(vrc) 1144 1168 || !pvTmpBuf) 1145 1169 throw setError(VBOX_E_FILE_ERROR, … … 1587 1611 throw setError(VBOX_E_IPRT_ERROR, 1588 1612 tr("Getting the current file within the archive failed (%Rrc)"), vrc); 1613 else 1614 { 1615 if (vrc == VINF_TAR_DIR_PATH) 1616 { 1617 throw setError(VBOX_E_FILE_ERROR, 1618 tr("Empty directory folder (%s) isn't allowed in the OVA package (%Rrc)"), 1619 pszFilename, 1620 vrc); 1621 } 1622 } 1589 1623 /* Skip the OVF file, cause this was read in IAppliance::Read already. */ 1590 1624 vrc = RTTarSeekNextFile(tar); … … 1593 1627 throw setError(VBOX_E_IPRT_ERROR, 1594 1628 tr("Seeking within the archive failed (%Rrc)"), vrc); 1629 else 1630 { 1631 if (vrc == VINF_TAR_DIR_PATH) 1632 { 1633 RTTarCurrentFile(tar, &pszFilename); 1634 throw setError(VBOX_E_FILE_ERROR, 1635 tr("Empty directory folder (%s) isn't allowed in the OVA package (%Rrc)"), 1636 pszFilename, 1637 vrc); 1638 } 1639 } 1595 1640 1596 1641 PVDINTERFACEIO pCallbacks = pShaIo; … … 1878 1923 if (RT_SUCCESS(vrc)) 1879 1924 { 1880 if (!strcmp(pszCurFile, RTPathFilename(strFile.c_str()))) 1881 rc = readManifestFile(strFile, ppvBuf, pcbSize, pCallbacks, pStorage); 1882 RTStrFree(pszCurFile); 1925 if (vrc == VINF_TAR_DIR_PATH) 1926 { 1927 rc = setError(VBOX_E_FILE_ERROR, 1928 tr("Empty directory folder (%s) isn't allowed in the OVA package (%Rrc)"), 1929 pszCurFile, 1930 vrc); 1931 } 1932 else 1933 { 1934 if (!strcmp(pszCurFile, RTPathFilename(strFile.c_str()))) 1935 rc = readManifestFile(strFile, ppvBuf, pcbSize, pCallbacks, pStorage); 1936 RTStrFree(pszCurFile); 1937 } 1883 1938 } 1884 1939 else if (vrc != VERR_TAR_END_OF_FILE) … … 2771 2826 { 2772 2827 throw setError(E_FAIL, 2773 tr("Internal inconsistency looking up disk image '%s'"), 2828 tr("Internal inconsistency looking up disk image '%s'. " 2829 "Check compliance OVA package structure and file names " 2830 "references in the section <References> in the OVF file."), 2774 2831 availableImage.c_str()); 2775 2832 } … … 3203 3260 { 3204 3261 throw setError(E_FAIL, 3205 tr("Internal inconsistency looking up disk image '%s'"), 3262 tr("Internal inconsistency looking up disk image '%s'. " 3263 "Check compliance OVA package structure and file names " 3264 "references in the section <References> in the OVF file."), 3206 3265 availableImage.c_str()); 3207 3266 } -
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.