about summary refs log tree commit diff
path: root/src/archive.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-07-17T11·25+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-07-17T11·25+0000
commit71cc3ceae5c5dd97a0faa2dab3da3dd0c479b0b5 (patch)
treefcbc8dc5409e1a7202b6bebc76782825da7ba9fa /src/archive.cc
parent54664b6fb74e964d70530d13e25459751d0c63fb (diff)
* Preserve the executable bit.
Diffstat (limited to 'src/archive.cc')
-rw-r--r--src/archive.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/archive.cc b/src/archive.cc
index c9b78824e7..73fc75fa27 100644
--- a/src/archive.cc
+++ b/src/archive.cc
@@ -119,6 +119,10 @@ static void dump(const string & path, DumpSink & sink)
     if (S_ISREG(st.st_mode)) {
         writeString("type", sink);
         writeString("regular", sink);
+        if (st.st_mode & S_IXUSR) {
+            writeString("executable", sink);
+            writeString("", sink);
+        }
         dumpContents(path, st.st_size, sink);
     } 
 
@@ -295,6 +299,15 @@ static void restore(const string & path, RestoreSource & source)
             restoreContents(fd, path, source);
         }
 
+        else if (s == "executable" && type == tpRegular) {
+            readString(source);
+            struct stat st;
+            if (fstat(fd, &st) == -1)
+                throw SysError("fstat");
+            if (fchmod(fd, st.st_mode | (S_IXUSR | S_IXGRP | S_IXOTH)) == -1)
+                throw SysError("fchmod");
+        }
+
         else if (s == "entry" && type == tpDirectory) {
             restoreEntry(path, source);
         }