+ if (windows_vst_discover_from_path (path) == 0) {
+ windows_vst_path += ':';
+ windows_vst_path += path;
+ return 0;
+ }
+ return -1;
+}
+
+static bool windows_vst_filter (const string& str, void *arg)
+{
+ /* Not a dotfile, has a prefix before a period, suffix is "dll" */
+
+ return str[0] != '.' && (str.length() > 4 && str.find (".dll") == (str.length() - 4));
+}
+
+int
+PluginManager::windows_vst_discover_from_path (string path)
+{
+ PathScanner scanner;
+ vector<string *> *plugin_objects;
+ vector<string *>::iterator x;
+ int ret = 0;
+
+ DEBUG_TRACE (DEBUG::PluginManager, string_compose ("detecting Windows VST plugins along %1\n", path));
+
+ plugin_objects = scanner (windows_vst_path, windows_vst_filter, 0, false, true);
+
+ if (plugin_objects) {
+ for (x = plugin_objects->begin(); x != plugin_objects->end (); ++x) {
+ windows_vst_discover (**x);
+ }
+
+ vector_delete (plugin_objects);
+ }
+
+ return ret;
+}
+
+int
+PluginManager::windows_vst_discover (string path)
+{
+ VSTInfo* finfo;
+ char buf[32];
+
+ if ((finfo = fst_get_info (const_cast<char *> (path.c_str()))) == 0) {
+ warning << "Cannot get Windows VST information from " << path << endmsg;
+ return -1;
+ }
+
+ if (!finfo->canProcessReplacing) {
+ warning << string_compose (_("VST plugin %1 does not support processReplacing, and so cannot be used in %2 at this time"),
+ finfo->name, PROGRAM_NAME)
+ << endl;
+ }
+
+ PluginInfoPtr info (new WindowsVSTPluginInfo);
+
+ /* what a joke freeware VST is */
+
+ if (!strcasecmp ("The Unnamed plugin", finfo->name)) {
+ info->name = PBD::basename_nosuffix (path);
+ } else {
+ info->name = finfo->name;
+ }
+
+
+ snprintf (buf, sizeof (buf), "%d", finfo->UniqueID);
+ info->unique_id = buf;
+ info->category = "VST";
+ info->path = path;
+ info->creator = finfo->creator;
+ info->index = 0;
+ info->n_inputs.set_audio (finfo->numInputs);
+ info->n_outputs.set_audio (finfo->numOutputs);
+ info->n_inputs.set_midi (finfo->wantMidi ? 1 : 0);
+ info->type = ARDOUR::Windows_VST;
+
+ _windows_vst_plugin_info->push_back (info);
+ fst_free_info (finfo);
+