diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-12-25 08:12:22 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2006-12-25 08:12:22 +0000 |
commit | eeb4859e9b0621f390bc42389091d1dbef4bc3cc (patch) | |
tree | beae1260cbcdc7d1ab77d98e4177aa0a0f6bd64a | |
parent | 4eadc36300cb4566f731ea71372f2edb9e0c6849 (diff) |
change_file_mode_rw(): win32: use widechar API.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1459 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | ChangeLog.ja | 5 | ||||
-rw-r--r-- | libsylph/utils.c | 29 |
3 files changed, 35 insertions, 3 deletions
@@ -1,5 +1,9 @@ 2006-12-25 + * libsylph/utils.c: change_file_mode_rw(): win32: use widechar API. + +2006-12-25 + * libsylph/utils.c: change_file_mode_rw(): win32: use SetFileAttributes() to change file attributes. * libsylph/procmsg.c: diff --git a/ChangeLog.ja b/ChangeLog.ja index d979af3a..72319ad7 100644 --- a/ChangeLog.ja +++ b/ChangeLog.ja @@ -1,5 +1,10 @@ 2006-12-25 + * libsylph/utils.c: change_file_mode_rw(): win32: ワイドキャラクタ + API を使用。 + +2006-12-25 + * libsylph/utils.c: change_file_mode_rw(): win32: ファイルの属性を 変更するのに SetFileAttributes() を使用するようにした。 * libsylph/procmsg.c: 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 |