fix crash when copy'ing latent plugins
[ardour.git] / libs / ardour / utils.cc
index 71051434c6e6d15a0af67ce11bc07b7e2df74ca9..8e57cdeac305af0224101dab6b2612b80453d458 100644 (file)
@@ -33,7 +33,6 @@
 #include <cerrno>
 #include <iostream>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <sys/time.h>
 #include <fcntl.h>
 #ifndef COMPILER_MSVC
@@ -42,7 +41,8 @@
 #include <errno.h>
 #include <regex.h>
 
-#include <glibmm/convert.h>
+#include "pbd/gstdio_compat.h"
+
 #include <glibmm/miscutils.h>
 #include <glibmm/fileutils.h>
 
@@ -57,7 +57,7 @@
 #include "ardour/utils.h"
 #include "ardour/rc_configuration.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
 using namespace std;
@@ -133,13 +133,13 @@ ARDOUR::legalize_for_uri (const string& str)
  * version.
  */
 
-string 
+string
 ARDOUR::legalize_for_path_2X (const string& str)
 {
        string::size_type pos;
        string legal_chars = "abcdefghijklmnopqrtsuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_+=: ";
         Glib::ustring legal;
-       
+
        /* this is the one place in Ardour where we need to iterate across
         * potential multibyte characters, and thus we need Glib::ustring
         */
@@ -297,17 +297,6 @@ ARDOUR::cmp_nocase_utf8 (const string& s1, const string& s2)
        return retval;
 }
 
-int
-ARDOUR::touch_file (string path)
-{
-       int fd = open (Glib::locale_from_utf8 (path).c_str(), O_RDWR|O_CREAT, 0660);
-       if (fd >= 0) {
-               close (fd);
-               return 0;
-       }
-       return 1;
-}
-
 string
 ARDOUR::region_name_from_path (string path, bool strip_channels, bool add_channel_suffix, uint32_t total, uint32_t this_one)
 {
@@ -661,6 +650,8 @@ ARDOUR::native_header_format_extension (HeaderFormat hf, const DataType& type)
         case iXML:
                 return ".ixml";
         case RF64:
+        case RF64_WAV:
+        case MBWF:
                 return ".rf64";
         }
 
@@ -672,11 +663,11 @@ ARDOUR::native_header_format_extension (HeaderFormat hf, const DataType& type)
 bool
 ARDOUR::matching_unsuffixed_filename_exists_in (const string& dir, const string& path)
 {
-        string bws = basename_nosuffix (path);
+       string bws = basename_nosuffix (path);
        struct dirent* dentry;
-       struct stat statbuf;
+       GStatBuf statbuf;
        DIR* dead;
-        bool ret = false;
+       bool ret = false;
 
         if ((dead = ::opendir (dir.c_str())) == 0) {
                 error << string_compose (_("cannot open directory %1 (%2)"), dir, strerror (errno)) << endl;
@@ -694,7 +685,7 @@ ARDOUR::matching_unsuffixed_filename_exists_in (const string& dir, const string&
 
                 string fullpath = Glib::build_filename (dir, dentry->d_name);
 
-                if (::stat (fullpath.c_str(), &statbuf)) {
+                if (g_stat (fullpath.c_str(), &statbuf)) {
                         continue;
                 }
 
@@ -763,3 +754,4 @@ ARDOUR::slider_position_to_gain_with_max (double g, double max_gain)
 extern "C" {
        void c_stacktrace() { stacktrace (cerr); }
 }
+