[PD-cvs] SF.net SVN: pure-data: [10014] branches/pd-extended/v0-40/pd/src/s_file.c

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Tue Jun 17 18:25:57 CEST 2008


Revision: 10014
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10014&view=rev
Author:   eighthave
Date:     2008-06-17 09:25:57 -0700 (Tue, 17 Jun 2008)

Log Message:
-----------
save to embedded preferences file on Mac OS X if the app is currently using them

Modified Paths:
--------------
    branches/pd-extended/v0-40/pd/src/s_file.c

Modified: branches/pd-extended/v0-40/pd/src/s_file.c
===================================================================
--- branches/pd-extended/v0-40/pd/src/s_file.c	2008-06-17 16:03:47 UTC (rev 10013)
+++ branches/pd-extended/v0-40/pd/src/s_file.c	2008-06-17 16:25:57 UTC (rev 10014)
@@ -227,6 +227,9 @@
 
 #ifdef __APPLE__
 
+// prefs file that is currently the one to save to
+static char current_prefs[FILENAME_MAX] = "org.puredata.pd"; 
+
 static void sys_initloadpreferences( void)
 {
 }
@@ -251,18 +254,21 @@
 			 "%s/Library/Preferences/org.puredata.pd.plist", homedir);
 	if (stat(embedded_prefs_file, &statbuf) == 0) 
 	{
-		snprintf(cmdbuf, 256, 
+		snprintf(cmdbuf, FILENAME_MAX + 20, 
 				 "defaults read %s %s 2> /dev/null\n", embedded_prefs, key);
+        strncpy(current_prefs, embedded_prefs, FILENAME_MAX);
 	}
 	else if (stat(user_prefs_file, &statbuf) == 0) 
 	{
-		snprintf(cmdbuf, 256, 
+		snprintf(cmdbuf, FILENAME_MAX + 20, 
 				 "defaults read org.puredata.pd %s 2> /dev/null\n", key);
+        strcpy(current_prefs, "org.puredata.pd");
 	}
 	else 
 	{
-		snprintf(cmdbuf, 256, 
+		snprintf(cmdbuf, FILENAME_MAX + 20, 
 				 "defaults read %s %s 2> /dev/null\n", default_prefs, key);
+        strcpy(current_prefs, "org.puredata.pd");
 	}
     FILE *fp = popen(cmdbuf, "r");
     while (nread < size)
@@ -295,7 +301,8 @@
 {
     char cmdbuf[MAXPDSTRING];
     snprintf(cmdbuf, MAXPDSTRING, 
-        "defaults write org.puredata.pd %s \"%s\" 2> /dev/null\n", key, value);
+             "defaults write %s %s \"%s\" 2> /dev/null\n",
+             current_prefs, key, value);
     system(cmdbuf);
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list