Changeset 67549 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Jun 21, 2017 11:45:48 PM (7 years ago)
- Location:
- trunk/src/VBox/Runtime/common/fs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fs/isomaker.cpp
r67539 r67549 274 274 /** The publisher ID or (root) file reference (ISO9660PRIMARYVOLDESC::achPublisherId). Empty if NULL. */ 275 275 char *pszPublisherId; 276 /** The data preperer ID or (root) file reference (ISO9660PRIMARYVOLDESC::achDataPreparerId). 277 * Defaults to g_szPreparerIdPrimaryIso or g_szPreparerIdJoliet. */ 276 /* The data preperer ID or (root) file reference (ISO9660PRIMARYVOLDESC::achDataPreparerId). Empty if NULL. */ 278 277 char *pszDataPreparerId; 279 /** The application ID or (root) file reference (ISO9660PRIMARYVOLDESC::achApplicationId). None if NULL. */ 278 /* The application ID or (root) file reference (ISO9660PRIMARYVOLDESC::achApplicationId). 279 * Defaults to g_szAppIdPrimaryIso or g_szAppIdJoliet. */ 280 280 char *pszApplicationId; 281 281 /** The copyright (root) file identifier (ISO9660PRIMARYVOLDESC::achCopyrightFileId). None if NULL. */ … … 628 628 /** The default translation table filename. */ 629 629 static const char g_szTransTbl[] = "TRANS.TBL"; 630 /** The default data preparerID for the primary ISO-9660 volume descriptor. */631 static char g_sz PreparerIdPrimaryIso[64] = "";632 /** The default data preparerID for the joliet volume descriptor. */633 static char g_sz PreparerIdJoliet[64] = "";630 /** The default application ID for the primary ISO-9660 volume descriptor. */ 631 static char g_szAppIdPrimaryIso[64] = ""; 632 /** The default application ID for the joliet volume descriptor. */ 633 static char g_szAppIdJoliet[64] = ""; 634 634 /** The default system ID the primary ISO-9660 volume descriptor. */ 635 635 static char g_szSystemId[64] = ""; … … 672 672 VERR_INTERNAL_ERROR_5); 673 673 674 if (g_sz PreparerIdPrimaryIso[0] == '\0')675 RTStrPrintf(g_sz PreparerIdPrimaryIso, sizeof(g_szPreparerIdPrimaryIso), "IPRT ISO MAKER V%u.%u.%u R%s",674 if (g_szAppIdPrimaryIso[0] == '\0') 675 RTStrPrintf(g_szAppIdPrimaryIso, sizeof(g_szAppIdPrimaryIso), "IPRT ISO MAKER V%u.%u.%u R%s", 676 676 RTBldCfgVersionMajor(), RTBldCfgVersionMinor(), RTBldCfgVersionBuild(), RTBldCfgRevisionStr()); 677 if (g_sz PreparerIdJoliet[0] == '\0')678 RTStrPrintf(g_sz PreparerIdJoliet, sizeof(g_szPreparerIdJoliet),677 if (g_szAppIdJoliet[0] == '\0') 678 RTStrPrintf(g_szAppIdJoliet, sizeof(g_szAppIdJoliet), 679 679 "IPRT ISO Maker v%s r%s", RTBldCfgVersion(), RTBldCfgRevisionStr()); 680 680 if (g_szSystemId[0] == '\0') … … 702 702 pThis->PrimaryIso.pszTransTbl = (char *)g_szTransTbl; 703 703 pThis->PrimaryIso.pszSystemId = g_szSystemId; 704 //pThis->PrimaryIso.pszVolumeId 705 //pThis->PrimaryIso.pszSetVolumeId 706 //pThis->PrimaryIso.pszPublisherId 707 pThis->PrimaryIso.pszDataPreparerId = g_szPreparerIdPrimaryIso;708 //pThis->PrimaryIso.pszApplicationId = NULL;709 //pThis->PrimaryIso.pszCopyrightFileId = NULL;704 //pThis->PrimaryIso.pszVolumeId = NULL; 705 //pThis->PrimaryIso.pszSetVolumeId = NULL; 706 //pThis->PrimaryIso.pszPublisherId = NULL; 707 //pThis->PrimaryIso.pszDataPreparerId = NULL; 708 pThis->PrimaryIso.pszApplicationId = g_szAppIdPrimaryIso; 709 //pThis->PrimaryIso.pszCopyrightFileId = NULL; 710 710 //pThis->PrimaryIso.pszAbstractFileId = NULL; 711 711 //pThis->PrimaryIso.pszBibliographicFileId = NULL; … … 720 720 //pThis->Joliet.pszSetVolumeId = NULL; 721 721 //pThis->Joliet.pszPublisherId = NULL; 722 pThis->Joliet.pszDataPreparerId = g_szPreparerIdJoliet;723 //pThis->Joliet.pszApplicationId = NULL;722 //pThis->Joliet.pszDataPreparerId = NULL; 723 pThis->Joliet.pszApplicationId = g_szAppIdJoliet; 724 724 //pThis->Joliet.pszCopyrightFileId = NULL; 725 725 //pThis->Joliet.pszAbstractFileId = NULL; … … 940 940 { 941 941 if (pNamespace->pszTransTbl != g_szTransTbl) 942 RT MemFree(pNamespace->pszTransTbl);942 RTStrFree(pNamespace->pszTransTbl); 943 943 pNamespace->pszTransTbl = NULL; 944 944 } … … 950 950 { 951 951 if (pNamespace->pszSystemId != g_szSystemId) 952 RT MemFree(pNamespace->pszSystemId);952 RTStrFree(pNamespace->pszSystemId); 953 953 pNamespace->pszSystemId = NULL; 954 954 } … … 956 956 if (pNamespace->pszVolumeId) 957 957 { 958 RT MemFree(pNamespace->pszVolumeId);958 RTStrFree(pNamespace->pszVolumeId); 959 959 pNamespace->pszVolumeId = NULL; 960 960 } … … 962 962 if (pNamespace->pszVolumeSetId) 963 963 { 964 RT MemFree(pNamespace->pszVolumeSetId);964 RTStrFree(pNamespace->pszVolumeSetId); 965 965 pNamespace->pszVolumeSetId = NULL; 966 966 } … … 968 968 if (pNamespace->pszPublisherId) 969 969 { 970 RT MemFree(pNamespace->pszPublisherId);970 RTStrFree(pNamespace->pszPublisherId); 971 971 pNamespace->pszPublisherId = NULL; 972 972 } … … 974 974 if (pNamespace->pszDataPreparerId) 975 975 { 976 if ( pNamespace->pszDataPreparerId != g_szPreparerIdPrimaryIso 977 && pNamespace->pszDataPreparerId != g_szPreparerIdJoliet) 978 RTMemFree(pNamespace->pszDataPreparerId); 976 RTStrFree(pNamespace->pszDataPreparerId); 979 977 pNamespace->pszDataPreparerId = NULL; 980 978 } … … 982 980 if (pNamespace->pszApplicationId) 983 981 { 984 RTMemFree(pNamespace->pszApplicationId); 982 if ( pNamespace->pszApplicationId != g_szAppIdPrimaryIso 983 && pNamespace->pszApplicationId != g_szAppIdJoliet) 984 RTStrFree(pNamespace->pszApplicationId); 985 985 pNamespace->pszApplicationId = NULL; 986 986 } … … 988 988 if (pNamespace->pszCopyrightFileId) 989 989 { 990 RT MemFree(pNamespace->pszCopyrightFileId);990 RTStrFree(pNamespace->pszCopyrightFileId); 991 991 pNamespace->pszCopyrightFileId = NULL; 992 992 } … … 994 994 if (pNamespace->pszAbstractFileId) 995 995 { 996 RT MemFree(pNamespace->pszAbstractFileId);996 RTStrFree(pNamespace->pszAbstractFileId); 997 997 pNamespace->pszAbstractFileId = NULL; 998 998 } … … 1000 1000 if (pNamespace->pszBibliographicFileId) 1001 1001 { 1002 RT MemFree(pNamespace->pszBibliographicFileId);1002 RTStrFree(pNamespace->pszBibliographicFileId); 1003 1003 pNamespace->pszBibliographicFileId = NULL; 1004 1004 } … … 1210 1210 return VINF_SUCCESS; 1211 1211 } 1212 1213 1214 /** 1215 * Sets a string property in one or more namespaces. 1216 * 1217 * @returns IPRT status code. 1218 * @param hIsoMaker The ISO maker handle. 1219 * @param enmStringProp The string property to set. 1220 * @param fNamespaces The namespaces to set it in. 1221 * @param pszValue The value to set it to. NULL is treated like an 1222 * empty string. The value will be silently truncated 1223 * to fit the available space. 1224 */ 1225 RTDECL(int) RTFsIsoMakerSetStringProp(RTFSISOMAKER hIsoMaker, RTFSISOMAKERSTRINGPROP enmStringProp, 1226 uint32_t fNamespaces, const char *pszValue) 1227 { 1228 /* 1229 * Validate input. 1230 */ 1231 PRTFSISOMAKERINT pThis = hIsoMaker; 1232 RTFSISOMAKER_ASSERT_VALID_HANDLE_RET(pThis); 1233 AssertReturn( enmStringProp > RTFSISOMAKERSTRINGPROP_INVALID 1234 && enmStringProp < RTFSISOMAKERSTRINGPROP_END, VERR_INVALID_PARAMETER); 1235 AssertReturn(!(fNamespaces & ~RTFSISOMAKER_NAMESPACE_VALID_MASK), VERR_INVALID_FLAGS); 1236 if (pszValue) 1237 { 1238 AssertPtrReturn(pszValue, VERR_INVALID_POINTER); 1239 if (*pszValue == '\0') 1240 pszValue = NULL; 1241 } 1242 AssertReturn(!pThis->fFinalized, VERR_WRONG_ORDER); 1243 1244 /* 1245 * Work the namespaces. 1246 */ 1247 for (uint32_t i = 0; i < RT_ELEMENTS(g_aRTFsIsoNamespaces); i++) 1248 if (fNamespaces & g_aRTFsIsoNamespaces[i].fNamespace) 1249 { 1250 PRTFSISOMAKERNAMESPACE pNamespace = (PRTFSISOMAKERNAMESPACE)((uintptr_t)pThis + g_aRTFsIsoNamespaces[i].offNamespace); 1251 if (pNamespace->uLevel > 0) 1252 { 1253 /* Get a pointer to the field. */ 1254 char **ppszValue; 1255 switch (enmStringProp) 1256 { 1257 case RTFSISOMAKERSTRINGPROP_SYSTEM_ID: ppszValue = &pNamespace->pszSystemId; break; 1258 case RTFSISOMAKERSTRINGPROP_VOLUME_ID: ppszValue = &pNamespace->pszVolumeId; break; 1259 case RTFSISOMAKERSTRINGPROP_VOLUME_SET_ID: ppszValue = &pNamespace->pszVolumeSetId; break; 1260 case RTFSISOMAKERSTRINGPROP_PUBLISHER_ID: ppszValue = &pNamespace->pszPublisherId; break; 1261 case RTFSISOMAKERSTRINGPROP_DATA_PREPARER_ID: ppszValue = &pNamespace->pszDataPreparerId; break; 1262 case RTFSISOMAKERSTRINGPROP_APPLICATION_ID: ppszValue = &pNamespace->pszApplicationId; break; 1263 case RTFSISOMAKERSTRINGPROP_COPYRIGHT_FILE_ID: ppszValue = &pNamespace->pszCopyrightFileId; break; 1264 case RTFSISOMAKERSTRINGPROP_ABSTRACT_FILE_ID: ppszValue = &pNamespace->pszAbstractFileId; break; 1265 case RTFSISOMAKERSTRINGPROP_BIBLIOGRAPHIC_FILE_ID: ppszValue = &pNamespace->pszBibliographicFileId; break; 1266 default: AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE); 1267 } 1268 1269 /* Free the old value. */ 1270 char *pszOld = *ppszValue; 1271 if ( pszOld 1272 && pszOld != g_szAppIdPrimaryIso 1273 && pszOld != g_szAppIdJoliet 1274 && pszOld != g_szSystemId) 1275 RTStrFree(pszOld); 1276 1277 /* Set the new value. */ 1278 if (!pszValue) 1279 *ppszValue = NULL; 1280 else 1281 { 1282 *ppszValue = RTStrDup(pszValue); 1283 AssertReturn(*ppszValue, VERR_NO_STR_MEMORY); 1284 } 1285 } 1286 } 1287 return VINF_SUCCESS; 1288 } 1289 1212 1290 1213 1291 -
trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp
r67538 r67549 230 230 RTFSISOMAKERCMD_OPT_UID, 231 231 RTFSISOMAKERCMD_OPT_USE_FILE_VERSION, 232 RTFSISOMAKERCMD_OPT_VOLUME_ID, 232 233 RTFSISOMAKERCMD_OPT_VOLUME_SET_ID, 233 234 RTFSISOMAKERCMD_OPT_VOLUME_SET_SEQ_NO, … … 427 428 /* 428 429 * genisoimage/mkisofs compatibility options we've implemented: 429 *430 430 */ 431 /* booting: */ 431 432 { "--generic-boot", 'G', RTGETOPT_REQ_STRING }, 432 433 DD("-eltorito-boot", 'b', RTGETOPT_REQ_STRING ), … … 441 442 { "--boot-catalog", 'c', RTGETOPT_REQ_STRING }, 442 443 444 /* String props: */ 445 DD("-abstract", RTFSISOMAKERCMD_OPT_ABSTRACT_FILE_ID, RTGETOPT_REQ_STRING ), 446 { "--application-id", 'A', RTGETOPT_REQ_STRING }, 447 DD("-biblio", RTFSISOMAKERCMD_OPT_BIBLIOGRAPHIC_FILE_ID, RTGETOPT_REQ_STRING ), 448 DD("-copyright", RTFSISOMAKERCMD_OPT_COPYRIGHT_FILE_ID, RTGETOPT_REQ_STRING ), 449 DD("-publisher", 'P', RTGETOPT_REQ_STRING ), 450 { "--preparer", 'p', RTGETOPT_REQ_STRING }, 451 DD("-sysid", RTFSISOMAKERCMD_OPT_SYSTEM_ID, RTGETOPT_REQ_STRING ), 452 { "--volume-id", RTFSISOMAKERCMD_OPT_VOLUME_ID, RTGETOPT_REQ_STRING }, /* should've been '-V' */ 453 DD("-volset", RTFSISOMAKERCMD_OPT_VOLUME_SET_ID, RTGETOPT_REQ_STRING ), 443 454 444 455 /* 445 456 * genisoimage/mkisofs compatibility: 446 457 */ 447 DD("-abstract", RTFSISOMAKERCMD_OPT_ABSTRACT_FILE_ID, RTGETOPT_REQ_STRING ),448 { "--application-id", 'A', RTGETOPT_REQ_STRING },449 458 DD("-allow-limited-size", RTFSISOMAKERCMD_OPT_ALLOW_LIMITED_SIZE, RTGETOPT_REQ_NOTHING ), 450 459 DD("-allow-leading-dots", RTFSISOMAKERCMD_OPT_ALLOW_LEADING_DOTS, RTGETOPT_REQ_NOTHING ), … … 452 461 DD("-allow-lowercase", RTFSISOMAKERCMD_OPT_ALLOW_LOWERCASE, RTGETOPT_REQ_NOTHING ), 453 462 DD("-allow-multidot", RTFSISOMAKERCMD_OPT_ALLOW_MULTI_DOT, RTGETOPT_REQ_NOTHING ), 454 DD("-biblio", RTFSISOMAKERCMD_OPT_BIBLIOGRAPHIC_FILE_ID, RTGETOPT_REQ_STRING ),455 463 DD("-cache-inodes", RTFSISOMAKERCMD_OPT_DETECT_HARDLINKS, RTGETOPT_REQ_NOTHING ), 456 464 DD("-no-cache-inodes", RTFSISOMAKERCMD_OPT_NO_DETECT_HARDLINKS, RTGETOPT_REQ_NOTHING ), 457 458 465 DD("-alpha-boot", RTFSISOMAKERCMD_OPT_ALPHA_BOOT, RTGETOPT_REQ_STRING ), 459 466 DD("-hppa-bootloader", RTFSISOMAKERCMD_OPT_HPPA_BOOTLOADER, RTGETOPT_REQ_STRING ), … … 468 475 DD("-check-oldnames", RTFSISOMAKERCMD_OPT_CHECK_OLD_NAMES, RTGETOPT_REQ_NOTHING ), 469 476 DD("-check-session", RTFSISOMAKERCMD_OPT_CHECK_SESSION, RTGETOPT_REQ_STRING ), 470 DD("-copyright", RTFSISOMAKERCMD_OPT_COPYRIGHT_FILE_ID, RTGETOPT_REQ_STRING ),471 477 { "--dont-append-dot", 'd', RTGETOPT_REQ_NOTHING }, 472 478 { "--deep-directories", 'D', RTGETOPT_REQ_NOTHING }, … … 521 527 DD("-no-pad", RTFSISOMAKERCMD_OPT_NO_PAD, RTGETOPT_REQ_NOTHING ), 522 528 DD("-path-list", RTFSISOMAKERCMD_OPT_PATH_LIST, RTGETOPT_REQ_STRING ), 523 DD("-publisher", 'P', RTGETOPT_REQ_STRING ),524 { "--preparer", 'p', RTGETOPT_REQ_STRING },525 529 DD("-print-size", RTFSISOMAKERCMD_OPT_PRINT_SIZE, RTGETOPT_REQ_NOTHING ), 526 530 DD("-quiet", RTFSISOMAKERCMD_OPT_QUIET, RTGETOPT_REQ_NOTHING ), … … 538 542 DD("-sunx86-boot", RTFSISOMAKERCMD_OPT_SUNX86_BOOT, RTGETOPT_REQ_STRING ), 539 543 DD("-sunx86-label", RTFSISOMAKERCMD_OPT_SUNX86_LABEL, RTGETOPT_REQ_STRING ), 540 DD("-sysid", RTFSISOMAKERCMD_OPT_SYSTEM_ID, RTGETOPT_REQ_STRING ),541 544 { "--trans-tbl", 'T', RTGETOPT_REQ_NOTHING }, 542 545 DD("-table-name", RTFSISOMAKERCMD_OPT_TRANS_TBL_NAME, RTGETOPT_REQ_STRING ), … … 547 550 { "--untranslated-filenames", 'U', RTGETOPT_REQ_NOTHING }, 548 551 DD("-no-iso-translate", RTFSISOMAKERCMD_OPT_NO_ISO_TRANSLATE, RTGETOPT_REQ_NOTHING ), 549 { "--volume-id", 'V', RTGETOPT_REQ_STRING },550 DD("-volset", RTFSISOMAKERCMD_OPT_VOLUME_SET_ID, RTGETOPT_REQ_STRING ),551 552 DD("-volset-size", RTFSISOMAKERCMD_OPT_VOLUME_SET_SIZE, RTGETOPT_REQ_UINT32 ), 552 553 DD("-volset-seqno", RTFSISOMAKERCMD_OPT_VOLUME_SET_SEQ_NO, RTGETOPT_REQ_UINT32 ), … … 640 641 "%s failed with rc=%Rrc: %s\n" 641 642 " '%s'\n" 642 " %*s^ \n",643 " %*s^", 643 644 pszFunction, rc, pErrInfo->pszMsg, pszSpec, offError, ""); 644 645 else 645 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s failed to open '%s': %Rrc: %s \n",646 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s failed to open '%s': %Rrc: %s", 646 647 pszFunction, pszSpec, rc, pErrInfo->pszMsg); 647 648 } … … 652 653 "%s failed with rc=%Rrc:\n" 653 654 " '%s'\n" 654 " %*s^ \n",655 " %*s^", 655 656 pszFunction, rc, pszSpec, offError, ""); 656 657 else 657 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s failed to open '%s': %Rrc \n", pszFunction, pszSpec, rc);658 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "%s failed to open '%s': %Rrc", pszFunction, pszSpec, rc); 658 659 } 659 660 return rc; … … 1827 1828 if (RT_FAILURE(rc)) 1828 1829 return rtFsIsoMakerCmdErrorRc(pOpts, rc, 1829 "RTFsIsoMakerObjEnableBootInfoTablePatching failed on entry #%u: %Rrc \n",1830 "RTFsIsoMakerObjEnableBootInfoTablePatching failed on entry #%u: %Rrc", 1830 1831 idxBootCat, rc); 1831 1832 } … … 1837 1838 rc = RTFsIsoMakerObjQueryDataSize(pOpts->hIsoMaker, idxImageObj, &cbImage); 1838 1839 if (RT_FAILURE(rc)) 1839 return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerObjGetDataSize failed on entry #%u: %Rrc \n",1840 return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerObjGetDataSize failed on entry #%u: %Rrc", 1840 1841 idxBootCat, rc); 1841 1842 if (cbImage == 1228800) … … 1862 1863 pBootCatEntry->u.Validation.pszString); 1863 1864 if (RT_FAILURE(rc)) 1864 return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerBootCatSetValidationEntry failed: %Rrc \n", rc);1865 return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerBootCatSetValidationEntry failed: %Rrc", rc); 1865 1866 break; 1866 1867 … … 1877 1878 ISO9660_ELTORITO_SEL_CRIT_TYPE_NONE, NULL, 0); 1878 1879 if (RT_FAILURE(rc)) 1879 return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerBootCatSetSectionEntry failed on entry #%u: %Rrc \n",1880 return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerBootCatSetSectionEntry failed on entry #%u: %Rrc", 1880 1881 idxBootCat, rc); 1881 1882 break; … … 1895 1896 if (RT_FAILURE(rc)) 1896 1897 return rtFsIsoMakerCmdErrorRc(pOpts, rc, 1897 "RTFsIsoMakerBootCatSetSectionHeaderEntry failed on entry #%u: %Rrc \n",1898 "RTFsIsoMakerBootCatSetSectionHeaderEntry failed on entry #%u: %Rrc", 1898 1899 idxBootCat, rc); 1899 1900 break; … … 1922 1923 } 1923 1924 1925 1926 /** 1927 * Sets a string property in all namespaces. 1928 * 1929 * @returns IPRT status code. 1930 * @param pOpts The ISO maker command instance. 1931 * @param pszValue The new string value. 1932 * @param enmStringProp The string property. 1933 */ 1934 static int rtFsIsoMakerCmdOptSetStringProp(PRTFSISOMAKERCMDOPTS pOpts, const char *pszValue, RTFSISOMAKERSTRINGPROP enmStringProp) 1935 { 1936 int rc = RTFsIsoMakerSetStringProp(pOpts->hIsoMaker, enmStringProp, RTFSISOMAKER_NAMESPACE_ALL, pszValue); 1937 if (RT_FAILURE(rc)) 1938 rc = rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to set string property %d to '%s': %Rrc", enmStringProp, pszValue, rc); 1939 return rc; 1940 } 1924 1941 1925 1942 … … 2068 2085 break; 2069 2086 2087 /* 2088 * Image/namespace property related options. 2089 */ 2090 case RTFSISOMAKERCMD_OPT_ABSTRACT_FILE_ID: 2091 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_ABSTRACT_FILE_ID); 2092 break; 2093 2094 case 'A': /* --application-id */ 2095 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_APPLICATION_ID); 2096 break; 2097 2098 case RTFSISOMAKERCMD_OPT_BIBLIOGRAPHIC_FILE_ID: 2099 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_BIBLIOGRAPHIC_FILE_ID); 2100 break; 2101 2102 case RTFSISOMAKERCMD_OPT_COPYRIGHT_FILE_ID: 2103 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_COPYRIGHT_FILE_ID); 2104 break; 2105 2106 case 'P': /* -publisher */ 2107 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_PUBLISHER_ID); 2108 break; 2109 2110 case 'p': /* --preparer*/ 2111 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_DATA_PREPARER_ID); 2112 break; 2113 2114 case RTFSISOMAKERCMD_OPT_SYSTEM_ID: 2115 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_SYSTEM_ID); 2116 break; 2117 2118 case RTFSISOMAKERCMD_OPT_VOLUME_ID: /* (should've been '-V') */ 2119 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_VOLUME_ID); 2120 break; 2121 2122 case RTFSISOMAKERCMD_OPT_VOLUME_SET_ID: 2123 rc = rtFsIsoMakerCmdOptSetStringProp(&Opts, ValueUnion.psz, RTFSISOMAKERSTRINGPROP_VOLUME_SET_ID); 2124 break; 2070 2125 2071 2126 /* … … 2099 2154 rc = rtFsIsoMakerCmdErrorRc(&Opts, rc, "Unknown option: '%s'", ValueUnion.psz); 2100 2155 else if (ValueUnion.pDef) 2101 rc = rtFsIsoMakerCmdErrorRc(&Opts, rc, "%s: %Rrs \n", ValueUnion.pDef->pszLong, rc);2156 rc = rtFsIsoMakerCmdErrorRc(&Opts, rc, "%s: %Rrs", ValueUnion.pDef->pszLong, rc); 2102 2157 else 2103 rc = rtFsIsoMakerCmdErrorRc(&Opts, rc, "%Rrs \n", rc);2158 rc = rtFsIsoMakerCmdErrorRc(&Opts, rc, "%Rrs", rc); 2104 2159 return rtFsIsoMakerCmdDeleteState(&Opts, rc); 2105 2160 } -
trunk/src/VBox/Runtime/common/fs/isomakerimport.cpp
r67539 r67549 721 721 722 722 /** 723 * Imports a UTF-16BE string property from the joliet volume descriptor. 724 * 725 * The fields are normally space filled and padded, but we also consider zero 726 * bytes are fillers. If the field only contains padding, the string property 727 * will remain unchanged. 728 * 729 * @returns IPRT status code (ignorable). 730 * @param pThis The importer instance. 731 * @param pachField Pointer to the field. The structure type 732 * is 'char' for hysterical raisins, while the 733 * real type is 'RTUTF16'. 734 * @param cchField The field length. 735 * @param enmStringProp The corresponding string property. 736 * 737 * @note Clobbers pThis->pbBuf! 738 */ 739 static int rtFsIsoImportUtf16BigStringField(PRTFSISOMKIMPORTER pThis, const char *pachField, size_t cchField, 740 RTFSISOMAKERSTRINGPROP enmStringProp) 741 { 742 /* 743 * Scan the field from the end as this way we know the result length if we find anything. 744 */ 745 PCRTUTF16 pwcField = (PCRTUTF16)pachField; 746 size_t cwcField = cchField / sizeof(RTUTF16); /* ignores any odd field byte */ 747 size_t off = cwcField; 748 while (off-- > 0) 749 { 750 RTUTF16 wc = RT_BE2H_U16(pwcField[off]); 751 if (wc == ' ' || wc == '\0') 752 { /* likely */ } 753 else 754 { 755 /* 756 * Convert to UTF-16. 757 */ 758 char *pszCopy = (char *)pThis->abBuf; 759 int rc = RTUtf16BigToUtf8Ex(pwcField, off + 1, &pszCopy, sizeof(pThis->abBuf), NULL); 760 if (RT_SUCCESS(rc)) 761 { 762 rc = RTFsIsoMakerSetStringProp(pThis->hIsoMaker, enmStringProp, RTFSISOMAKER_NAMESPACE_JOLIET, pszCopy); 763 if (RT_SUCCESS(rc)) 764 return VINF_SUCCESS; 765 return rtFsIsoImpError(pThis, rc, "RTFsIsoMakerSetStringProp failed setting field %d to '%s': %Rrc", 766 enmStringProp, pszCopy, rc); 767 } 768 return rtFsIsoImpError(pThis, rc, "RTUtf16BigToUtf8Ex failed converting field %d to UTF-8: %Rrc - %.*Rhxs", 769 enmStringProp, rc, off * sizeof(RTUTF16), pwcField); 770 } 771 } 772 return VINF_SUCCESS; 773 } 774 775 776 /** 777 * Imports a string property from the primary volume descriptor. 778 * 779 * The fields are normally space filled and padded, but we also consider zero 780 * bytes are fillers. If the field only contains padding, the string property 781 * will remain unchanged. 782 * 783 * @returns IPRT status code (ignorable). 784 * @param pThis The importer instance. 785 * @param pachField Pointer to the field. 786 * @param cchField The field length. 787 * @param enmStringProp The corresponding string property. 788 * 789 * @note Clobbers pThis->pbBuf! 790 */ 791 static int rtFsIsoImportAsciiStringField(PRTFSISOMKIMPORTER pThis, const char *pachField, size_t cchField, 792 RTFSISOMAKERSTRINGPROP enmStringProp) 793 { 794 /* 795 * Scan the field from the end as this way we know the result length if we find anything. 796 */ 797 size_t off = cchField; 798 while (off-- > 0) 799 { 800 char ch = pachField[off]; 801 if (ch == ' ' || ch == '\0') 802 { /* likely */ } 803 else 804 { 805 /* 806 * Make a copy of the string in abBuf, purge the encoding. 807 */ 808 off++; 809 char *pszCopy = (char *)pThis->abBuf; 810 memcpy(pszCopy, pachField, off); 811 pszCopy[off] = '\0'; 812 RTStrPurgeEncoding(pszCopy); 813 814 int rc = RTFsIsoMakerSetStringProp(pThis->hIsoMaker, enmStringProp, RTFSISOMAKER_NAMESPACE_ISO_9660, pszCopy); 815 if (RT_SUCCESS(rc)) 816 return VINF_SUCCESS; 817 return rtFsIsoImpError(pThis, rc, "RTFsIsoMakerSetStringProp failed setting field %d to '%s': %Rrc", 818 enmStringProp, pszCopy, rc); 819 } 820 } 821 return VINF_SUCCESS; 822 } 823 824 825 /** 723 826 * Validates a root directory record. 724 827 * … … 780 883 781 884 /** 782 * Processes a primary volume descriptor, importing all files described by its 783 * namespace. 885 * Processes a primary volume descriptor, importing all files and stuff. 784 886 * 785 887 * @returns IPRT status code (safe to ignore, see pThis->rc). … … 847 949 { 848 950 /* 849 * Process the directory tree. Start by establishing a root directory. 951 * Import stuff if present and not opted out. 952 */ 953 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_SYSTEM_ID)) 954 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achSystemId, sizeof(pVolDesc->achSystemId), 955 RTFSISOMAKERSTRINGPROP_SYSTEM_ID); 956 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_VOLUME_ID)) 957 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achVolumeId, sizeof(pVolDesc->achVolumeId), 958 RTFSISOMAKERSTRINGPROP_VOLUME_ID); 959 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_VOLUME_SET_ID)) 960 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achVolumeSetId, sizeof(pVolDesc->achVolumeSetId), 961 RTFSISOMAKERSTRINGPROP_VOLUME_SET_ID); 962 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_PUBLISHER_ID)) 963 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achPublisherId, sizeof(pVolDesc->achPublisherId), 964 RTFSISOMAKERSTRINGPROP_PUBLISHER_ID); 965 if (pThis->fFlags & RTFSISOMK_IMPORT_F_DATA_PREPARER_ID) 966 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achDataPreparerId, sizeof(pVolDesc->achDataPreparerId), 967 RTFSISOMAKERSTRINGPROP_DATA_PREPARER_ID); 968 if (pThis->fFlags & RTFSISOMK_IMPORT_F_APPLICATION_ID) 969 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achApplicationId, sizeof(pVolDesc->achApplicationId), 970 RTFSISOMAKERSTRINGPROP_APPLICATION_ID); 971 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_COPYRIGHT_FID)) 972 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achCopyrightFileId, sizeof(pVolDesc->achCopyrightFileId), 973 RTFSISOMAKERSTRINGPROP_COPYRIGHT_FILE_ID); 974 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_ABSTRACT_FID)) 975 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achAbstractFileId, sizeof(pVolDesc->achAbstractFileId), 976 RTFSISOMAKERSTRINGPROP_ABSTRACT_FILE_ID); 977 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_BIBLIO_FID)) 978 rtFsIsoImportAsciiStringField(pThis, pVolDesc->achBibliographicFileId, sizeof(pVolDesc->achBibliographicFileId), 979 RTFSISOMAKERSTRINGPROP_BIBLIOGRAPHIC_FILE_ID); 980 981 /* 982 * Process the directory tree. 850 983 */ 851 984 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_PRIMARY_ISO)) … … 858 991 859 992 993 /** 994 * Processes a secondary volume descriptor, if it is joliet we'll importing all 995 * the files and stuff. 996 * 997 * @returns IPRT status code (safe to ignore, see pThis->rc). 998 * @param pThis The importer instance. 999 * @param pVolDesc The primary volume descriptor. 1000 */ 860 1001 static int rtFsIsoImportProcessSupplementaryDesc(PRTFSISOMKIMPORTER pThis, PISO9660SUPVOLDESC pVolDesc) 861 1002 { … … 940 1081 "More than one Joliet volume descriptor is not supported"); 941 1082 pThis->fSeenJoliet = true; 1083 1084 /* 1085 * Import stuff if present and not opted out. 1086 */ 1087 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_SYSTEM_ID)) 1088 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achSystemId, sizeof(pVolDesc->achSystemId), 1089 RTFSISOMAKERSTRINGPROP_SYSTEM_ID); 1090 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_J_VOLUME_ID)) 1091 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achVolumeId, sizeof(pVolDesc->achVolumeId), 1092 RTFSISOMAKERSTRINGPROP_VOLUME_ID); 1093 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_J_VOLUME_SET_ID)) 1094 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achVolumeSetId, sizeof(pVolDesc->achVolumeSetId), 1095 RTFSISOMAKERSTRINGPROP_VOLUME_SET_ID); 1096 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_J_PUBLISHER_ID)) 1097 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achPublisherId, sizeof(pVolDesc->achPublisherId), 1098 RTFSISOMAKERSTRINGPROP_PUBLISHER_ID); 1099 if (pThis->fFlags & RTFSISOMK_IMPORT_F_J_DATA_PREPARER_ID) 1100 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achDataPreparerId, sizeof(pVolDesc->achDataPreparerId), 1101 RTFSISOMAKERSTRINGPROP_DATA_PREPARER_ID); 1102 if (pThis->fFlags & RTFSISOMK_IMPORT_F_J_APPLICATION_ID) 1103 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achApplicationId, sizeof(pVolDesc->achApplicationId), 1104 RTFSISOMAKERSTRINGPROP_APPLICATION_ID); 1105 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_J_COPYRIGHT_FID)) 1106 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achCopyrightFileId, sizeof(pVolDesc->achCopyrightFileId), 1107 RTFSISOMAKERSTRINGPROP_COPYRIGHT_FILE_ID); 1108 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_J_ABSTRACT_FID)) 1109 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achAbstractFileId, sizeof(pVolDesc->achAbstractFileId), 1110 RTFSISOMAKERSTRINGPROP_ABSTRACT_FILE_ID); 1111 if (!(pThis->fFlags & RTFSISOMK_IMPORT_F_NO_J_BIBLIO_FID)) 1112 rtFsIsoImportUtf16BigStringField(pThis, pVolDesc->achBibliographicFileId, sizeof(pVolDesc->achBibliographicFileId), 1113 RTFSISOMAKERSTRINGPROP_BIBLIOGRAPHIC_FILE_ID); 942 1114 943 1115 /*
Note:
See TracChangeset
for help on using the changeset viewer.