Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Coudoin <bcoudoin@src.gnome.org>2006-11-13 21:56:56 (GMT)
committer Bruno Coudoin <bcoudoin@src.gnome.org>2006-11-13 21:56:56 (GMT)
commit9016d9806b286d63dec93a4760335473a73bec08 (patch)
treec2909d9e49c7b3952f9365ebbd3a834380d5fdc9
parent740b3ae36d911523fd8a23552f04f2de6434660b (diff)
changed to no more use open. open is not portable and it fails to open
* src/gcompris/properties.c: (gc_prop_config_file_get), (gc_prop_new): changed to no more use open. open is not portable and it fails to open file with utf8 characters on windows.
-rw-r--r--ChangeLog6
-rw-r--r--src/gcompris/properties.c19
2 files changed, 15 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 8635d26..c37afbc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-13 Bruno coudoin <bruno.coudoin@free.fr>
+
+ * src/gcompris/properties.c: (gc_prop_config_file_get),
+ (gc_prop_new): changed to no more use open. open is not portable
+ and it fails to open file with utf8 characters on windows.
+
2006-11-12 Bruno coudoin <bruno.coudoin@free.fr>
- By Miguel DE IZARRA, added a 2 player mode in connect4.
diff --git a/src/gcompris/properties.c b/src/gcompris/properties.c
index 2d20020..bb5fdc2 100644
--- a/src/gcompris/properties.c
+++ b/src/gcompris/properties.c
@@ -23,7 +23,6 @@
#include <glib/gstdio.h>
#include <fcntl.h>
#include <string.h>
-#include <unistd.h>
#include "gcompris.h"
@@ -103,7 +102,7 @@ gc_prop_config_file_get()
#ifdef WIN32
if (! G_WIN32_IS_NT_BASED() ) {
config_file = g_strconcat(dir, "/gcompris.cfg", NULL);
- } else
+ } else
#endif
config_file = g_strconcat(dir, "/gcompris.conf", NULL);
@@ -131,7 +130,8 @@ gc_prop_new ()
GcomprisProperties *tmp;
char *config_file = gc_prop_config_file_get();
GScanner *scanner;
- int filefd;
+ gchar *content;
+ gsize length;
gchar *full_rootdir;
#ifndef WIN32
const gchar *locale;
@@ -204,15 +204,16 @@ gc_prop_new ()
g_warning("config_file %s", config_file);
- filefd = open(config_file, O_RDONLY);
-
- if(filefd > 0) {
+ if(g_file_get_contents(config_file,
+ &content,
+ &length,
+ NULL)) {
/* create a new scanner */
scanner = g_scanner_new(NULL);
/* set up the scanner to read from the file */
- g_scanner_input_file(scanner, filefd);
+ g_scanner_input_text(scanner, content, length);
/* while the next token is something else other than end of file */
while(g_scanner_peek_next_token(scanner) != G_TOKEN_EOF) {
@@ -286,9 +287,7 @@ gc_prop_new ()
/* destroy the scanner */
g_scanner_destroy(scanner);
-
- close(filefd);
-
+ g_free(content);
}
/*