diff options
author | Mark Spruiell <mes@zeroc.com> | 2010-01-05 20:17:33 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2010-01-05 20:17:33 -0800 |
commit | cf24e681e8c52cd20d81fe750ff258e67ee65734 (patch) | |
tree | 8411820ce3a257272d6ffa0d3dcdab9ce106609a /cpp/demo/book/simple_filesystem/Client.cpp | |
parent | Fixed bug 4576 - add NPTL options only on Rhel4 (diff) | |
download | ice-cf24e681e8c52cd20d81fe750ff258e67ee65734.tar.bz2 ice-cf24e681e8c52cd20d81fe750ff258e67ee65734.tar.xz ice-cf24e681e8c52cd20d81fe750ff258e67ee65734.zip |
bug 4495 - clean up book demos
Diffstat (limited to 'cpp/demo/book/simple_filesystem/Client.cpp')
-rw-r--r-- | cpp/demo/book/simple_filesystem/Client.cpp | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/cpp/demo/book/simple_filesystem/Client.cpp b/cpp/demo/book/simple_filesystem/Client.cpp index 24865abb023..007e4b11cfa 100644 --- a/cpp/demo/book/simple_filesystem/Client.cpp +++ b/cpp/demo/book/simple_filesystem/Client.cpp @@ -26,16 +26,22 @@ listRecursive(const DirectoryPrx& dir, int depth = 0) NodeSeq contents = dir->list(); - for (NodeSeq::const_iterator i = contents.begin(); i != contents.end(); ++i) { + for(NodeSeq::const_iterator i = contents.begin(); i != contents.end(); ++i) + { DirectoryPrx dir = DirectoryPrx::checkedCast(*i); FilePrx file = FilePrx::uncheckedCast(*i); cout << indent << (*i)->name() << (dir ? " (directory):" : " (file):") << endl; - if (dir) { + if(dir) + { listRecursive(dir, depth); - } else { + } + else + { Lines text = file->read(); - for (Lines::const_iterator j = text.begin(); j != text.end(); ++j) + for(Lines::const_iterator j = text.begin(); j != text.end(); ++j) + { cout << indent << "\t" << *j << endl; + } } } } @@ -45,39 +51,59 @@ main(int argc, char* argv[]) { int status = 0; Ice::CommunicatorPtr ic; - try { + try + { + // // Create a communicator // ic = Ice::initialize(argc, argv); + // // Create a proxy for the root directory // Ice::ObjectPrx base = ic->stringToProxy("RootDir:default -p 10000"); - if (!base) - throw "Could not create proxy"; + // // Down-cast the proxy to a Directory proxy // DirectoryPrx rootDir = DirectoryPrx::checkedCast(base); - if (!rootDir) + if(!rootDir) + { throw "Invalid proxy"; + } + // // Recursively list the contents of the root directory // cout << "Contents of root directory:" << endl; listRecursive(rootDir); - } catch (const Ice::Exception & ex) { + } + catch(const Ice::Exception& ex) + { cerr << ex << endl; status = 1; - } catch (const char * msg) { + } + catch(const char* msg) + { cerr << msg << endl; status = 1; } + // // Clean up // - if (ic) - ic->destroy(); + if(ic) + { + try + { + ic->destroy(); + } + catch(const Ice::Exception& e) + { + cerr << e << endl; + status = 1; + } + } return status; } |