[PD-cvs] pd/src s_file.c,1.8.2.3,1.8.2.4

Hans-Christoph Steiner eighthave at users.sourceforge.net
Sun Jun 17 07:11:17 CEST 2007


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5003

Modified Files:
      Tag: branch-v0-39-2-extended
	s_file.c 
Log Message:
added option for both a default embedded preferences file which can be overridden by user prefs, and another embedded prefs file, which overrides both user and default.  This allows the creation of standalone apps by including the pd patch into the Pd.app and opening it using the embedded prefs

Index: s_file.c
===================================================================
RCS file: /cvsroot/pure-data/pd/src/s_file.c,v
retrieving revision 1.8.2.3
retrieving revision 1.8.2.4
diff -C2 -d -r1.8.2.3 -r1.8.2.4
*** s_file.c	31 May 2007 22:39:12 -0000	1.8.2.3
--- s_file.c	17 Jun 2007 05:11:14 -0000	1.8.2.4
***************
*** 216,230 ****
      char cmdbuf[256];
      int nread = 0, nleft = size;
! 	char embedded_prefs[MAXPDSTRING];
! 	char user_prefs[MAXPDSTRING];
  	char *homedir = getenv("HOME");
      struct stat statbuf;
  	/* the 'defaults' command expects the filename without .plist at the end */
! 	snprintf(embedded_prefs, MAXPDSTRING, "%s/../org.puredata.pd", sys_libdir->s_name);
! 	snprintf(user_prefs, MAXPDSTRING, "%s/Library/Preferences/org.puredata.pd.plist", homedir);
! 	if (stat(user_prefs, &statbuf) == 0)
! 		snprintf(cmdbuf, 256, "defaults read org.puredata.pd %s 2> /dev/null\n", key);
  	else 
! 		snprintf(cmdbuf, 256, "defaults read %s %s 2> /dev/null\n", embedded_prefs, key);
      FILE *fp = popen(cmdbuf, "r");
      while (nread < size)
--- 216,250 ----
      char cmdbuf[256];
      int nread = 0, nleft = size;
! 	char default_prefs[MAXPDSTRING]; // default prefs embedded in the package
! 	char embedded_prefs[MAXPDSTRING]; // overrides others for standalone app
! 	char embedded_prefs_file[MAXPDSTRING];
! 	char user_prefs_file[MAXPDSTRING];
  	char *homedir = getenv("HOME");
      struct stat statbuf;
  	/* the 'defaults' command expects the filename without .plist at the end */
! 	snprintf(default_prefs, MAXPDSTRING, "%s/../org.puredata.pd.default", 
! 			 sys_libdir->s_name);
! 	snprintf(embedded_prefs, MAXPDSTRING, "%s/../org.puredata.pd", 
! 			 sys_libdir->s_name);
! 	snprintf(embedded_prefs_file, MAXPDSTRING, "%s.plist", embedded_prefs);
! 	snprintf(user_prefs_file, MAXPDSTRING, 
! 			 "%s/Library/Preferences/org.puredata.pd.plist", homedir);
! //	fprintf(stderr,"embedded_prefs %s\nuser_prefs: %s\ndefault_prefs: %s\n",
! //			embedded_prefs,user_prefs_file,default_prefs);
! 	if (stat(embedded_prefs_file, &statbuf) == 0) 
! 	{
! 		snprintf(cmdbuf, 256, 
! 				 "defaults read %s %s 2> /dev/null\n", embedded_prefs, key);
! 	}
! 	else if (stat(user_prefs_file, &statbuf) == 0) 
! 	{
! 		snprintf(cmdbuf, 256, 
! 				 "defaults read org.puredata.pd %s 2> /dev/null\n", key);
! 	}
  	else 
! 	{
! 		snprintf(cmdbuf, 256, 
! 				 "defaults read %s %s 2> /dev/null\n", default_prefs, key);
! 	}
      FILE *fp = popen(cmdbuf, "r");
      while (nread < size)





More information about the Pd-cvs mailing list