| 261 | } |
| 262 | |
| 263 | const Result CtrlrMac::setBundleInfoCarbon (CtrlrPanel *sourceInfo, const File &bundle) |
| 264 | { |
| 265 | #ifdef JUCE_DEBUG |
| 266 | File rsrcFile = bundle.getChildFile ("Contents/Resources/Ctrlr-Debug.rsrc"); |
| 267 | #else |
| 268 | File rsrcFile = bundle.getChildFile ("Contents/Resources/Ctrlr.rsrc"); |
| 269 | #endif |
| 270 | |
| 271 | const String instanceName = sourceInfo->getPanelInstanceName(); |
| 272 | const String instanceManufacturer = sourceInfo->getPanelInstanceManufacturer(); |
| 273 | const String instanceID = sourceInfo->getPanelInstanceID(); |
| 274 | const String instanceManufacturerID = sourceInfo->getPanelInstanceManufacturerID(); |
| 275 | |
| 276 | String nameToWrite = String (instanceManufacturer + ": " + instanceName).substring (0,127); |
| 277 | const String idToWrite = instanceID+instanceManufacturerID; |
| 278 | const int nameLength = nameToWrite.length(); |
| 279 | String zipFileEntryName = "result_"+_STR(nameLength)+".rsrc"; |
| 280 | |
| 281 | if (idToWrite.length() != 8) |
| 282 | { |
| 283 | return (Result::fail("MAC native, id to write for Carbon information is not 8 characters \""+idToWrite+"\"")); |
| 284 | } |
| 285 | |
| 286 | MemoryInputStream zipStream (BinaryData::RSRC_zip, BinaryData::RSRC_zipSize, false); |
| 287 | ZipFile zipFile (zipStream); |
| 288 | const ZipFile::ZipEntry *zipFileEntry = zipFile.getEntry(zipFileEntryName); |
| 289 | |
| 290 | _DBG("INSTANCE: trying to use zip file entry with name: "+zipFileEntryName); |
| 291 | |
| 292 | if (zipFileEntry) |
| 293 | { |
| 294 | _DBG("\tgot it"); |
| 295 | ScopedPointer <InputStream> is (zipFile.createStreamForEntry(*zipFileEntry)); |
| 296 | |
| 297 | if (is) |
| 298 | { |
| 299 | MemoryBlock data; |
| 300 | is->readIntoMemoryBlock (data, is->getTotalLength()); |
| 301 | |
| 302 | if (data.getSize() > 0) |
| 303 | { |
| 304 | /* name data start 261 */ |
| 305 | data.removeSection (261, 3 + nameLength); |
| 306 | |
| 307 | /* id data startx 579 - after the name is removed*/ |
| 308 | data.removeSection (299, 8); |
| 309 | data.insert (idToWrite.toUTF8().getAddress(), 8, 299); |
| 310 | |
| 311 | data.insert (nameToWrite.toUTF8().getAddress(), 3+nameLength, 261); |
| 312 | |
| 313 | if (rsrcFile.hasWriteAccess()) |
| 314 | { |
| 315 | if (rsrcFile.replaceWithData (data.getData(), data.getSize())) |
| 316 | { |
| 317 | return (Result::ok()); |
| 318 | } |
| 319 | else |
| 320 | { |
nothing calls this directly
no test coverage detected