void XmlParser::readConfig() { XmlDocument* xmlConfigDoc = new XmlDocument(File(File::getCurrentWorkingDirectory().getChildFile(configFile))); XmlElement* xmlConfigElem = xmlConfigDoc->getDocumentElement(); if (xmlConfigElem != NULL) { XmlElement* pictures = xmlConfigElem->getChildByName(T("pictures")); if (pictures != NULL) { if (pictures->hasAttribute(T("path"))) { m_picturePath = pictures->getStringAttribute(T("path")); } else { LOG_ERROR(T("Element \"pictures\" is incomplete")); } } else { LOG_ERROR(T("Element \"pictures\" not found")); } delete xmlConfigElem; } else { LOG_ERROR((T("XML load failed: %ls"), (const juce_wchar*)xmlConfigDoc->getLastParseError())); } delete xmlConfigDoc; }
//============================================================================== void VstPluginWindow::loadPreset () { File lastPresetDirectory = File (plugin->getValue (PROP_PLUGPRESETDIR, String::empty)); if (! lastPresetDirectory.exists()) lastPresetDirectory = Config::getInstance ()->lastPresetDirectory; FileChooser myChooser (T("Load a preset file..."), lastPresetDirectory, JOST_PRESET_WILDCARD, JOST_USE_NATIVE_FILE_CHOOSER); if (myChooser.browseForFileToOpen()) { File fileToLoad = myChooser.getResult(); if (fileToLoad.existsAsFile()) { XmlDocument xmlDoc (fileToLoad.loadFileAsString ()); XmlElement* xml = xmlDoc.getDocumentElement(); if (xml == 0 || ! xml->hasTagName (JOST_PRESET_PRESETTAG)) { String errString = xmlDoc.getLastParseError(); printf ("Error parsing preset: %s \n", (const char*) errString); } else { plugin->loadPresetFromXml (xml); updateParameters (); repaint (); Config::getInstance()->addRecentPreset (fileToLoad); plugin->setValue (PROP_PLUGPRESETDIR, fileToLoad.getParentDirectory().getFullPathName()); } } } }