summaryrefslogtreecommitdiff
path: root/cpp/src/IcePatch/Server.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-04-16 23:45:16 +0000
committerMarc Laukien <marc@zeroc.com>2002-04-16 23:45:16 +0000
commitcb721b45d761ccb7fa3bb873e3d567dd665b1f9f (patch)
tree75bd19e8d32751ff178093f47b4ce87e83d4b6d0 /cpp/src/IcePatch/Server.cpp
parentalign with C++ - fixes for the thread pool (diff)
downloadice-cb721b45d761ccb7fa3bb873e3d567dd665b1f9f.tar.bz2
ice-cb721b45d761ccb7fa3bb873e3d567dd665b1f9f.tar.xz
ice-cb721b45d761ccb7fa3bb873e3d567dd665b1f9f.zip
IcePatch improvements; Ice.PrintAdapterReady timing fix
Diffstat (limited to 'cpp/src/IcePatch/Server.cpp')
-rw-r--r--cpp/src/IcePatch/Server.cpp123
1 files changed, 43 insertions, 80 deletions
diff --git a/cpp/src/IcePatch/Server.cpp b/cpp/src/IcePatch/Server.cpp
index fadbf596b95..3f90275cfa4 100644
--- a/cpp/src/IcePatch/Server.cpp
+++ b/cpp/src/IcePatch/Server.cpp
@@ -26,8 +26,7 @@ public:
void usage();
virtual int run(int, char*[]);
- static void removeOrphanedRecursive(const string&);
- static void updateRecursive(const string&);
+ static void cleanup(const FileDescSeq&);
};
};
@@ -88,28 +87,41 @@ IcePatch::Server::run(int argc, char* argv[])
string directory = properties->getProperty(directoryProperty);
if (!directory.empty())
{
- changeDirectory(directory);
+#ifdef _WIN32
+ if (_chdir(directory.c_str()) == -1)
+#else
+ if (chdir(directory.c_str()) == -1)
+#endif
+ {
+ cerr << appName() << ": cannot change to directory `" << directory << "': " << strerror(errno) << endl;
+ }
}
- //
- // Remove orphaned MD5 and BZ2 files.
- // Create MD5 and BZ2 files.
- //
- removeOrphanedRecursive(".");
- updateRecursive(".");
-
//
// Create and initialize the object adapter and the file locator.
//
ObjectAdapterPtr adapter = communicator()->createObjectAdapterFromProperty("IcePatch", endpointsProperty);
ServantLocatorPtr fileLocator = new FileLocator(adapter);
adapter->addServantLocator(fileLocator, "IcePatch");
- adapter->activate();
- //
- // We're done, let's wait for shutdown.
- //
- communicator()->waitForShutdown();
+ //
+ // Do cleanup.
+ //
+ Identity identity = pathToIdentity(".");
+ ObjectPrx topObj = communicator()->stringToProxy(identityToString(identity) + ':' + endpoints);
+ FilePrx top = FilePrx::checkedCast(topObj);
+ assert(top);
+ DirectoryDescPtr topDesc = DirectoryDescPtr::dynamicCast(top->describe());
+ assert(topDesc);
+ cleanup(topDesc->directory->getContents());
+
+ //
+ // Everything ok, let's go.
+ //
+ shutdownOnInterrupt();
+ adapter->activate();
+ communicator()->waitForShutdown();
+ ignoreInterrupt();
}
catch (const FileAccessException& ex)
{
@@ -121,77 +133,28 @@ IcePatch::Server::run(int argc, char* argv[])
}
void
-IcePatch::Server::removeOrphanedRecursive(const string& path)
-{
- assert(getFileInfo(path, true).type == FileTypeDirectory);
-
- StringSeq paths = readDirectory(path);
- StringSeq::const_iterator p;
- for (p = paths.begin(); p != paths.end(); ++p)
- {
- if (ignoreSuffix(*p))
- {
- 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, true).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)
+IcePatch::Server::cleanup(const FileDescSeq& fileDescSeq)
{
- if (ignoreSuffix(path))
+ for (FileDescSeq::const_iterator p = fileDescSeq.begin(); p != fileDescSeq.end(); ++p)
{
- return;
- }
-
- FileInfo info = getFileInfo(path, true);
-
- if (info.type == FileTypeDirectory)
- {
- StringSeq paths = readDirectory(path);
- StringSeq::const_iterator p;
- for (p = paths.begin(); p != paths.end(); ++p)
+ DirectoryDescPtr directoryDesc = DirectoryDescPtr::dynamicCast(*p);
+ if (directoryDesc)
{
- updateRecursive(*p);
+ //
+ // Force .md5 files to be created and orphaned files to be
+ // removed.
+ //
+ cleanup(directoryDesc->directory->getContents());
}
- }
- else if (info.type == FileTypeRegular)
- {
- FileInfo infoMD5 = getFileInfo(path + ".md5", false);
- if (infoMD5.type != FileTypeRegular || infoMD5.time < info.time)
+ else
{
- cout << "creating .md5 file for `" << path << "'... " << flush;
- createMD5(path);
- cout << "ok" << endl;
- }
+ RegularDescPtr regularDesc = RegularDescPtr::dynamicCast(*p);
+ assert(regularDesc);
- FileInfo infoBZ2 = getFileInfo(path + ".bz2", false);
- if (infoBZ2.type != FileTypeRegular || infoBZ2.time < info.time)
- {
- cout << "creating .bz2 file for `" << path << "'... " << flush;
- createBZ2(path);
- cout << "ok" << endl;
+ //
+ // Force .bz2 files to be created.
+ //
+ regularDesc->regular->getBZ2Size();
}
}
}