MCPcopy Create free account
hub / github.com/audacity/audacity / LoadFXB

Method LoadFXB

libraries/lib-vst/VSTWrapper.cpp:758–929  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

756}
757
758bool VSTWrapper::LoadFXB(const wxFileName & fn)
759{
760 bool ret = false;
761
762 // Try to open the file...will be closed automatically when method returns
763 wxFFile f(fn.GetFullPath(), wxT("rb"));
764 if (!f.IsOpened())
765 {
766 return false;
767 }
768
769 // Allocate memory for the contents
770 ArrayOf<unsigned char> data{ size_t(f.Length()) };
771 if (!data)
772 {
773 using namespace BasicUI;
774 ShowMessageBox(
775 XO("Unable to allocate memory when loading presets file."),
776 MessageBoxOptions{}
777 .Caption(XO("Error Loading VST Presets")));
778 return false;
779 }
780 unsigned char *bptr = data.get();
781
782 do
783 {
784 // Read in the whole file
785 ssize_t len = f.Read((void *) bptr, f.Length());
786 if (f.Error())
787 {
788 using namespace BasicUI;
789 ShowMessageBox(
790 XO("Unable to read presets file."),
791 MessageBoxOptions{}
792 .Caption(XO("Error Loading VST Presets")));
793 break;
794 }
795
796 // Most references to the data are via an "int" array
797 int32_t *iptr = (int32_t *) bptr;
798
799 // Verify that we have at least enough for the header
800 if (len < 156)
801 {
802 break;
803 }
804
805 // Verify that we probably have an FX file
806 if (wxINT32_SWAP_ON_LE(iptr[0]) != CCONST('C', 'c', 'n', 'K'))
807 {
808 break;
809 }
810
811 // Ignore the size...sometimes it's there, other times it's zero
812
813 // Get the version and verify
814 int version = wxINT32_SWAP_ON_LE(iptr[3]);
815 if (version != 1 && version != 2)

Callers

nothing calls this directly

Calls 6

ShowMessageBoxFunction · 0.85
IsOpenedMethod · 0.80
LengthMethod · 0.80
getMethod · 0.45
ReadMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected