summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin C. Pierce <bcpierce@cis.upenn.edu>2005-09-26 19:46:19 +0000
committerBenjamin C. Pierce <bcpierce@cis.upenn.edu>2005-09-26 19:46:19 +0000
commit7520fda5f01f5f640eab61d074211e1b90c25f4e (patch)
treea19e1f2295613fb79cb5e464f2f4f53e723f4029
parent825948b65f786849129f64deebcb182e5ecf2c4c (diff)
downloadunison-7520fda5f01f5f640eab61d074211e1b90c25f4e.zip
unison-7520fda5f01f5f640eab61d074211e1b90c25f4e.tar.gz
unison-7520fda5f01f5f640eab61d074211e1b90c25f4e.tar.bz2
* Incorporated old patch to set read-only file to R/W on OSX before
attempting to change other attributes, per discussion on unison-hackers list.
-rw-r--r--src/RECENTNEWS11
-rw-r--r--src/mkProjectInfo.ml1
-rw-r--r--src/osxsupport.c17
3 files changed, 29 insertions, 0 deletions
diff --git a/src/RECENTNEWS b/src/RECENTNEWS
index 234bed8..fbaf03b 100644
--- a/src/RECENTNEWS
+++ b/src/RECENTNEWS
@@ -1,8 +1,19 @@
+CHANGES FROM VERSION 2.17.5
+
+* Incorporated old patch to set read-only file to R/W on OSX before
+ attempting to change other attributes, per discussion on
+ unison-hackers list.
+
+-------------------------------
CHANGES FROM VERSION 2.17.4
Mac GUI: enable/disable synchronize and restart buttons
and menu items as appropriate. Thanks to Ben Willmore.
+* Incorporated old patch to set read-only file to R/W on OSX before
+ attempting to change other attributes, per discussion on
+ unison-hackers list.
+
-------------------------------
CHANGES FROM VERSION 2.17.3
diff --git a/src/mkProjectInfo.ml b/src/mkProjectInfo.ml
index 27b7b8a..6ec0c9b 100644
--- a/src/mkProjectInfo.ml
+++ b/src/mkProjectInfo.ml
@@ -71,3 +71,4 @@ Printf.printf "NAME=%s\n" projectName;;
+
diff --git a/src/osxsupport.c b/src/osxsupport.c
index 141e225..1a18dec 100644
--- a/src/osxsupport.c
+++ b/src/osxsupport.c
@@ -6,6 +6,8 @@
#include <caml/alloc.h>
#include <caml/memory.h>
#ifdef __APPLE__
+#include <sys/types.h>
+#include <sys/stat.h>
#include <sys/attr.h>
#include <unistd.h>
#include <stdio.h>
@@ -100,6 +102,21 @@ CAMLprim value setFileInfos (value path, value fInfo) {
retcode = setattrlist(String_val (path), &attrList, attrBuf.finderInfo,
sizeof attrBuf.finderInfo, options);
+ if (retcode == -1 && errno == EACCES) {
+ /* Unlike with normal Unix attributes, we cannot set OS X attributes
+ if file is read-only. Try making it writable temporarily. */
+ struct stat st;
+ int r = stat(String_val(path), &st);
+ if (r == -1) uerror("setattrlist", path);
+ r = chmod(String_val(path), st.st_mode | S_IWUSR);
+ if (r == -1) uerror("setattrlist", path);
+ /* Try again */
+ retcode = setattrlist(String_val (path), &attrList, attrBuf.finderInfo,
+ sizeof attrBuf.finderInfo, options);
+ /* Whether or not that worked, we should try to set the mode back. */
+ chmod(String_val(path), st.st_mode);
+ }
+
if (retcode == -1) uerror("setattrlist", path);
CAMLreturn (Val_unit);