diff options
author | Marc Laukien <marc@zeroc.com> | 2002-04-04 15:40:24 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2002-04-04 15:40:24 +0000 |
commit | b5086e9be0baa8e5a2268fb6fe53ea6a0f8558a6 (patch) | |
tree | e41d34d1be3f7e21670cf831a4d9e0cf8c3fc8b9 /cpp/src/IcePatch/NodeI.cpp | |
parent | more IcePatch stuff (diff) | |
download | ice-b5086e9be0baa8e5a2268fb6fe53ea6a0f8558a6.tar.bz2 ice-b5086e9be0baa8e5a2268fb6fe53ea6a0f8558a6.tar.xz ice-b5086e9be0baa8e5a2268fb6fe53ea6a0f8558a6.zip |
more IcePatch stuff
Diffstat (limited to 'cpp/src/IcePatch/NodeI.cpp')
-rw-r--r-- | cpp/src/IcePatch/NodeI.cpp | 110 |
1 files changed, 18 insertions, 92 deletions
diff --git a/cpp/src/IcePatch/NodeI.cpp b/cpp/src/IcePatch/NodeI.cpp index d0c8635b456..ed3c3a11947 100644 --- a/cpp/src/IcePatch/NodeI.cpp +++ b/cpp/src/IcePatch/NodeI.cpp @@ -9,8 +9,7 @@ // ********************************************************************** #include <IcePatch/NodeI.h> -#include <IcePatch/NodeUtil.h> -#include <dirent.h> +#include <IcePatch/Util.h> using namespace std; using namespace Ice; @@ -21,36 +20,6 @@ IcePatch::NodeI::NodeI(const ObjectAdapterPtr& adapter) : { } -string -IcePatch::NodeI::normalizePath(const string& path) -{ - string result = path; - - string::size_type pos; - - for (pos = 0; pos < result.size(); ++pos) - { - if (result[pos] == '\\') - { - result[pos] = '/'; - } - } - - pos = 0; - while ((pos = result.find("//", pos)) != string::npos) - { - result.erase(pos, 1); - } - - pos = 0; - while ((pos = result.find("/./", pos)) != string::npos) - { - result.erase(pos, 2); - } - - return result; -} - IcePatch::DirectoryI::DirectoryI(const ObjectAdapterPtr& adapter) : NodeI(adapter) { @@ -67,76 +36,35 @@ IcePatch::DirectoryI::describe(const Ice::Current& current) NodeDescSeq IcePatch::DirectoryI::getContents(const Ice::Current& current) { - string path = normalizePath(current.identity.name); - - 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; - } + StringSeq paths = readDirectory(identityToPath(current.identity)); NodeDescSeq result; - result.reserve(n - 2); + result.reserve(paths.size()); - int i; - - try + StringSeq::const_iterator p; + for (p = paths.begin(); p != paths.end(); ++p) { - Identity identity; - identity.category = "IcePatch"; - - for (i = 0; i < n; ++i) + string::size_type pos; + if ((pos = p->rfind(".md5")) != string::npos) { - string name = namelist[i]->d_name; - - if (name == ".." || name == ".") + if (p->size() == pos + 4) { continue; } - - string::size_type pos; - if ((pos = name.rfind(".md5")) != string::npos) - { - if (name.size() == pos + 4) - { - continue; - } - } - - 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) + + NodePrx node = NodePrx::uncheckedCast(_adapter->createProxy(pathToIdentity(*p))); + try { - free(namelist[i]); + result.push_back(node->describe()); } - free(namelist); - - } - catch (...) - { - for (i = 0; i < n; ++i) + catch (const ObjectNotExistException&) { - free(namelist[i]); + // + // Ignore. This can for example happen if the node + // locator cannot call stat() on the file. + // } - free(namelist); - - throw; } return result; @@ -152,14 +80,12 @@ IcePatch::FileI::describe(const Ice::Current& current) { FileDescPtr desc = new FileDesc; desc->file = FilePrx::uncheckedCast(_adapter->createProxy(current.identity)); - string path = normalizePath(current.identity.name); - desc->md5 = getMD5(path); + desc->md5 = getMD5(identityToPath(current.identity)); return desc; } ByteSeq IcePatch::FileI::getBytes(Int startPos, Int howMuch, const Ice::Current& current) { - string path = normalizePath(current.identity.name); return ByteSeq(); } |