summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2012-10-03 17:29:01 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-10-04 02:43:10 -0700
commit4f18f83ce9a46c58720e0ed65074bd60f92b0e29 (patch)
tree2438a652c8d227fac5fb0810b793611f9c028fd7
parentf3b9a37fb2e853717723ca98d07101201a328518 (diff)
downloadsubsurface-4f18f83ce9a46c58720e0ed65074bd60f92b0e29.tar.gz
Use GLib's g_fopen() and g_open() when working with files
On Windows, the GLib wrappers for fopen() and open() deal with the UTF-8 format used for file names when we have to open or save a file with unicode characters in its name. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--file.c4
-rw-r--r--save-xml.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/file.c b/file.c
index 943be6f09..df00ea213 100644
--- a/file.c
+++ b/file.c
@@ -22,7 +22,7 @@ static int readfile(const char *filename, struct memblock *mem)
mem->buffer = NULL;
mem->size = 0;
- fd = open(filename, O_RDONLY | O_BINARY);
+ fd = g_open(filename, O_RDONLY | O_BINARY, 0);
if (fd < 0)
return fd;
ret = fstat(fd, &st);
@@ -257,7 +257,7 @@ void parse_file(const char *filename, GError **error)
if (default_filename && ! strcmp(filename, default_filename))
return;
- fprintf(stderr, "Failed to read '%s'.\n", filename);
+ g_warning("Failed to read '%s'.\n", filename);
if (error) {
*error = g_error_new(g_quark_from_string("subsurface"),
DIVE_ERROR_PARSE,
diff --git a/save-xml.c b/save-xml.c
index 8fa723f61..f386814f3 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -352,7 +352,7 @@ void save_dives(const char *filename)
struct dive *dive;
dive_trip_t *trip = NULL;
- FILE *f = fopen(filename, "w");
+ FILE *f = g_fopen(filename, "w");
if (!f)
return;