fix typo in prev. commit
[ardour.git] / libs / ardour / plugin_manager.cc
index 4eb67db48dd044450e15d98b5b5a52d3b2159f01..9ffab34a18afbef7e8f167f351b1057543667ce0 100644 (file)
@@ -26,7 +26,9 @@
 #include <sys/types.h>
 #include <cstdio>
 #include <cstdlib>
-#include <fstream>
+
+#include <glib.h>
+#include "pbd/gstdio_compat.h"
 
 #ifdef HAVE_LRDF
 #include <lrdf.h>
@@ -46,7 +48,6 @@
 #include <cstring>
 #endif //LXVST_SUPPORT
 
-#include <glib/gstdio.h>
 #include <glibmm/miscutils.h>
 #include <glibmm/pattern.h>
 #include <glibmm/fileutils.h>
@@ -123,7 +124,7 @@ PluginManager::PluginManager ()
 
 #ifdef PLATFORM_WINDOWS
        // on windows the .exe needs to be in the same folder with libardour.dll
-       vstsp += Glib::build_filename(g_win32_get_package_installation_directory_of_module (0), "bin");
+       vstsp += Glib::build_filename(windows_package_directory_path(), "bin");
 #else
        // on Unices additional internal-use binaries are deployed to $libdir
        vstsp += ARDOUR::ardour_dll_directory();
@@ -266,10 +267,11 @@ PluginManager::refresh (bool cache_only)
                if (!cache_only) {
                        string fn = Glib::build_filename (ARDOUR::user_cache_directory(), VST_BLACKLIST);
                        if (Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) {
-                               std::string bl;
-                               std::ifstream ifs (fn.c_str ());
-                               bl.assign ((std::istreambuf_iterator<char> (ifs)), (std::istreambuf_iterator<char> ()));
-                               PBD::info << _("VST Blacklist:") << "\n" << bl << "-----" << endmsg;
+                               gchar *bl = NULL;
+                               if (g_file_get_contents(fn.c_str (), &bl, NULL, NULL)) {
+                                       PBD::info << _("VST Blacklist:") << "\n" << bl << "-----" << endmsg;
+                                       g_free (bl);
+                               }
                        }
                }
 #endif
@@ -1005,14 +1007,8 @@ PluginManager::get_status (const PluginInfoPtr& pi)
 void
 PluginManager::save_statuses ()
 {
-       ofstream ofs;
        std::string path = Glib::build_filename (user_config_directory(), "plugin_statuses");
-
-       ofs.open (path.c_str(), ios_base::openmode (ios::out|ios::trunc));
-
-       if (!ofs) {
-               return;
-       }
+       stringstream ofs;
 
        for (PluginStatusList::iterator i = statuses.begin(); i != statuses.end(); ++i) {
                switch ((*i).type) {
@@ -1051,19 +1047,19 @@ PluginManager::save_statuses ()
                ofs << (*i).unique_id;;
                ofs << endl;
        }
-
-       ofs.close ();
+       g_file_set_contents (path.c_str(), ofs.str().c_str(), -1, NULL);
 }
 
 void
 PluginManager::load_statuses ()
 {
        std::string path = Glib::build_filename (user_config_directory(), "plugin_statuses");
-       ifstream ifs (path.c_str());
-
-       if (!ifs) {
+       gchar *fbuf = NULL;
+       if (!g_file_get_contents (path.c_str(), &fbuf, NULL, NULL))  {
                return;
        }
+       stringstream ifs (fbuf);
+       g_free (fbuf);
 
        std::string stype;
        std::string sstatus;
@@ -1126,8 +1122,6 @@ PluginManager::load_statuses ()
                strip_whitespace_edges (id);
                set_status (type, id, status);
        }
-
-       ifs.close ();
 }
 
 void