[Xbubble-commits] xbubble-sdl/src utils.c,1.2,1.3
Martin Quinson
mquinson at alioth.debian.org
Tue May 18 14:16:53 UTC 2010
Update of /cvsroot/xbubble/xbubble-sdl/src
In directory alioth:/tmp/cvs-serv27280
Modified Files:
utils.c
Log Message:
When launching the game from the source tree, search data locally
Index: utils.c
===================================================================
RCS file: /cvsroot/xbubble/xbubble-sdl/src/utils.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- utils.c 18 May 2010 11:58:17 -0000 1.2
+++ utils.c 18 May 2010 14:16:46 -0000 1.3
@@ -26,6 +26,8 @@
#include <string.h>
#include <limits.h> /* pathconf */
#include <dirent.h>
+#include <unistd.h> /* access */
+#include <errno.h>
#include "config.h"
#include "utils.h"
@@ -264,6 +266,20 @@
strncpy( buffer + offset, name, 126);
}
+ if (access(buffer,R_OK) && errno == ENOENT) {
+ /* file not found. Try to get it locally so that it works even if not installed yet */
+ static char buff[1024];
+ sprintf(buff,"../data/%s%s%s%s",theme?"themes/":"",theme?theme:"",theme?"/":"",name);
+ if (!access(buff,R_OK)) { /* great, we found it locally */
+ printf("Load %s locally as %s\n",name,buff);
+
+ return buff;
+ } else {
+ printf("Cannot open %s either\n",buff);
+ }
+ }
+ //printf("Load %s as %s\n",name,buffer);
+
return buffer;
}
More information about the Xbubble-commits
mailing list