Merging undo branch into trunk. It compiles and works for limited tests. Keep
[ardour.git] / libs / ardour / utils.cc
index 15d0c6be813b7cde495a4da0700fd9b07b0f6a53..78e5572a3ddb20aa994a3fe6de687d488f9ab672 100644 (file)
@@ -42,6 +42,7 @@
 
 using namespace ARDOUR;
 using namespace std;
+using namespace PBD;
 
 void
 elapsed_time_to_str (char *buf, uint32_t seconds)
@@ -177,7 +178,7 @@ tokenize_fullpath (string fullpath, string& path, string& name)
 int
 touch_file (string path)
 {
-       int fd = open (path.c_str(), O_RDONLY|O_CREAT);
+       int fd = open (path.c_str(), O_RDWR|O_CREAT, 0660);
        if (fd >= 0) {
                close (fd);
                return 0;
@@ -185,15 +186,6 @@ touch_file (string path)
        return 1;
 }
 
-uint32_t long
-get_uid()
-{
-       struct timeval tv;
-       gettimeofday(&tv, 0);
-
-       return (uint32_t long) tv.tv_sec * 1000000 + tv.tv_usec;
-}
-
 string
 placement_as_string (Placement p)
 {
@@ -261,3 +253,21 @@ path_expand (string path)
 #endif
 }
 
+#ifdef HAVE_COREAUDIO
+string 
+CFStringRefToStdString(CFStringRef stringRef)
+{
+       CFIndex size = 
+               CFStringGetMaximumSizeForEncoding(CFStringGetLength(stringRef) , 
+               kCFStringEncodingUTF8);
+           char *buf = new char[size];
+       
+       std::string result;
+
+       if(CFStringGetCString(stringRef, buf, size, kCFStringEncodingUTF8)) {
+           result = buf;
+       }
+       delete [] buf;
+       return result;
+}
+#endif // HAVE_COREAUDIO