From 71cc3ceae5c5dd97a0faa2dab3da3dd0c479b0b5 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 17 Jul 2003 11:25:14 +0000 Subject: [PATCH] * Preserve the executable bit. --- src/archive.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/archive.cc b/src/archive.cc index c9b78824e..73fc75fa2 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); }