MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / getDefaultResources

Method getDefaultResources

Source/Native/CtrlrLinux.cpp:162–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162const Result CtrlrLinux::getDefaultResources(MemoryBlock& dataToWrite)
163{
164#ifdef DEBUG_INSTANCE
165 File temp("/home/r.kubiak/devel/debug.bpanelz");
166 MemoryBlock data;
167 {
168 ScopedPointer <FileInputStream> fis (temp.createInputStream());
169 fis->readIntoMemoryBlock (data);
170 }
171
172 ValueTree t = ValueTree::readFromGZIPData(data.getData(), data.getSize());
173
174 if (t.isValid())
175 {
176 ValueTree r = t.getChildWithName (Ids::resourceExportList);
177 if (r.isValid())
178 {
179 MemoryOutputStream mos (dataToWrite, false);
180 {
181 GZIPCompressorOutputStream gzipOutputStream (&mos);
182 r.writeToStream(gzipOutputStream);
183 gzipOutputStream.flush();
184 }
185 return (Result::ok());
186 }
187 }
188 else
189 {
190 return (Result::fail("Linux Native: getDefaultResources got data but couldn't parse it as a compressed ValueTree"));
191 }
192#endif
193
194 libr_file *handle = libr_open (nullptr, LIBR_READ);
195
196 if (handle == nullptr)
197 {
198 return (Result::fail ("Linux native, libr_open failed to open binary [self]"));
199 }
200 else
201 {
202 _DBG("CtrlrLinux::getDefaultResources, libr_open succeeded for binary [self]");
203 }
204
205 size_t panelResourcesDataSize;
206 char *panelResourcesData = (char *)libr_malloc (handle, (char *)CTRLR_INTERNAL_RESOURCES_SECTION, &panelResourcesDataSize);
207
208 if (panelResourcesData == nullptr)
209 {
210 libr_close (handle);
211 return (Result::fail ("Linux native, libr_malloc didn't find embedded panel resources in binary"));
212 }
213 else
214 {
215 _DBG("CtrlrLinux::getDefaultResources, libr_malloc returned data for panel size ["+STR((int32)panelResourcesDataSize)+"]");
216 }
217
218 dataToWrite.append (panelResourcesData, panelResourcesDataSize);
219

Callers

nothing calls this directly

Calls 11

libr_openFunction · 0.85
libr_mallocFunction · 0.85
libr_closeFunction · 0.85
readIntoMemoryBlockMethod · 0.80
createInputStreamMethod · 0.45
getDataMethod · 0.45
getSizeMethod · 0.45
isValidMethod · 0.45
writeToStreamMethod · 0.45
flushMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected