[mw-devel] MW3 r1020 - trunk/src

welshbyte at sucs.org welshbyte at sucs.org
Fri Mar 28 20:09:29 GMT 2008


Author: welshbyte
Date: 2008-03-28 20:09:29 +0000 (Fri, 28 Mar 2008)
New Revision: 1020

Modified:
   trunk/src/add.c
   trunk/src/files.c
Log:
This lets mw cope with an empty folders.bb file
- Improve nofolders() function to cope with empty folders.bb
- Make the add_msg() function use it
- Fix debug message

Note: A missing folders.bb is still not handled



Modified: trunk/src/add.c
===================================================================
--- trunk/src/add.c	2008-03-28 16:38:00 UTC (rev 1019)
+++ trunk/src/add.c	2008-03-28 20:09:29 UTC (rev 1020)
@@ -40,7 +40,7 @@
 	/* check write status of folder */
 	
 	get_folder_number(fol,folnum);
-	if (!allowed_w(fol,user))
+	if (nofolders() || !allowed_w(fol,user))
 	{
 		printf(_("Not allowed to write to this folder.\n"));
 		free(fol);

Modified: trunk/src/files.c
===================================================================
--- trunk/src/files.c	2008-03-28 16:38:00 UTC (rev 1019)
+++ trunk/src/files.c	2008-03-28 20:09:29 UTC (rev 1020)
@@ -141,7 +141,20 @@
 		
 int nofolders(void)
 {
-	return(access(makepath(FOLDERFILE,"",""),00));
+	int fd;
+	struct folder fol;
+
+	fd = open(makepath(FOLDERFILE,"",""), O_RDONLY);
+	if (fd < 0) return 1;
+
+	if (read(fd,&fol,sizeof(struct folder)) < sizeof(struct folder))
+	{
+		close(fd);
+		return 1;
+	}
+
+	close(fd);
+	return 0;
 }
 
 void create_folder_file(void)
@@ -204,7 +217,7 @@
 	lseek(file,sizeof(*fol)*num,0);
 	if ((no=read(file,fol,sizeof(*fol)))<0)
 	{
-		perror("get_folder_entry");
+		perror("get_folder_number");
 		exit(-1);
 	}
 	close(file);





More information about the mw-devel mailing list