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

Method exportWithDefaultPanel

Source/Native/CtrlrLinux.cpp:28–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28const Result CtrlrLinux::exportWithDefaultPanel(CtrlrPanel *panelToWrite, const bool isRestricted, const bool signPanel)
29{
30 _DBG("CtrlrLinux::exportWithDefaultPanel");
31
32 if (panelToWrite == nullptr)
33 {
34 return (Result::fail("Linux native, panel pointer is invalid"));
35 }
36
37 File me = File::getSpecialLocation(File::currentApplicationFile);
38 File newMe;
39 libr_file *outputHandle;
40
41 MemoryBlock panelExportData;
42 MemoryBlock panelResourcesData;
43 String error;
44
45 FileChooser fc(CTRLR_NEW_INSTANCE_DIALOG_TITLE,
46 me.getParentDirectory().getChildFile(File::createLegalFileName(panelToWrite->getProperty(Ids::name))).withFileExtension(me.getFileExtension()),
47 me.getFileExtension(),
48 panelToWrite->getOwner().getProperty(Ids::ctrlrNativeFileDialogs));
49
50 if (fc.browseForFileToSave (true))
51 {
52 _DBG("CtrlrLinux::exportWithDefaultPanel chosen file: "+fc.getResult().getFullPathName());
53
54 newMe = fc.getResult();
55 if (!me.copyFileTo (newMe))
56 {
57 return (Result::fail("Linux native, copyFileTo from \""+me.getFullPathName()+"\" to \""+newMe.getFullPathName()+"\" failed"));
58 }
59 }
60 else
61 {
62 return (Result::fail("Linux native, browse for save file dialog failed"));
63 }
64
65 outputHandle = libr_open (newMe.getFullPathName().toUTF8().getAddress(), LIBR_READ_WRITE);
66
67 if (outputHandle == nullptr)
68 {
69 return (Result::fail ("Linux native, can't open output binary ["+newMe.getFullPathName()+"] using libr_open()"));
70 }
71 else
72 {
73 _DBG("CtrlrLinux::exportWithDefaultPanel libr_open success on: "+newMe.getFullPathName());
74 }
75
76 if ( (error = CtrlrPanel::exportPanel (panelToWrite, File(), newMe, &panelExportData, &panelResourcesData, isRestricted)) == "")
77 {
78 if (!libr_write (outputHandle, (char *)CTRLR_INTERNAL_PANEL_SECTION, (char *)panelExportData.getData(), panelExportData.getSize(), LIBR_UNCOMPRESSED, LIBR_OVERWRITE))
79 {
80 return (Result::fail ("Linux native, failed to write panel data to binary ["+newMe.getFullPathName()+"], size ["+STR((int32)panelExportData.getSize())+"]"));
81 libr_close (outputHandle);
82 }
83
84 _DBG ("CtrlrLinux::exportWithDefaultPanel wrote panel data to binary size ["+STR((int32)panelExportData.getSize())+"]");
85

Callers

nothing calls this directly

Calls 15

libr_openFunction · 0.85
FileClass · 0.85
libr_writeFunction · 0.85
libr_closeFunction · 0.85
browseForFileToSaveMethod · 0.80
copyFileToMethod · 0.80
moveFileToMethod · 0.80
withFileExtensionMethod · 0.45
getChildFileMethod · 0.45
getParentDirectoryMethod · 0.45
getPropertyMethod · 0.45
getFileExtensionMethod · 0.45

Tested by

no test coverage detected