summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch2/Util.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2005-08-26 10:57:14 +0000
committerBenoit Foucher <benoit@zeroc.com>2005-08-26 10:57:14 +0000
commit7517883e56547e284826802174b83ffe36a03d59 (patch)
tree6487620c9b4812d18e2b80b2663ac7bb47b1a3ce /cpp/src/IcePatch2/Util.cpp
parentFix for http://www.zeroc.com/vbulletin/showthread.php?t=1612 (diff)
downloadice-7517883e56547e284826802174b83ffe36a03d59.tar.bz2
ice-7517883e56547e284826802174b83ffe36a03d59.tar.xz
ice-7517883e56547e284826802174b83ffe36a03d59.zip
Added support for 'executable' flag.
Diffstat (limited to 'cpp/src/IcePatch2/Util.cpp')
-rw-r--r--cpp/src/IcePatch2/Util.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index 9d293a11f4a..71af38368ae 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -712,6 +712,18 @@ IcePatch2::decompressFile(const string& pa)
}
fclose(stdioFileBZ2);
+};
+
+void
+IcePatch2::setFileFlags(const string& pa, const FileInfo& info)
+{
+ const string path = simplify(pa);
+ struct stat buf;
+ if(stat(path.c_str(), &buf) == -1)
+ {
+ throw "cannot stat `" + path + "':\n" + lastError();
+ }
+ chmod(path.c_str(), info.executable ? buf.st_mode | S_IXUSR : buf.st_mode & ~S_IXUSR);
}
static bool
@@ -781,6 +793,7 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G
FileInfo info;
info.path = relPath;
info.size = -1;
+ info.executable = false;
ByteSeq bytes(relPath.size());
copy(relPath.begin(), relPath.end(), bytes.begin());
@@ -813,6 +826,7 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G
FileInfo info;
info.path = relPath;
info.size = 0;
+ info.executable = buf.st_mode & S_IXUSR;
ByteSeq bytes(relPath.size() + buf.st_size);
copy(relPath.begin(), relPath.end(), bytes.begin());
@@ -1076,12 +1090,13 @@ IcePatch2::getFileTree0(const FileInfoSeq& infoSeq, FileTree0& tree0)
}
ByteSeq allChecksums1;
- allChecksums1.resize(tree1.files.size() * 20);
+ allChecksums1.resize(tree1.files.size() * 21); // 20 bytes for the checksum + 1 byte for the flag
ByteSeq::iterator c1 = allChecksums1.begin();
-
- for(p = tree1.files.begin(); p != tree1.files.end(); ++p, c1 += 20)
+
+ for(p = tree1.files.begin(); p != tree1.files.end(); ++p, c1 += 21)
{
copy(p->checksum.begin(), p->checksum.end(), c1);
+ *(c1 + 20) = p->executable;
}
if(!allChecksums1.empty())
@@ -1111,7 +1126,10 @@ IcePatch2::getFileTree0(const FileInfoSeq& infoSeq, FileTree0& tree0)
ostream&
IcePatch2::operator<<(ostream& os, const FileInfo& info)
{
- os << IceUtil::escapeString(info.path, "") << '\t' << bytesToString(info.checksum) << '\t' << info.size;
+ os << IceUtil::escapeString(info.path, "") << '\t'
+ << bytesToString(info.checksum) << '\t'
+ << info.size << '\t'
+ << info.executable;
return os;
}
@@ -1126,8 +1144,10 @@ IcePatch2::operator>>(istream& is, FileInfo& info)
getline(is, s, '\t');
info.checksum = stringToBytes(s);
- getline(is, s, '\n');
- info.size = atoi(s.c_str());
+ is >> info.size;
+ is >> info.executable;
+
+ getline(is, s); // Read until the EOL
return is;
}