[Tux4kids-commits] r1365 - in tuxtype/branches/gsoc-sarah: doc src

Sarah Frisk fou_fou-guest at alioth.debian.org
Wed Aug 5 08:13:47 UTC 2009


Author: fou_fou-guest
Date: 2009-08-05 08:13:46 +0000 (Wed, 05 Aug 2009)
New Revision: 1365

Modified:
   tuxtype/branches/gsoc-sarah/doc/ChangeLog
   tuxtype/branches/gsoc-sarah/src/editor.c
Log:
Program now successfully creates/removes/changes files

Modified: tuxtype/branches/gsoc-sarah/doc/ChangeLog
===================================================================
--- tuxtype/branches/gsoc-sarah/doc/ChangeLog	2009-08-05 00:01:42 UTC (rev 1364)
+++ tuxtype/branches/gsoc-sarah/doc/ChangeLog	2009-08-05 08:13:46 UTC (rev 1365)
@@ -1,3 +1,9 @@
+5 Aug 2009 (svn.debian.org/tux4kids -revision 1365)
+[Sarah Frisk <ssfrisk at gmail.com> }
+	-Program now successfully creates/removes/changes files
+	-Bug to be fixed: program crashes at the end of NewWordList(),
+	however, it does save the new word list.
+
 4 Aug 2009 (svn.debian.org/tux4kids -revision 1361)
 [Sarah Frisk <ssfrisk at gmail.com> }
 	-Worked on drawing issues in NewWordList()

Modified: tuxtype/branches/gsoc-sarah/src/editor.c
===================================================================
--- tuxtype/branches/gsoc-sarah/src/editor.c	2009-08-05 00:01:42 UTC (rev 1364)
+++ tuxtype/branches/gsoc-sarah/src/editor.c	2009-08-05 08:13:46 UTC (rev 1365)
@@ -733,6 +733,7 @@
 {
 	fprintf(stderr, "Creating a New Word List!!!");
 	int stop = 0;
+	int save = 0;
 	SDL_Surface* OK_button = NULL;
 	SDL_Surface* CANCEL_button = NULL;
 	SDL_Surface *OK = NULL, *CANCEL = NULL;
@@ -751,6 +752,9 @@
 	int len = 0; //len = length, 
 	int i = 0; //i = checks for keydown
 	
+	FILE* fp = NULL;
+	char fn[FNLEN];
+	
 	//Creates a box thing, tells user to enter in name of list.  Click OK, or CANCEL
 	//FIXME: Text in boxes needs work
 	//FIXME: Create a rect for user to enter stuff, and a pretty box to go around everything
@@ -803,6 +807,7 @@
 						// Check if anything is written
 							//if yes, save
 							//if not, don't do anything?
+						save = 1;	
 						stop = 1;
 						break;
 						
@@ -852,6 +857,7 @@
 								if (len != 0)
 								{
 									fprintf(stderr, "Save the wordlist\n");
+									save = 1;
 									i = 0;
 									stop = 1;
 									break;
@@ -860,7 +866,7 @@
 								{
 									fprintf(stderr, "Word needs an actual length\n");
 									i = 0;
-									stop = 1;
+									//stop = 1;
 									break;
 								}
 		                	i = 0;
@@ -918,7 +924,22 @@
 
 		fprintf(stderr, "Check Two\n");
 
+		
+		/* Creating file, if possible */
+		if (save == 1)
+		{
+			sprintf(fn, "%s/%s.txt", settings.var_data_path, wordlist);
+			fprintf(stderr, "File to be saved: %s\n", fn);
+			fp = fopen(fn, "a+");
+			fprintf(stderr, "Opened File\n");
+			fprintf(fp,"%s", wordlist);
+			fprintf(stderr, "Wrote file\n");
+			fclose(fp);	
+			fprintf(stderr, "Closed file\n");
+		}
+		
 	
+	
 		//we free stuff  
 		if(OK_button)
 			SDL_FreeSurface(OK_button);




More information about the Tux4kids-commits mailing list