Changeset 33462 in vbox for trunk/src/VBox/Installer/win
- Timestamp:
- Oct 26, 2010 12:15:19 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Installer/win/Stub/VBoxStub.cpp
r32375 r33462 121 121 do 122 122 { 123 Assert BreakStmt(pszDataName, "Resource name is empty!");123 AssertMsgBreak(pszDataName, ("Resource name is empty!\n")); 124 124 125 125 /* Find our resource. */ 126 126 HRSRC hRsrc = FindResourceEx(hInst, RT_RCDATA, pszDataName, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)); 127 Assert BreakStmt(hRsrc, "Could not find resource!");127 AssertMsgBreak(hRsrc, ("Could not find resource!\n")); 128 128 129 129 /* Get resource size. */ 130 130 *pdwSize = SizeofResource(hInst, hRsrc); 131 Assert BreakStmt(*pdwSize > 0, "Size of resource is invalid!");131 AssertMsgBreak((*pdwSize > 0, "Size of resource is invalid!\n")); 132 132 133 133 /* Get pointer to resource. */ 134 134 HGLOBAL hData = LoadResource(hInst, hRsrc); 135 Assert BreakStmt(hData, "Could not load resource!");135 AssertMsgBreak(hData, ("Could not load resource!\n")); 136 136 137 137 /* Lock resource. */ 138 138 *ppvResource = LockResource(hData); 139 AssertBreakStmt(*ppvResource, "Could not lock resource!"); 139 AssertMsgBreak(*ppvResource, ("Could not lock resource!\n")); 140 return VINF_SUCCESS; 141 140 142 } while (0); 141 return *ppvResource ? VINF_SUCCESS : VERR_IO_GEN_FAILURE; 143 144 return VERR_IO_GEN_FAILURE; 142 145 } 143 146 … … 157 160 char **ppszTempFile) 158 161 { 159 return RTStrAPrintf(ppszTempFile, "%s\\%s", pszTempPath, pszTargetFileName); 162 if (RTStrAPrintf(ppszTempFile, "%s\\%s", pszTempPath, pszTargetFileName) >= 0) 163 return VINF_SUCCESS; 164 return VERR_NO_STR_MEMORY; 160 165 } 161 166 … … 179 184 do 180 185 { 181 Assert BreakStmt(pszResourceName, "Resource pointer invalid!");182 Assert BreakStmt(pszTempFile, "Temp file pointer invalid!");186 AssertMsgBreak(pszResourceName, ("Resource pointer invalid!\n")); 187 AssertMsgBreak(pszTempFile, ("Temp file pointer invalid!")); 183 188 184 189 /* Read the data of the built-in resource. */ … … 186 191 DWORD dwDataSize = 0; 187 192 rc = ReadData(NULL, pszResourceName, &pvData, &dwDataSize); 188 Assert RCBreakStmt(rc, "Could not read resource data!");193 AssertMsgRCBreak(rc, ("Could not read resource data!\n")); 189 194 190 195 /* Create new (and replace an old) file. */ … … 194 199 | RTFILE_O_DENY_NOT_DELETE 195 200 | RTFILE_O_DENY_WRITE); 196 Assert RCBreakStmt(rc, "Could not open file for writing!");201 AssertMsgRCBreak(rc, ("Could not open file for writing!\n")); 197 202 bCreatedFile = TRUE; 198 203 … … 200 205 size_t cbWritten = 0; 201 206 rc = RTFileWrite(fh, pvData, dwDataSize, &cbWritten); 202 Assert RCBreakStmt(rc, "Could not open file for writing!");203 Assert BreakStmt((dwDataSize == cbWritten), "File was not extracted completely! Disk full?");207 AssertMsgRCBreak(rc, ("Could not open file for writing!\n")); 208 AssertMsgBreak(dwDataSize == cbWritten, ("File was not extracted completely! Disk full?\n")); 204 209 205 210 } while (0); … … 346 351 BOOL fEnableLogging = FALSE; 347 352 BOOL bExit = FALSE; 348 char *pszTempPathFull = NULL; /* Contains the final extraction directory later. */349 353 350 354 /* Temp variables for arguments. */ 351 char szExtractPath[ 1024] = {0};352 char szMSIArgs[ 1024] = {0};355 char szExtractPath[RTPATH_MAX] = {0}; 356 char szMSIArgs[RTPATH_MAX] = {0}; 353 357 354 358 /* Process arguments. */ … … 382 386 { 383 387 vrc = ::StringCbCat(szExtractPath, sizeof(szExtractPath), pArgV[i+1]); 384 pszTempPathFull = szExtractPath; /* Point to the new path. */385 388 i++; /* Avoid the specify path from being parsed */ 386 389 } … … 445 448 HRESULT hr = S_OK; 446 449 447 do 450 do /* break loop */ 448 451 { 449 452 /* Get/create our temp path (only if not already set). */ 450 if (pszTempPathFull == NULL) 451 { 452 char szTemp[_MAX_PATH] = {0}; 453 vrc = RTPathTemp(szTemp, sizeof(szTemp)); 454 AssertRCBreakStmt(vrc, "Could not retrieve temp directory!"); 455 vrc = RTStrAPrintf(&pszTempPathFull, "%s\\VirtualBox", szTemp); 456 AssertRCBreakStmt(vrc, "Could not construct temp directory!"); 457 } 458 459 if (!RTDirExists(pszTempPathFull)) 460 { 461 vrc = RTDirCreate(pszTempPathFull, 0700); 462 AssertRCBreakStmt(vrc, "Could not create temp directory!"); 453 if (szExtractPath[0] == '\0') 454 { 455 vrc = RTPathTemp(szExtractPath, sizeof(szExtractPath)); 456 AssertMsgRCBreak(vrc, ("Could not retrieve temp directory!\n")); 457 458 vrc = RTPathAppend(szExtractPath, sizeof(szExtractPath), "VirtualBox"); 459 AssertMsgRCBreak(vrc, ("Could not construct temp directory!\n")); 460 } 461 if (!RTDirExists(szExtractPath)) 462 { 463 vrc = RTDirCreate(szExtractPath, 0700); 464 AssertMsgRCBreak(vrc, ("Could not create temp directory!\n")); 463 465 } 464 466 … … 472 474 DWORD cbHeader = 0; 473 475 vrc = ReadData(NULL, "MANIFEST", (LPVOID*)&pHeader, &cbHeader); 474 Assert RCBreakStmt(vrc, "Manifest not found!");476 AssertMsgRCBreak(vrc, ("Manifest not found!\n")); 475 477 476 478 /* Extract files. */ … … 483 485 hr = ::StringCchPrintf(szHeaderName, _MAX_PATH, "HDR_%02d", k); 484 486 vrc = ReadData(NULL, szHeaderName, (LPVOID*)&pPackage, &cbPackage); 485 Assert RCBreakStmt(vrc, "Header not found!"); /** @todo include header name, how? */487 AssertMsgRCBreak(vrc, ("Header not found!\n")); /** @todo include header name, how? */ 486 488 487 489 if (PackageIsNeeded(pPackage) || fExtractOnly) 488 490 { 489 491 char *pszTempFile = NULL; 490 vrc = GetTempFileAlloc( pszTempPathFull, pPackage->szFileName, &pszTempFile);491 Assert RCBreakStmt(vrc, "Could not create name for temporary extracted file!");492 vrc = GetTempFileAlloc(szExtractPath, pPackage->szFileName, &pszTempFile); 493 AssertMsgRCBreak(vrc, ("Could not create name for temporary extracted file!\n")); 492 494 vrc = Extract(pPackage, pszTempFile); 493 Assert RCBreakStmt(vrc, "Could not extract file!");495 AssertMsgRCBreak(vrc, ("Could not extract file!\n")); 494 496 RTStrFree(pszTempFile); 495 497 } … … 502 504 * file(s) can use it. 503 505 */ 504 char *pszPathCustomDir; 505 vrc = RTStrAPrintf(&pszPathCustomDir, "%s\\.custom", szPathExe); 506 if (RT_SUCCESS(vrc) && RTDirExists(pszPathCustomDir)) 506 char *pszPathCustomDir = RTPathJoinA(szPathExe, ".custom"); 507 if (pszPathCustomDir && RTDirExists(pszPathCustomDir)) 507 508 { 508 vrc = CopyDir( pszTempPathFull, pszPathCustomDir);509 vrc = CopyDir(szExtractPath, pszPathCustomDir); 509 510 if (RT_FAILURE(vrc)) /* Don't fail if it's missing! */ 510 511 vrc = VINF_SUCCESS; … … 522 523 hr = StringCchPrintf(szHeaderName, _MAX_PATH, "HDR_%02d", k); 523 524 vrc = ReadData(NULL, szHeaderName, (LPVOID*)&pPackage, &cbPackage); 524 Assert RCBreakStmt(vrc, "Package not found!");525 AssertMsgRCBreak(vrc, ("Package not found!\n")); 525 526 526 527 if (PackageIsNeeded(pPackage)) … … 528 529 char *pszTempFile = NULL; 529 530 530 vrc = GetTempFileAlloc( pszTempPathFull, pPackage->szFileName, &pszTempFile);531 Assert RCBreakStmt(vrc, "Could not create name for temporary action file!");531 vrc = GetTempFileAlloc(szExtractPath, pPackage->szFileName, &pszTempFile); 532 AssertMsgRCBreak(vrc, ("Could not create name for temporary action file!\n")); 532 533 533 534 /* Handle MSI files. */ … … 539 540 : INSTALLUILEVEL_FULL, 540 541 NULL); 541 Assert BreakStmt((UILevel != INSTALLUILEVEL_NOCHANGE), "Could not set installer UI level!");542 AssertMsgBreak(UILevel != INSTALLUILEVEL_NOCHANGE, ("Could not set installer UI level!\n")); 542 543 543 544 /* Enable logging? */ 544 545 if (fEnableLogging) 545 546 { 546 char *pszLog = NULL; 547 vrc = RTStrAPrintf(&pszLog, "%s\\VBoxInstallLog.txt", pszTempPathFull); 548 char *pszMSILog = NULL; 549 AssertRCBreakStmt(vrc, "Could not convert MSI log string to current codepage!"); 547 char *pszLog = RTPathJoinA(szExtractPath, "VBoxInstallLog.txt"); 548 AssertMsgRCBreak(vrc, ("Could not convert MSI log string to current codepage!\n")); 550 549 UINT uLogLevel = MsiEnableLog(INSTALLLOGMODE_VERBOSE, 551 550 pszLog, INSTALLLOGATTRIBUTES_FLUSHEACHLINE); 552 551 RTStrFree(pszLog); 553 Assert BreakStmt((uLogLevel == ERROR_SUCCESS), "Could not set installer logging level!");552 AssertMsgBreak(uLogLevel == ERROR_SUCCESS, ("Could not set installer logging level!\n")); 554 553 } 555 554 … … 596 595 for (int i=0; i<5; i++) 597 596 { 598 vrc = RTDirRemoveRecursive( pszTempPathFull, 0 /*fFlags*/);597 vrc = RTDirRemoveRecursive(szExtractPath, 0 /*fFlags*/); 599 598 if (RT_SUCCESS(vrc)) 600 599 break; … … 607 606 if (RT_SUCCESS(vrc)) 608 607 { 609 if ( fExtractOnly 610 && !fSilent 611 ) 612 { 613 ShowInfo("Files were extracted to: %s", pszTempPathFull); 608 if ( fExtractOnly 609 && !fSilent) 610 { 611 ShowInfo("Files were extracted to: %s", szExtractPath); 614 612 } 615 613 616 614 /** @todo Add more post installation stuff here if required. */ 617 615 } 618 619 if (strlen(szExtractPath) <= 0)620 RTStrFree(pszTempPathFull);621 616 622 617 /* Release instance mutex. */
Note:
See TracChangeset
for help on using the changeset viewer.