Changeset 77047 in vbox for trunk/src/VBox/Runtime/common/fs
- Timestamp:
- Jan 30, 2019 3:38:53 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp
r76553 r77047 1704 1704 * @param cDepth Number of recursions. Used to deal with loopy 1705 1705 * directories. 1706 * @param fFilesWithSrcPath Whether to add files using @a pszSrc or to add 1707 * as VFS handles (open first). For saving native 1708 * file descriptors. 1706 1709 */ 1707 1710 static int rtFsIsoMakerCmdAddVfsDirRecursive(PRTFSISOMAKERCMDOPTS pOpts, RTVFSDIR hVfsDir, uint32_t idxDirObj, 1708 char *pszSrc, size_t cchSrc, uint32_t fNamespaces, uint8_t cDepth) 1711 char *pszSrc, size_t cchSrc, uint32_t fNamespaces, uint8_t cDepth, 1712 bool fFilesWithSrcPath) 1709 1713 { 1710 1714 /* … … 1775 1779 { 1776 1780 /* 1777 * Files are added with VFS file sources.1778 * The ASSUMPTION is that we're working with a virtual file system1779 * here and won't be wasting native file descriptors.1781 * Files are either added with VFS handles or paths to the sources, 1782 * depending on what's considered more efficient. We prefer the latter 1783 * if hVfsDir maps to native handle and not a virtual one. 1780 1784 */ 1781 RTVFSFILE hVfsFileSrc; 1782 rc = RTVfsDirOpenFile(hVfsDir, pDirEntry->szName, 1783 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFileSrc); 1785 if (!fFilesWithSrcPath) 1786 { 1787 RTVFSFILE hVfsFileSrc; 1788 rc = RTVfsDirOpenFile(hVfsDir, pDirEntry->szName, 1789 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFileSrc); 1790 if (RT_SUCCESS(rc)) 1791 { 1792 rc = RTFsIsoMakerAddUnnamedFileWithVfsFile(pOpts->hIsoMaker, hVfsFileSrc, &idxObj); 1793 RTVfsFileRelease(hVfsFileSrc); 1794 if (RT_FAILURE(rc)) 1795 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding file '%s' (VFS recursive, handle): %Rrc", 1796 pszSrc, rc); 1797 } 1798 else 1799 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error opening file '%s' (VFS recursive): %Rrc", pszSrc, rc); 1800 } 1801 else 1802 { 1803 /* Add file with source path: */ 1804 rc = RTFsIsoMakerAddUnnamedFileWithSrcPath(pOpts->hIsoMaker, pszSrc, &idxObj); 1805 if (RT_FAILURE(rc)) 1806 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding file '%s' (VFS recursive, path): %Rrc", 1807 pszSrc, rc); 1808 } 1784 1809 if (RT_SUCCESS(rc)) 1785 1810 { 1786 rc = RTFsIsoMakerAddUnnamedFileWithVfsFile(pOpts->hIsoMaker, hVfsFileSrc, &idxObj); 1787 RTVfsFileRelease(hVfsFileSrc); 1788 if (RT_SUCCESS(rc)) 1789 { 1790 pOpts->cItemsAdded++; 1791 rc = RTFsIsoMakerObjSetNameAndParent(pOpts->hIsoMaker, idxObj, idxDirObj, fNamespaces, 1792 pDirEntry->szName); 1793 if (RT_FAILURE(rc)) 1794 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error setting parent & name on file '%s' to '%s': %Rrc", 1795 pszSrc, pDirEntry->szName, rc); 1796 } 1797 else 1798 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error adding file '%s' (VFS recursive): %Rrc", pszSrc, rc); 1811 pOpts->cItemsAdded++; 1812 rc = RTFsIsoMakerObjSetNameAndParent(pOpts->hIsoMaker, idxObj, idxDirObj, fNamespaces, 1813 pDirEntry->szName); 1814 if (RT_FAILURE(rc)) 1815 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error setting parent & name on file '%s' to '%s': %Rrc", 1816 pszSrc, pDirEntry->szName, rc); 1799 1817 } 1800 else1801 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Error opening file '%s' (VFS recursive): %Rrc", pszSrc, rc);1802 1818 } 1803 1819 else if (RTFS_IS_DIRECTORY(pDirEntry->Info.Attr.fMode)) … … 1819 1835 /* Recurse into the sub-directory. */ 1820 1836 rc = rtFsIsoMakerCmdAddVfsDirRecursive(pOpts, hVfsSubDirSrc, idxObj, pszSrc, 1821 cchSrc + 1 + pDirEntry->cbName, fNamespaces, cDepth + 1); 1837 cchSrc + 1 + pDirEntry->cbName, fNamespaces, cDepth + 1, 1838 fFilesWithSrcPath); 1822 1839 else 1823 1840 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, … … 1864 1881 * @param pszSrc The source directory name. 1865 1882 * @param pParsed The parsed names. 1883 * @param fFilesWithSrcPath Whether to add files using @a pszSrc 1884 * or to add as VFS handles (open first). For 1885 * saving native file descriptors. 1866 1886 * @param pidxObj Where to return the configuration index for the 1867 1887 * added file. Optional. 1868 1888 */ 1869 1889 static int rtFsIsoMakerCmdAddVfsDirCommon(PRTFSISOMAKERCMDOPTS pOpts, RTVFSDIR hVfsDirSrc, char *pszSrc, 1870 PCRTFSISOMKCMDPARSEDNAMES pParsed, PCRTFSOBJINFO pObjInfo)1890 PCRTFSISOMKCMDPARSEDNAMES pParsed, bool fFilesWithSrcPath, PCRTFSOBJINFO pObjInfo) 1871 1891 { 1872 1892 /* … … 1904 1924 fNamespaces |= pParsed->aNames[i].fNameSpecifiers & RTFSISOMAKERCMDNAME_MAJOR_MASK; 1905 1925 rc = rtFsIsoMakerCmdAddVfsDirRecursive(pOpts, hVfsDirSrc, idxObj, pszSrc, 1906 pParsed->aNames[pParsed->cNamesWithSrc - 1].cchPath, fNamespaces, 0 /*cDepth*/); 1926 pParsed->aNames[pParsed->cNamesWithSrc - 1].cchPath, fNamespaces, 0 /*cDepth*/, 1927 fFilesWithSrcPath); 1907 1928 } 1908 1929 … … 1929 1950 if (RT_SUCCESS(rc)) 1930 1951 { 1931 rc = rtFsIsoMakerCmdAddVfsDirCommon(pOpts, hVfsDirSrc, pszSrc, pParsed, pObjInfo);1952 rc = rtFsIsoMakerCmdAddVfsDirCommon(pOpts, hVfsDirSrc, pszSrc, pParsed, false /*fFilesWithSrcPath*/, pObjInfo); 1932 1953 RTVfsDirRelease(hVfsDirSrc); 1933 1954 } … … 1958 1979 if (RT_SUCCESS(rc)) 1959 1980 { 1960 rc = rtFsIsoMakerCmdAddVfsDirCommon(pOpts, hVfsDirSrc, pszSrc, pParsed, pObjInfo); 1981 rc = rtFsIsoMakerCmdAddVfsDirCommon(pOpts, hVfsDirSrc, pszSrc, pParsed, 1982 RTVfsDirIsStdDir(hVfsDirSrc) /*fFilesWithSrcPath*/, pObjInfo); 1961 1983 RTVfsDirRelease(hVfsDirSrc); 1962 1984 }
Note:
See TracChangeset
for help on using the changeset viewer.