summaryrefslogtreecommitdiff
path: root/libs/ardour/vst_info_file.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-10-04 18:23:21 +0200
committerRobin Gareus <robin@gareus.org>2015-10-04 18:23:21 +0200
commit2fbed9e41f754b2b0dce4bc481f5193532b165b9 (patch)
tree37f8f3d8bf659d26c3dfa5bca3d451bdc738473d /libs/ardour/vst_info_file.cc
parent00c9d1bf346b8a0a7cf5127090e52179e79d5489 (diff)
replace std::ifstream with g_fopen for portability
Diffstat (limited to 'libs/ardour/vst_info_file.cc')
-rw-r--r--libs/ardour/vst_info_file.cc39
1 files changed, 33 insertions, 6 deletions
diff --git a/libs/ardour/vst_info_file.cc b/libs/ardour/vst_info_file.cc
index 6ab9de2a2b..72119dc768 100644
--- a/libs/ardour/vst_info_file.cc
+++ b/libs/ardour/vst_info_file.cc
@@ -107,6 +107,36 @@ vstfx_infofile_path (const char* dllpath)
/* *** VST Blacklist *** */
+static void vstfx_read_blacklist (std::string &bl) {
+ FILE * blacklist_fd = NULL;
+ bl = "";
+
+ string fn = Glib::build_filename (ARDOUR::user_cache_directory (), VST_BLACKLIST);
+
+ if (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) {
+ return;
+ }
+
+ if (! (blacklist_fd = g_fopen (fn.c_str (), "rb"))) {
+ return;
+ }
+
+ while (!feof (blacklist_fd)) {
+ char buf[1024];
+ size_t s = fread (buf, sizeof(char), 1024, blacklist_fd);
+ if (ferror (blacklist_fd)) {
+ error << string_compose (_("error reading VST Blacklist file %1 (%2)"), fn, strerror (errno)) << endmsg;
+ bl = "";
+ break;
+ }
+ if (s == 0) {
+ break;
+ }
+ bl.append (buf, s);
+ }
+ ::fclose (blacklist_fd);
+}
+
/** mark plugin as blacklisted */
static void vstfx_blacklist (const char *id)
{
@@ -132,10 +162,7 @@ static void vstfx_un_blacklist (const char *idcs)
}
std::string bl;
- {
- std::ifstream ifs (fn.c_str ());
- bl.assign ((std::istreambuf_iterator<char> (ifs)), (std::istreambuf_iterator<char> ()));
- }
+ vstfx_read_blacklist (bl);
::g_unlink (fn.c_str ());
@@ -169,9 +196,9 @@ static bool vst_is_blacklisted (const char *idcs)
if (!Glib::file_test (fn, Glib::FILE_TEST_EXISTS)) {
return false;
}
+
std::string bl;
- std::ifstream ifs (fn.c_str ());
- bl.assign ((std::istreambuf_iterator<char> (ifs)), (std::istreambuf_iterator<char> ()));
+ vstfx_read_blacklist (bl);
assert (id.find ("\n") == string::npos);