From eeb4859e9b0621f390bc42389091d1dbef4bc3cc Mon Sep 17 00:00:00 2001 From: hiro Date: Mon, 25 Dec 2006 08:12:22 +0000 Subject: change_file_mode_rw(): win32: use widechar API. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1459 ee746299-78ed-0310-b773-934348b2243d --- libsylph/utils.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'libsylph') diff --git a/libsylph/utils.c b/libsylph/utils.c index 803892c5..663d121f 100644 --- a/libsylph/utils.c +++ b/libsylph/utils.c @@ -3156,9 +3156,32 @@ gint change_file_mode_rw(FILE *fp, const gchar *file) DWORD attr; BOOL retval; - attr = GetFileAttributes(file); - retval = SetFileAttributes - (file, attr & ~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN)); + if (G_WIN32_HAVE_WIDECHAR_API()) { + wchar_t *wpath; + + wpath = g_utf8_to_utf16(file, -1, NULL, NULL, NULL); + if (wpath == NULL) + return -1; + + attr = GetFileAttributesW(wpath); + retval = SetFileAttributesW + (wpath, attr & ~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN)); + + g_free(wpath); + } else { + gchar *cp_path; + + cp_path = g_locale_from_utf8(file, -1, NULL, NULL, NULL); + if (cp_path == NULL) + return -1; + + attr = GetFileAttributesA(cp_path); + retval = SetFileAttributesA + (cp_path, attr & ~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN)); + + g_free(cp_path); + } + if (retval) return 0; else -- cgit v1.2.3