[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-user: gsch2pcb use pcb library preferences patch



   This patch lets gsch2pcb open up ~/.pcb/preferences and read the
   library-newlib = paths and add them to the list of places to get
   footprints.  The patch is directly for gsch2pcb.c
--- gsch2pcb.c	2008-12-31 18:15:59.000000000 -0500
+++ gsch2pcbnew.c	2009-03-10 20:41:59.000000000 -0400
@@ -1468,6 +1468,42 @@
 		element_directory_list = g_list_append(element_directory_list,
 					"packages");
 
+	/* load library paths from pcb preferences ~/.pcb/preferences */
+	printf("going into new code\n");
+	path = g_build_filename((gchar *) g_get_home_dir(), ".pcb/preferences", NULL);
+	if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
+	{
+		char buf[1024];		
+		gchar *pref_paths, *pref_path, *tmp;
+		FILE *fp;
+		fp=fopen(path, "r");
+		while(fgets(buf, sizeof(buf), fp)) 
+		{ 
+			if (g_str_has_prefix(buf, "library-newlib = "))
+			{
+				pref_paths = buf+17;
+				printf("found- %s\n", pref_paths);
+				tmp = pref_paths;
+				while(*tmp != 0)
+				{
+					while(*++tmp != ':' && *tmp != 0); //push np up to next : or end of string
+					pref_path = g_strndup(pref_paths, tmp-pref_paths);
+					if (*pref_path == '~')
+					{
+						pref_path = g_build_filename((gchar *) g_get_home_dir(), pref_path+1, NULL);
+					}
+					if (g_file_test(pref_path, G_FILE_TEST_IS_DIR))
+							element_directory_list = g_list_append(element_directory_list, pref_path);
+					printf("next- %s\n", pref_path);
+					pref_paths = tmp+1;
+				}
+			}       
+		}
+		fclose(fp);
+		g_free(pref_path);
+	}
+	printf("coming out of new code\n");
+
 #define PCB_PATH_DELIMETER ":"
 	if (verbose)
 		printf ("Processing PCBLIBPATH=\"%s\"\n", PCBLIBPATH);

_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user