summaryrefslogtreecommitdiffstats
path: root/utf8.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-03-14 02:39:38 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-03-14 02:39:38 -0700
commit9cfd4e0adf28ad932b2a99886c1aae96715669a3 (patch)
tree76c9275a9771e52fc677af33bf37944f919bc68b /utf8.c
parent6150e4f135fdab479af31a93c2e8ae89d414c224 (diff)
downloadtxr-9cfd4e0adf28ad932b2a99886c1aae96715669a3.tar.gz
txr-9cfd4e0adf28ad932b2a99886c1aae96715669a3.tar.bz2
txr-9cfd4e0adf28ad932b2a99886c1aae96715669a3.zip
* utf8.c (w_fopen, w_popen, w_freopen, w_remove, w_rename): We
have similar functions in the MSVCRT library used by MinGW, so if _WIN32 is defined, our functions now just wrap those.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index e3ef3e7a..51a61371 100644
--- a/utf8.c
+++ b/utf8.c
@@ -359,48 +359,68 @@ wint_t utf8_decode(utf8_decoder_t *ud, int (*get)(mem_t *ctx), mem_t *ctx)
FILE *w_fopen(const wchar_t *wname, const wchar_t *wmode)
{
+#ifdef _WIN32
+ return _wfopen(wname, wmode);
+#else
char *name = utf8_dup_to(wname);
char *mode = utf8_dup_to(wmode);
FILE *f = fopen(name, mode);
free(name);
free(mode);
return f;
+#endif
}
FILE *w_popen(const wchar_t *wcmd, const wchar_t *wmode)
{
+#ifdef _WIN32
+ return _wpopen(wcmd, wmode);
+#else
char *cmd = utf8_dup_to(wcmd);
char *mode = utf8_dup_to(wmode);
FILE *f = popen(cmd, mode);
free(cmd);
free(mode);
return f;
+#endif
}
FILE *w_freopen(const wchar_t *wname, const wchar_t *wmode, FILE *fold)
{
+#ifdef _WIN32
+ return _wfreopen(wname, wmode, fold);
+#else
char *name = utf8_dup_to(wname);
char *mode = utf8_dup_to(wmode);
FILE *f = fold ? freopen(name, mode, fold) : fopen(name, mode);
free(name);
free(mode);
return f;
+#endif
}
int w_remove(const wchar_t *wpath)
{
+#ifdef _WIN32
+ return _wremove(wpath);
+#else
char *path = utf8_dup_to(wpath);
int err = remove(path);
free(path);
return err;
+#endif
}
int w_rename(const wchar_t *wfrom, const wchar_t *wto)
{
+#ifdef _WIN32
+ return _wrename(wfrom, wto);
+#else
char *from = utf8_dup_to(wfrom);
char *to = utf8_dup_to(wto);
int err = rename(from, to);
free(to);
free(from);
return err;
+#endif
}