本文整理汇总了C++中Transaction::TransactionDirectory方法的典型用法代码示例。如果您正苦于以下问题:C++ Transaction::TransactionDirectory方法的具体用法?C++ Transaction::TransactionDirectory怎么用?C++ Transaction::TransactionDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transaction
的用法示例。
在下文中一共展示了Transaction::TransactionDirectory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
BPackageManager::_CommitPackageChanges(Transaction& transaction)
{
InstalledRepository& installationRepository = transaction.Repository();
fUserInteractionHandler->ProgressStartApplyingChanges(
installationRepository);
// commit the transaction
BCommitTransactionResult transactionResult;
status_t error = fInstallationInterface->CommitTransaction(transaction,
transactionResult);
if (error != B_OK)
DIE(error, "failed to commit transaction");
if (transactionResult.Error() != B_TRANSACTION_OK)
DIE(transactionResult);
fUserInteractionHandler->ProgressTransactionCommitted(
installationRepository, transactionResult);
BEntry transactionDirectoryEntry;
if ((error = transaction.TransactionDirectory()
.GetEntry(&transactionDirectoryEntry)) != B_OK
|| (error = transactionDirectoryEntry.Remove()) != B_OK) {
fUserInteractionHandler->Warn(error,
"failed to remove transaction directory");
}
fUserInteractionHandler->ProgressApplyingChangesDone(
installationRepository);
}
示例2:
status_t
PackageManager::PrepareTransaction(Transaction& transaction)
{
Volume* volume = fRoot->GetVolume(transaction.Repository().Location());
if (volume == NULL)
return B_BAD_VALUE;
return volume->CreateTransaction(transaction.Repository().Location(),
transaction.ActivationTransaction(),
transaction.TransactionDirectory());
}
示例3: bad_alloc
void
BPackageManager::_PreparePackageChanges(
InstalledRepository& installationRepository)
{
if (!installationRepository.HasChanges())
return;
PackageList& packagesToActivate
= installationRepository.PackagesToActivate();
PackageList& packagesToDeactivate
= installationRepository.PackagesToDeactivate();
// create the transaction
Transaction* transaction = new Transaction(installationRepository);
if (!fTransactions.AddItem(transaction)) {
delete transaction;
throw std::bad_alloc();
}
status_t error = fInstallationInterface->PrepareTransaction(*transaction);
if (error != B_OK)
DIE(error, "failed to create transaction");
// download the new packages and prepare the transaction
for (int32 i = 0; BSolverPackage* package = packagesToActivate.ItemAt(i);
i++) {
// get package URL and target entry
BString fileName(package->Info().FileName());
if (fileName.IsEmpty())
throw std::bad_alloc();
BEntry entry;
error = entry.SetTo(&transaction->TransactionDirectory(), fileName);
if (error != B_OK)
DIE(error, "failed to create package entry");
RemoteRepository* remoteRepository
= dynamic_cast<RemoteRepository*>(package->Repository());
if (remoteRepository != NULL) {
// download the package
BString url = remoteRepository->Config().PackagesURL();
url << '/' << fileName;
status_t error = DownloadPackage(url, entry,
package->Info().Checksum());
if (error != B_OK)
DIE(error, "failed to download package");
} else if (package->Repository() != &installationRepository) {
// clone the existing package
LocalRepository* localRepository
= dynamic_cast<LocalRepository*>(package->Repository());
if (localRepository == NULL) {
DIE("internal error: repository %s is not a local repository",
package->Repository()->Name().String());
}
_ClonePackageFile(localRepository, package, entry);
}
// add package to transaction
if (!transaction->ActivationTransaction().AddPackageToActivate(
fileName)) {
throw std::bad_alloc();
}
}
for (int32 i = 0; BSolverPackage* package = packagesToDeactivate.ItemAt(i);
i++) {
// add package to transaction
if (!transaction->ActivationTransaction().AddPackageToDeactivate(
package->Info().FileName())) {
throw std::bad_alloc();
}
}
}