MCPcopy Create free account
hub / github.com/christophhart/HISE / encodeExpansion

Method encodeExpansion

hi_scripting/scripting/api/ScriptExpansion.cpp:1679–1725  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1677}
1678
1679Result ScriptEncryptedExpansion::encodeExpansion()
1680{
1681 if (getExpansionType() == Expansion::FileBased)
1682 {
1683 auto& handler = getMainController()->getExpansionHandler();
1684
1685 if (handler.getEncryptionKey().isEmpty())
1686 {
1687 return Result::fail("You have to set an encryption key using `ExpansionHandler.setEncryptionKey()` before using this method.");
1688 }
1689
1690 String s;
1691 s << "Do you want to encode the expansion " << getProperty(ExpansionIds::Name) << "? \n> The encryption key is `" << handler.getEncryptionKey() << "`.";
1692
1693 if (true)//PresetHandler::showYesNoWindow("Encode expansion", s))
1694 {
1695 auto hxiFile = Expansion::Helpers::getExpansionInfoFile(getRootFolder(), Expansion::Intermediate);
1696
1697 ValueTree hxiData("Expansion");
1698
1699 auto metadata = data->v.createCopy();
1700 metadata.setProperty(ExpansionIds::Hash, handler.getEncryptionKey().hashCode64(), nullptr);
1701
1702 hxiData.addChild(metadata, -1, nullptr);
1703 encodePoolAndUserPresets(hxiData, false);
1704
1705#if HISE_USE_XML_FOR_HXI
1706 ScopedPointer<XmlElement> xml = hxiData.createXml();
1707 hxiFile.replaceWithText(xml->createDocument(""));
1708#else
1709 hxiFile.deleteFile();
1710 FileOutputStream fos(hxiFile);
1711 hxiData.writeToStream(fos);
1712 fos.flush();
1713#endif
1714 auto h = &getMainController()->getExpansionHandler();
1715
1716 h->forceReinitialisation();
1717 }
1718 }
1719 else
1720 {
1721 return Result::fail("The expansion " + getProperty(ExpansionIds::Name) + " is already encoded");
1722 }
1723
1724 return Result::ok();
1725}
1726
1727juce::Array<hise::FileHandlerBase::SubDirectories> ScriptEncryptedExpansion::getSubDirectoryIds() const
1728{

Callers 1

runMethod · 0.45

Calls 15

replaceWithTextMethod · 0.80
createDocumentMethod · 0.80
forceReinitialisationMethod · 0.80
toBase64EncodingMethod · 0.80
loadFileAsDataMethod · 0.80
getNextProcessorMethod · 0.80
collectScriptMethod · 0.80
StringClass · 0.50
callRecursiveFunction · 0.50
isEmptyMethod · 0.45

Tested by

no test coverage detected