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

Method exportWithDefaultPanel

Source/Native/CtrlrMac.cpp:19–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19const Result CtrlrMac::exportWithDefaultPanel(CtrlrPanel* panelToWrite, const bool isRestricted, const bool signPanel)
20{
21 if (panelToWrite == nullptr)
22 {
23 return (Result::fail("MAC native, panel pointer is invalid"));
24 }
25
26 File me = File::getSpecialLocation(File::currentApplicationFile);
27 File newMe;
28 MemoryBlock panelExportData,panelResourcesData;
29 String error;
30
31 FileChooser fc(CTRLR_NEW_INSTANCE_DIALOG_TITLE,
32 me.getParentDirectory().getChildFile(File::createLegalFileName(panelToWrite->getProperty(Ids::name))).withFileExtension(me.getFileExtension()),
33 me.getFileExtension(),
34 panelToWrite->getOwner().getProperty(Ids::ctrlrNativeFileDialogs));
35
36 if (fc.browseForDirectory())
37 {
38 newMe = fc.getResult().getChildFile (File::createLegalFileName (panelToWrite->getProperty(Ids::name).toString()+me.getFileExtension()));
39 if (!me.copyDirectoryTo (newMe))
40 {
41 return (Result::fail("MAC native, copyDirectoryTo from \""+me.getFullPathName()+"\" to \""+newMe.getFullPathName()+"\" failed"));
42 }
43 }
44 else
45 {
46 return (Result::fail("MAC native, browse for directory dialog failed"));
47 }
48
49 Result res = setBundleInfo(panelToWrite, newMe);
50 if (!res.wasOk())
51 {
52 return (res);
53 }
54
55 res = setBundleInfoCarbon(panelToWrite, newMe);
56 if (!res.wasOk())
57 {
58 return (res);
59 }
60
61 if ( (error = CtrlrPanel::exportPanel (panelToWrite, File(), newMe, &panelExportData, &panelResourcesData, isRestricted)) == "")
62 {
63 File panelFile = newMe.getChildFile("Contents/Resources/"+String(CTRLR_MAC_PANEL_FILE));
64 File resourcesFile = newMe.getChildFile("Contents/Resources/"+String(CTRLR_MAC_RESOURCES_FILE));
65
66 if (panelFile.create() && panelFile.hasWriteAccess())
67 {
68 if (!panelFile.replaceWithData(panelExportData.getData(), panelExportData.getSize()))
69 {
70 return (Result::fail("MAC native, failed to write panel file at: " + panelFile.getFullPathName()));
71 }
72 }
73
74 if (resourcesFile.create() && resourcesFile.hasWriteAccess())
75 {
76 if (!resourcesFile.replaceWithData(panelResourcesData.getData(), panelResourcesData.getSize()))

Callers 1

savePanelAsMethod · 0.45

Calls 15

FileClass · 0.85
browseForDirectoryMethod · 0.80
copyDirectoryToMethod · 0.80
wasOkMethod · 0.80
StringFunction · 0.50
withFileExtensionMethod · 0.45
getChildFileMethod · 0.45
getParentDirectoryMethod · 0.45
getPropertyMethod · 0.45
getFileExtensionMethod · 0.45
getOwnerMethod · 0.45
getResultMethod · 0.45

Tested by

no test coverage detected