diff options
author | Arnav Singh <arnavion@gmail.com> | 2012-10-22 02:00:21 -0700 |
---|---|---|
committer | Arnav Singh <arnavion@gmail.com> | 2012-10-22 19:07:28 -0700 |
commit | 8c7ec909b899d859af3f20927ab2db6e3b2270fb (patch) | |
tree | 7b3860a9c45513064e6cd3d33ed5f206dcce8457 | |
parent | 1cc599a0f92eddf65d3bb9b6d874c21b1281d803 (diff) |
Replaced use of OS file I/O functions which expect filenames in system codepage with GLib's, since GLib's functions work with UTF-8 and GLib handles converting the filename to system codepage for us.
-rw-r--r-- | src/common/dcc.c | 14 | ||||
-rw-r--r-- | src/common/xchat.h | 5 |
2 files changed, 8 insertions, 11 deletions
diff --git a/src/common/dcc.c b/src/common/dcc.c index 6f0dedcc..36c0b499 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -57,6 +57,8 @@ #include "url.h" #include "xchatc.h" +#include <glib/gstdio.h> + #ifdef USE_DCC64 #define BIG_STR_TO_INT(x) strtoull(x,NULL,10) #ifdef WIN32 @@ -691,12 +693,12 @@ dcc_read (GIOChannel *source, GIOCondition condition, struct DCC *dcc) if (dcc->resumable) { - dcc->fp = open (dcc->destfile_fs, O_WRONLY | O_APPEND | OFLAGS); + dcc->fp = g_open (dcc->destfile_fs, O_WRONLY | O_APPEND | OFLAGS, 0); dcc->pos = dcc->resumable; dcc->ack = dcc->resumable; } else { - if (access (dcc->destfile_fs, F_OK) == 0) + if (g_access (dcc->destfile_fs, F_OK) == 0) { n = 0; do @@ -717,7 +719,7 @@ dcc_read (GIOChannel *source, GIOCondition condition, struct DCC *dcc) g_free (old); } dcc->fp = - open (dcc->destfile_fs, OFLAGS | O_TRUNC | O_WRONLY | O_CREAT, + g_open (dcc->destfile_fs, OFLAGS | O_TRUNC | O_WRONLY | O_CREAT, prefs.hex_dcc_permissions); } } @@ -1835,7 +1837,7 @@ dcc_send (struct session *sess, char *to, char *file, int maxcps, int passive) dcc->dccstat = STAT_QUEUED; dcc->size = st.st_size; dcc->type = TYPE_SEND; - dcc->fp = open (file_fs, OFLAGS | O_RDONLY); + dcc->fp = g_open (file_fs, OFLAGS | O_RDONLY, 0); if (dcc->fp != -1) { g_free (file_fs); @@ -2015,11 +2017,11 @@ is_resumable (struct DCC *dcc) dcc->resumable = 0; /* Check the file size */ - if (access (dcc->destfile_fs, W_OK) == 0) + if (g_access (dcc->destfile_fs, W_OK) == 0) { struct stat st; - if (stat (dcc->destfile_fs, &st) != -1) + if (g_stat (dcc->destfile_fs, &st) != -1) { if (st.st_size < dcc->size) { diff --git a/src/common/xchat.h b/src/common/xchat.h index a19716f6..2980fc1c 100644 --- a/src/common/xchat.h +++ b/src/common/xchat.h @@ -589,12 +589,7 @@ struct popup /* CL: get a random int in the range [0..n-1]. DON'T use rand() % n, it gives terrible results. */ #define RAND_INT(n) ((int)(rand() / (RAND_MAX + 1.0) * (n))) -#ifdef WIN32 -#define xchat_filename_from_utf8 g_locale_from_utf8 -#define xchat_filename_to_utf8 g_locale_to_utf8 -#else #define xchat_filename_from_utf8 g_filename_from_utf8 #define xchat_filename_to_utf8 g_filename_to_utf8 -#endif #endif |