const Result CtrlrWindows::getDefaultResources(MemoryBlock& dataToWrite) { #ifdef DEBUG_INSTANCE File temp("c:\\devel\\debug_small.bpanelz"); MemoryBlock data; { ScopedPointer <FileInputStream> fis (temp.createInputStream()); fis->readIntoMemoryBlock (data); } ValueTree t = ValueTree::readFromGZIPData(data.getData(), data.getSize()); if (t.isValid()) { ValueTree r = t.getChildWithName (Ids::resourceExportList); if (r.isValid()) { MemoryOutputStream mos (dataToWrite, false); { GZIPCompressorOutputStream gzipOutputStream (&mos); r.writeToStream(gzipOutputStream); gzipOutputStream.flush(); } return (Result::ok()); } } else { return (Result::fail("Windows Native: getDefaultResources got data but couldn't parse it as a compressed ValueTree")); } #endif return (readResource (nullptr, MAKEINTRESOURCE(CTRLR_INTERNAL_RESOURCES_RESID), RT_RCDATA, dataToWrite)); }
void jojo_write (t_jojo *x, const File& aFile) { MemoryOutputStream myText; GZIPCompressorOutputStream zipper (&myText); zipper << "Stately, plump Buck Mulligan came from the stairhead, " << newLine << "bearing a bowl of lather on which a mirror and a razor lay crossed." << newLine; zipper.flush(); aFile.replaceWithData (myText.getData(), myText.getDataSize()); }
void work (const URIs& uris, const lvtk::Atom& atom) override { const File file (String::fromUTF8 (path.c_str())); if (ScopedXml xml = XmlDocument::parse (file)) { if (ScopedPointer<SamplerSynth> ss = SamplerSynth::create ()) { if (ss->loadValueTreeXml (*xml)) { #define compressd_json 1 #if compressd_json var json; const bool haveJson = ss->getNestedVariant (json); #endif uint8_t buf [2048]; getForge()->set_buffer (buf, 2048); ObjectRef synth (*getForge(), uris.ksp1_SamplerSynth, ss.release()); respond (synth); if (haveJson) { MemoryBlock block (0, false); MemoryOutputStream stream (block, false); GZIPCompressorOutputStream compressed (&stream, 9); JSON::writeToStream (compressed, json, true); compressed.flush(); if (block.getSize() > 0) { Forge& f = *getForge(); int bufSize = nextPowerOfTwo ((int) block.getSize()); bufSize = nextPowerOfTwo (bufSize); MemoryBlock buffer ((size_t) bufSize, false); f.set_buffer ((uint8*) buffer.getData(), buffer.getSize()); lvtk::Atom gzipped (f.write_atom (block.getSize(), 100100)); f.write_raw (block.getData(), block.getSize()); DBG ("SIZE: " << (int)block.getSize()); respond (gzipped); } } } } } }