aboutsummaryrefslogtreecommitdiffstats
path: root/src/fileio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/fileio.c b/src/fileio.c
index c0f6c1d2e8e..3306085491e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2416,15 +2416,27 @@ check_writable (const char *filename)
2416 return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode)); 2416 return (st.st_mode & S_IWRITE || S_ISDIR (st.st_mode));
2417#else /* not MSDOS */ 2417#else /* not MSDOS */
2418#ifdef HAVE_EUIDACCESS 2418#ifdef HAVE_EUIDACCESS
2419 return (euidaccess (filename, 2) >= 0); 2419 int res = (euidaccess (filename, 2) >= 0);
2420#else 2420#ifdef CYGWIN
2421 /* euidaccess may have returned failure because Cygwin couldn't
2422 determine the file's UID or GID; if so, we return success. */
2423 if (!res)
2424 {
2425 struct stat st;
2426 if (stat (filename, &st) < 0)
2427 return 0;
2428 res = (st.st_uid == -1 || st.st_gid == -1);
2429 }
2430#endif /* CYGWIN */
2431 return res;
2432#else /* not HAVE_EUIDACCESS */
2421 /* Access isn't quite right because it uses the real uid 2433 /* Access isn't quite right because it uses the real uid
2422 and we really want to test with the effective uid. 2434 and we really want to test with the effective uid.
2423 But Unix doesn't give us a right way to do it. 2435 But Unix doesn't give us a right way to do it.
2424 Opening with O_WRONLY could work for an ordinary file, 2436 Opening with O_WRONLY could work for an ordinary file,
2425 but would lose for directories. */ 2437 but would lose for directories. */
2426 return (access (filename, 2) >= 0); 2438 return (access (filename, 2) >= 0);
2427#endif 2439#endif /* not HAVE_EUIDACCESS */
2428#endif /* not MSDOS */ 2440#endif /* not MSDOS */
2429} 2441}
2430 2442
@@ -4186,7 +4198,7 @@ variable `last-coding-system-used' to the coding system actually used. */)
4186 /* If REPLACE is non-nil and we succeeded in not replacing the 4198 /* If REPLACE is non-nil and we succeeded in not replacing the
4187 beginning or end of the buffer text with the file's contents, 4199 beginning or end of the buffer text with the file's contents,
4188 call format-decode with `point' positioned at the beginning 4200 call format-decode with `point' positioned at the beginning
4189 of the buffer and `inserted' equalling the number of 4201 of the buffer and `inserted' equaling the number of
4190 characters in the buffer. Otherwise, format-decode might 4202 characters in the buffer. Otherwise, format-decode might
4191 fail to correctly analyze the beginning or end of the buffer. 4203 fail to correctly analyze the beginning or end of the buffer.
4192 Hence we temporarily save `point' and `inserted' here and 4204 Hence we temporarily save `point' and `inserted' here and