[gcompris-devel] Python bugs...
Olivier Samyn
osamyn at ulb.ac.be
Fri Apr 11 05:35:03 UTC 2003
I just commited the latest changes I made on the gcompris Python code...
It'll now work as it was supposed to... (some import errors)
I also removed some files that are in fact added by autoconf (and so
doesn't need to be present on the CVS).
Finally, I made a patch on gameutils.c to avoid the use of the scandir
function. It'll resolve the bug on solaris... I didn't already commited
it because I'm not sure the sorting method I used is the good one.
Can someone check this ? (I attatch the patch to this mail)
--
Olivier Samyn <osamyn at ulb.ac.be>
-------------- next part --------------
--- gameutil.c.old 2003-04-06 17:16:05.000000000 +0200
+++ gameutil.c 2003-04-06 17:32:40.000000000 +0200
@@ -594,10 +594,8 @@
/*
* Select only files with .xml extention
*/
-int selectMenuXML(void *d)
+int selectMenuXML(const char *file)
{
- gchar *file = ((struct dirent *)d)->d_name;
-
if(strlen(file)<4)
return 0;
@@ -609,20 +607,40 @@
*/
void gcompris_load_menus()
{
- struct dirent **namelist;
- int n;
-
- n = scandir(PACKAGE_DATA_DIR, &namelist, &selectMenuXML, alphasort);
- if (n < 0)
- g_warning("gcompris_load_menus : scandir");
- else {
- while(n--) {
- /* add the board to the list */
- boards_list = g_list_append(boards_list, gcompris_read_xml_file(namelist[n]->d_name));
-
- free (namelist [n]);
+ GList *namelist = NULL;
+ GDir *dir;
+ GList *n;
+ const char* file;
+
+ dir = g_dir_open(PACKAGE_DATA_DIR, 0, NULL);
+ if(dir==NULL){
+ g_warning("gcompris_load_menus : g_dir_open");
+ } else {
+
+ file = g_dir_read_name (dir);
+ while (file!=NULL){
+ if(selectMenuXML(file) > 0){
+ namelist = g_list_insert_sorted( namelist,
+ (gpointer)g_strdup(file),
+ (GCompareFunc)strcmp);
+ }
+ file = g_dir_read_name (dir);
+ }
+ g_dir_close(dir);
+
+ n = g_list_first(namelist);
+
+ if (n == NULL)
+ g_warning("gcompris_load_menus : namelist");
+ else {
+ while( n !=NULL ) {
+ /* add the board to the list */
+ boards_list = g_list_append(boards_list, gcompris_read_xml_file(n->data));
+ g_free(n->data);
+ n = g_list_next(n);
+ }
}
- free (namelist);
+ g_list_free(namelist);
}
gcompris_get_menulist("/");
}
More information about the Gcompris-devel
mailing list