diff options
author | Marc Laukien <marc@zeroc.com> | 2002-04-03 22:52:39 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-04-03 22:52:39 +0000 |
commit | 96d03c0016f3fb063c77007480171a7785c51c24 (patch) | |
tree | 5c604c07665e48603602da6bc260a53316629e43 /cpp/src/IcePatch/NodeI.cpp | |
parent | started with IcePatch (diff) | |
download | ice-96d03c0016f3fb063c77007480171a7785c51c24.tar.bz2 ice-96d03c0016f3fb063c77007480171a7785c51c24.tar.xz ice-96d03c0016f3fb063c77007480171a7785c51c24.zip |
more IcePatch work
Diffstat (limited to 'cpp/src/IcePatch/NodeI.cpp')
-rw-r--r-- | cpp/src/IcePatch/NodeI.cpp | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/cpp/src/IcePatch/NodeI.cpp b/cpp/src/IcePatch/NodeI.cpp index 0c41b31f562..0f0de1006fc 100644 --- a/cpp/src/IcePatch/NodeI.cpp +++ b/cpp/src/IcePatch/NodeI.cpp @@ -9,11 +9,17 @@ // ********************************************************************** #include <IcePatch/NodeI.h> +#include <dirent.h> using namespace std; using namespace Ice; using namespace IcePatch; +IcePatch::NodeI::NodeI(const ObjectAdapterPtr& adapter) : + _adapter(adapter) +{ +} + string IcePatch::NodeI::normalizePath(const string& path) { @@ -44,6 +50,11 @@ IcePatch::NodeI::normalizePath(const string& path) return result; } +IcePatch::DirectoryI::DirectoryI(const ObjectAdapterPtr& adapter) : + NodeI(adapter) +{ +} + Nodes IcePatch::DirectoryI::getNodes(const Ice::Current& current) { @@ -54,9 +65,36 @@ IcePatch::DirectoryI::getNodes(const Ice::Current& current) string path = normalizePath(current.identity.name); - return Nodes(); + struct dirent **namelist; + int n = scandir(path.c_str(), &namelist, 0, alphasort); + if (n < 0) + { + NodeAccessException ex; + ex.reason = "cannot read directory `" + path + "':" + strerror(errno); + throw ex; + } + + Nodes result; + result.reserve(n); + + Identity identity; + identity.category = "IcePatch"; + + while(n--) + { + identity.name = namelist[n]->d_name; + free(namelist[n]); + result.push_back(NodePrx::uncheckedCast(_adapter->createProxy(identity))); + } + free(namelist); + + return result; } +IcePatch::FileI::FileI(const ObjectAdapterPtr& adapter) : + NodeI(adapter) +{ +} ByteSeq IcePatch::FileI::getBytes(Int startPos, Int howMuch, const Ice::Current& current) { |