aboutsummaryrefslogtreecommitdiff
path: root/libsylph/utils.c
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-12-25 07:59:28 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2006-12-25 07:59:28 +0000
commit959f0bca04be8a58bdf0533793dd17514251db27 (patch)
tree4f66a553b12529c123b90393884eab4df7b54e25 /libsylph/utils.c
parent608ad31f3e7ca6270cac78ea2022467e0dc257a4 (diff)
fixed crash when .sylpheed_mark is not writable.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1457 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph/utils.c')
-rw-r--r--libsylph/utils.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/libsylph/utils.c b/libsylph/utils.c
index bd104e6e..428b5c84 100644
--- a/libsylph/utils.c
+++ b/libsylph/utils.c
@@ -3152,10 +3152,25 @@ gchar *generate_mime_boundary(const gchar *prefix)
gint change_file_mode_rw(FILE *fp, const gchar *file)
{
+#ifdef G_OS_WIN32
+ DWORD attr;
+ BOOL retval;
+
+ attr = GetFileAttributes(file);
+ retval = SetFileAttributes
+ (file, attr & ~(FILE_ATTRIBUTE_READONLY|FILE_ATTRIBUTE_HIDDEN));
+ if (retval)
+ return 0;
+ else
+ return -1;
+#else
#if HAVE_FCHMOD
- return fchmod(fileno(fp), S_IRUSR|S_IWUSR);
+ if (fp)
+ return fchmod(fileno(fp), S_IRUSR|S_IWUSR);
+ else
#else
- return g_chmod(file, S_IRUSR|S_IWUSR);
+ return g_chmod(file, S_IRUSR|S_IWUSR);
+#endif
#endif
}