summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch/Server.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-04-12 15:10:24 +0000
committerMarc Laukien <marc@zeroc.com>2002-04-12 15:10:24 +0000
commit23a9e91ab61541591254d2f8fceb7c1d8e2cbe9e (patch)
treedc57e5457b0d19447c080f7e55c8ac6f9edeae74 /cpp/src/IcePatch/Server.cpp
parentWIN32->_WIN32 (diff)
downloadice-23a9e91ab61541591254d2f8fceb7c1d8e2cbe9e.tar.bz2
ice-23a9e91ab61541591254d2f8fceb7c1d8e2cbe9e.tar.xz
ice-23a9e91ab61541591254d2f8fceb7c1d8e2cbe9e.zip
brought getLocalHost() back; changes to IcePatch (not finished)
Diffstat (limited to 'cpp/src/IcePatch/Server.cpp')
-rw-r--r--cpp/src/IcePatch/Server.cpp95
1 files changed, 89 insertions, 6 deletions
diff --git a/cpp/src/IcePatch/Server.cpp b/cpp/src/IcePatch/Server.cpp
index 3d515aacfd9..9046280762d 100644
--- a/cpp/src/IcePatch/Server.cpp
+++ b/cpp/src/IcePatch/Server.cpp
@@ -25,6 +25,8 @@ public:
void usage();
virtual int run(int, char*[]);
+ void removeOrphanedRecursive(const string&);
+ void updateRecursive(const string&);
};
};
@@ -90,14 +92,10 @@ IcePatch::Server::run(int argc, char* argv[])
//
// Remove orphaned MD5 and BZ2 files.
+ // Create MD5 and BZ2 files.
//
removeOrphanedRecursive(".");
-
- //
- // Create MD5 and BZ2 files.
- //
- createMD5Recursive(".");
- createBZ2Recursive(".");
+ updateRecursive(".");
//
// Create and initialize the object adapter and the node locator.
@@ -121,6 +119,91 @@ IcePatch::Server::run(int argc, char* argv[])
return EXIT_SUCCESS;
}
+void
+IcePatch::Server::removeOrphanedRecursive(const string& path)
+{
+ assert(getFileInfo(path).type == FileTypeDirectory);
+
+ StringSeq paths = readDirectory(path);
+ StringSeq::const_iterator p;
+ for (p = paths.begin(); p != paths.end(); ++p)
+ {
+ string suffix = getSuffix(*p);
+ if (suffix == "md5" || suffix == "bz2")
+ {
+ pair<StringSeq::const_iterator, StringSeq::const_iterator> r =
+ equal_range(paths.begin(), paths.end(), removeSuffix(*p));
+ if (r.first == r.second)
+ {
+ cout << "removing orphaned file `" << *p << "'... " << flush;
+ removeRecursive(*p);
+ cout << "ok" << endl;
+ }
+ }
+ else
+ {
+ if (getFileInfo(*p).type == FileTypeDirectory)
+ {
+ removeOrphanedRecursive(*p);
+ }
+ }
+ }
+
+ if (readDirectory(path).empty())
+ {
+ cout << "removing empty directory `" << *p << "'... " << flush;
+ removeRecursive(path);
+ cout << "ok" << endl;
+ }
+}
+
+void
+IcePatch::Server::updateRecursive(const string& path)
+{
+ string suffix = getSuffix(path);
+ if (suffix == "md5" || suffix == "bz2")
+ {
+ return;
+ }
+
+ if (pathToName(path) == tmpName)
+ {
+ return;
+ }
+
+ FileInfo info = getFileInfo(path);
+
+ if (info.type == FileTypeDirectory)
+ {
+ StringSeq paths = readDirectory(path);
+ StringSeq::const_iterator p;
+ for (p = paths.begin(); p != paths.end(); ++p)
+ {
+ updateRecursive(*p);
+ }
+ }
+ else if (info.type == FileTypeRegular)
+ {
+ string pathMD5 = path + ".md5";
+ FileInfo infoMD5 = getFileInfo(pathMD5);
+ if (infoMD5.type != FileTypeRegular || infoMD5.time < info.time)
+ {
+ cout << "creating .md5 file for `" << path << "'... " << flush;
+ createMD5(pathMD5);
+ cout << "ok" << endl;
+ }
+
+ string pathBZ2 = path + ".bz2";
+ FileInfo infoBZ2 = getFileInfo(pathBZ2);
+ if (infoBZ2.type != FileTypeRegular || infoBZ2.time < info.time)
+ {
+ cout << "creating .bz2 file for `" << path << "'... " << flush;
+ createBZ2(pathBZ2);
+ cout << "ok" << endl;
+ }
+ }
+}
+
int
main(int argc, char* argv[])
{