summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2004-12-31 04:57:31 +0000
committerMichi Henning <michi@zeroc.com>2004-12-31 04:57:31 +0000
commit4f8a21643abdeceb0e999baab097b1c5d9377f4c (patch)
treea68a5ec5247f6085745fe6bcc14bb70a5fd69c5d /cpp
parentRemoved a bit of trace that got left behind. (diff)
downloadice-4f8a21643abdeceb0e999baab097b1c5d9377f4c.tar.bz2
ice-4f8a21643abdeceb0e999baab097b1c5d9377f4c.tar.xz
ice-4f8a21643abdeceb0e999baab097b1c5d9377f4c.zip
Backed out previous change -- I didn't realize until just now that the file
is always sent in compressed form, even if the compressed file is larger than the original. I agree -- it's simpler that way.
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/IcePatch2/Util.h2
-rw-r--r--cpp/src/IcePatch2/Util.cpp39
2 files changed, 17 insertions, 24 deletions
diff --git a/cpp/include/IcePatch2/Util.h b/cpp/include/IcePatch2/Util.h
index 94c95257e8b..4041838cf69 100644
--- a/cpp/include/IcePatch2/Util.h
+++ b/cpp/include/IcePatch2/Util.h
@@ -38,7 +38,7 @@ ICE_PATCH2_API Ice::StringSeq readDirectory(const std::string&);
ICE_PATCH2_API void createDirectory(const std::string&);
ICE_PATCH2_API void createDirectoryRecursive(const std::string&);
-ICE_PATCH2_API int compressBytesToFile(const std::string&, const Ice::ByteSeq&, Ice::Int, int);
+ICE_PATCH2_API void compressBytesToFile(const std::string&, const Ice::ByteSeq&, Ice::Int);
ICE_PATCH2_API void decompressFile(const std::string&);
struct FileInfoEqual: public std::binary_function<const FileInfo&, const FileInfo&, bool>
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index eaef59a8ddd..0bf6c71106c 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -516,8 +516,8 @@ IcePatch2::createDirectoryRecursive(const string& pa)
}
}
-int
-IcePatch2::compressBytesToFile(const string& pa, const ByteSeq& bytes, Int pos, int compress)
+void
+IcePatch2::compressBytesToFile(const string& pa, const ByteSeq& bytes, Int pos)
{
const string path = normalize(pa);
@@ -566,21 +566,6 @@ IcePatch2::compressBytesToFile(const string& pa, const ByteSeq& bytes, Int pos,
}
fclose(stdioFile);
-
- struct stat buf;
- if(stat(path.c_str(), &buf) == -1)
- {
- throw "cannot stat `" + path + "':\n" + lastError();
- }
- if(compress == 1) // Use compressed file only if it is smaller.
- {
- if(static_cast<ByteSeq::size_type>(buf.st_size) >= bytes.size() - pos)
- {
- remove(path);
- return 0;
- }
- }
- return buf.st_size;
}
void
@@ -792,17 +777,25 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G
//
if(compress > 0)
{
- if(compress >= 2 && cb && !cb->compress(relPath))
- {
- return false;
- }
-
string pathBZ2 = path + ".bz2";
struct stat bufBZ2;
+
if(compress >= 2 || stat(pathBZ2.c_str(), &bufBZ2) == -1 || buf.st_mtime >= bufBZ2.st_mtime)
{
- info.size = compressBytesToFile(pathBZ2, bytes, relPath.size(), compress);
+ if(cb && !cb->compress(relPath))
+ {
+ return false;
+ }
+
+ compressBytesToFile(pathBZ2, bytes, relPath.size());
+
+ if(stat(pathBZ2.c_str(), &bufBZ2) == -1)
+ {
+ throw "cannot stat `" + pathBZ2 + "':\n" + lastError();
+ }
}
+
+ info.size = bufBZ2.st_size;
}
}