summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-06-07 21:04:49 +0000
committerBram Moolenaar <Bram@vim.org>2005-06-07 21:04:49 +0000
commitc4a06d34471d21532a3e0535e547b3d797992350 (patch)
tree6a902e733791a74bf5340a06b9acaa03913f4041
parent78916d7c3b7e9d599353b9fb71ec7e95b91df913 (diff)
updated for version 7.0082
-rw-r--r--src/misc2.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/misc2.c b/src/misc2.c
index 3450362985..b3ab1f2410 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -5592,3 +5592,41 @@ vimpty_getenv(string)
# endif
#endif /* !defined(HAVE_SETENV) && !defined(HAVE_PUTENV) */
+
+#if defined(FEAT_EVAL) || defined(FEAT_SYN_HL) || defined(PROTO)
+/*
+ * Return 0 for not writable, 1 for writable file, 2 for a dir which we have
+ * rights to write into.
+ */
+ int
+filewritable(fname)
+ char_u *fname;
+{
+ int retval = 0;
+#if defined(UNIX) || defined(VMS)
+ int perm = 0;
+#endif
+
+#if defined(UNIX) || defined(VMS)
+ perm = mch_getperm(fname);
+#endif
+#ifndef MACOS_CLASSIC /* TODO: get either mch_writable or mch_access */
+ if (
+# ifdef WIN3264
+ mch_writable(fname) &&
+# else
+# if defined(UNIX) || defined(VMS)
+ (perm & 0222) &&
+# endif
+# endif
+ mch_access((char *)fname, W_OK) == 0
+ )
+#endif
+ {
+ ++retval;
+ if (mch_isdir(fname))
+ ++retval;
+ }
+ return retval;
+}
+#endif