diff options
author | Marc Laukien <marc@zeroc.com> | 2002-04-04 01:14:48 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-04-04 01:14:48 +0000 |
commit | 19c25b1c91eca6009439f7d8b2f9b81ea47444e0 (patch) | |
tree | ac5f2dda561f2e475c2f2528b8f78be1571d390d /cpp/src/IcePatch/NodeI.cpp | |
parent | more IcePatch stuff (diff) | |
download | ice-19c25b1c91eca6009439f7d8b2f9b81ea47444e0.tar.bz2 ice-19c25b1c91eca6009439f7d8b2f9b81ea47444e0.tar.xz ice-19c25b1c91eca6009439f7d8b2f9b81ea47444e0.zip |
more IcePatch stuff
Diffstat (limited to 'cpp/src/IcePatch/NodeI.cpp')
-rw-r--r-- | cpp/src/IcePatch/NodeI.cpp | 84 |
1 files changed, 63 insertions, 21 deletions
diff --git a/cpp/src/IcePatch/NodeI.cpp b/cpp/src/IcePatch/NodeI.cpp index 77deba89b7a..4a3c0ed1b7e 100644 --- a/cpp/src/IcePatch/NodeI.cpp +++ b/cpp/src/IcePatch/NodeI.cpp @@ -9,6 +9,9 @@ // ********************************************************************** #include <IcePatch/NodeI.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #include <dirent.h> using namespace std; @@ -55,14 +58,17 @@ IcePatch::DirectoryI::DirectoryI(const ObjectAdapterPtr& adapter) : { } -Nodes -IcePatch::DirectoryI::getNodes(const Ice::Current& current) +NodeDescPtr +IcePatch::DirectoryI::describe(const Ice::Current& current) { - // - // No synchronization necessary, this servant is completely - // stateless. - // + DirectoryDescPtr desc = new DirectoryDesc; + desc->directory = DirectoryPrx::uncheckedCast(_adapter->createProxy(current.identity)); + return desc; +} +NodeDescSeq +IcePatch::DirectoryI::getContents(const Ice::Current& current) +{ string path = normalizePath(current.identity.name); struct dirent **namelist; @@ -74,23 +80,56 @@ IcePatch::DirectoryI::getNodes(const Ice::Current& current) throw ex; } - Nodes result; + NodeDescSeq result; result.reserve(n - 2); - Identity identity; - identity.category = "IcePatch"; + int i; - while(n--) + try { - if (strcmp(namelist[n]->d_name, "..") != 0 && strcmp(namelist[n]->d_name, ".") != 0) + Identity identity; + identity.category = "IcePatch"; + + for (i = 0; i < n; ++i) + { + string name = namelist[i]->d_name; + + if (name != ".." && name != ".") + { + identity.name = path + '/' + name; + NodePrx node = NodePrx::uncheckedCast(_adapter->createProxy(identity)); + try + { + result.push_back(node->describe()); + } + catch (const ObjectNotExistException&) + { + // + // Ignore. This can for example happen if the node + // locator cannot call stat() on the file. + // + } + } + } + + for (i = 0; i < n; ++i) { - identity.name = path + '/' + namelist[n]->d_name; - result.push_back(NodePrx::uncheckedCast(_adapter->createProxy(identity))); + free(namelist[i]); } - free(namelist[n]); + free(namelist); + } - free(namelist); + catch (...) + { + for (i = 0; i < n; ++i) + { + free(namelist[i]); + } + free(namelist); + throw; + } + return result; } @@ -98,15 +137,18 @@ IcePatch::FileI::FileI(const ObjectAdapterPtr& adapter) : NodeI(adapter) { } + +NodeDescPtr +IcePatch::FileI::describe(const Ice::Current& current) +{ + FileDescPtr desc = new FileDesc; + desc->file = FilePrx::uncheckedCast(_adapter->createProxy(current.identity)); + return desc; +} + ByteSeq IcePatch::FileI::getBytes(Int startPos, Int howMuch, const Ice::Current& current) { - // - // No synchronization necessary, this servant is completely - // stateless. - // - string path = normalizePath(current.identity.name); - return ByteSeq(); } |