[mw-devel] MW3 r1015 - in trunk: . src

welshbyte at sucs.org welshbyte at sucs.org
Wed Mar 26 20:30:05 GMT 2008


Author: welshbyte
Date: 2008-03-26 20:30:05 +0000 (Wed, 26 Mar 2008)
New Revision: 1015

Modified:
   trunk/Makefile
   trunk/src/files.c
Log:
Create empty who.bb if who.bb doesn't exist.


Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2008-03-20 17:30:42 UTC (rev 1014)
+++ trunk/Makefile	2008-03-26 20:30:05 UTC (rev 1015)
@@ -17,7 +17,6 @@
 
 install:
 	install -d $(libdir)/mw/mesgs
-	touch "$(libdir)/mw/who.bb"
 	touch "$(libdir)/mw/log.bb"
 	cp -a $(INSTALLFILES) $(libdir)/mw/
 	make -C src install

Modified: trunk/src/files.c
===================================================================
--- trunk/src/files.c	2008-03-20 17:30:42 UTC (rev 1014)
+++ trunk/src/files.c	2008-03-26 20:30:05 UTC (rev 1015)
@@ -10,6 +10,7 @@
 #include <unistd.h>
 #include <sys/types.h>
 #include <string.h>
+#include <errno.h>
 #include "strings.h"
 
 int openuserfile(int mode)
@@ -52,16 +53,35 @@
 	close(outfile);
 }
 
-int openwhofile(int mode)
+int createwhofile()
 {
+	int fd;
+	fd = creat(makepath(WHOFILE,"",""), 0644);
+	if (fd < 0) {
+		perror("Create Who File");
+		return -1;
+	}
+	close(fd);
+	return 0;
+}
+
+int openwhofile(int flags)
+{
 	int x;
-	x=open(makepath(WHOFILE,"",""),mode);
-	if (x<0)
+	x=open(makepath(WHOFILE,"",""),flags);
+	if (x>=0) return x;
+
+	if (errno != ENOENT || createwhofile())
 	{
 		perror("Open Who File");
 		return(-1);
 	}
-	return(x);
+
+	x=open(makepath(WHOFILE,"",""),flags);
+	if (x>=0) return x;
+
+	perror("Open Who File After Create");
+	return -1;
 }
 
 void who_add(int pid, int32_t posn)





More information about the mw-devel mailing list