diff options
author | Marc Laukien <marc@zeroc.com> | 2002-04-04 18:49:29 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-04-04 18:49:29 +0000 |
commit | 146e6a31d51916c2783701cff2c197c34b0e4eee (patch) | |
tree | 1564e98db7cd3c9e564cabbfa26cba94977e19b4 /cpp/src/IcePatch/Util.cpp | |
parent | more IcePatch stuff (diff) | |
download | ice-146e6a31d51916c2783701cff2c197c34b0e4eee.tar.bz2 ice-146e6a31d51916c2783701cff2c197c34b0e4eee.tar.xz ice-146e6a31d51916c2783701cff2c197c34b0e4eee.zip |
more IcePatch stuff
Diffstat (limited to 'cpp/src/IcePatch/Util.cpp')
-rw-r--r-- | cpp/src/IcePatch/Util.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/cpp/src/IcePatch/Util.cpp b/cpp/src/IcePatch/Util.cpp index 5934584cd93..04d275f14b5 100644 --- a/cpp/src/IcePatch/Util.cpp +++ b/cpp/src/IcePatch/Util.cpp @@ -16,6 +16,7 @@ #include <fcntl.h> #include <dirent.h> #include <openssl/md5.h> +#include <bzlib.h> using namespace std; using namespace Ice; @@ -418,3 +419,68 @@ IcePatch::MD5ToString(const ByteSeq& md5) return out.str(); } + +ByteSeq +IcePatch::getBZ2(const string& path, Int n) +{ + // + // Stat the file to get a bzip2 file for. + // + struct stat buf; + if (::stat(path.c_str(), &buf) == -1) + { + NodeAccessException ex; + ex.reason = "cannot stat `" + path + "':" + strerror(errno); + throw ex; + } + else + { + if (!S_ISREG(buf.st_mode)) + { + NodeAccessException ex; + ex.reason = "`" + path + "' is not a regular file"; + throw ex; + } + } + + // + // Stat the .bz2 file. If it doesn't exist, or if it's outdated, + // set a flag to create a new bzip2 file. + // + struct stat bufbz2; + string pathbz2 = path + ".bz2"; + bool createbz2 = false; + if (::stat(pathbz2.c_str(), &bufbz2) == -1) + { + if (errno == ENOENT) + { + createbz2 = true; + } + else + { + NodeAccessException ex; + ex.reason = "cannot stat `" + path + "':" + strerror(errno); + throw ex; + } + } + else + { + if (!S_ISREG(bufbz2.st_mode)) + { + NodeAccessException ex; + ex.reason = "`" + path + "' is not a regular file"; + throw ex; + } + + if (bufbz2.st_mtime <= buf.st_mtime) + { + createbz2 = true; + } + } + + if (createbz2) + { + } + + return ByteSeq(); +} |