From 434eb8437811a2b5c50c98d5af4b208fed4d37f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 16 Sep 2003 02:34:55 +0000 Subject: [PATCH] Implemented the missing Directory::Lookup() method, since it's now needed during path parsing. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4708 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../file_systems/amiga_ffs/Directory.cpp | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/kernel/boot/loader/file_systems/amiga_ffs/Directory.cpp b/src/kernel/boot/loader/file_systems/amiga_ffs/Directory.cpp index b597dcaec0..569fdccf5e 100644 --- a/src/kernel/boot/loader/file_systems/amiga_ffs/Directory.cpp +++ b/src/kernel/boot/loader/file_systems/amiga_ffs/Directory.cpp @@ -55,10 +55,16 @@ Directory::InitCheck() status_t Directory::Open(void **_cookie, int mode) { - *_cookie = (void *)new HashIterator(fVolume.Device(), fNode); - if (*_cookie == NULL) + HashIterator *iterator = new HashIterator(fVolume.Device(), fNode); + if (iterator == NULL) return B_NO_MEMORY; + if (iterator->InitCheck() != B_OK) { + delete iterator; + return B_NO_MEMORY; + } + + *_cookie = (void *)iterator; return B_OK; } @@ -74,6 +80,31 @@ Directory::Close(void *cookie) Node * Directory::Lookup(const char *name, bool traverseLinks) { + HashIterator iterator(fVolume.Device(), fNode); + if (iterator.InitCheck() != B_OK) + return NULL; + + if (!strcmp(name, ".")) { + Acquire(); + return this; + } + + iterator.Goto(fNode.HashIndexFor(fVolume.Type(), name)); + + NodeBlock *node; + int32 block; + while ((node = iterator.GetNext(block)) != NULL) { + char fileName[FFS_NAME_LENGTH]; + if (node->GetName(fileName, sizeof(fileName)) == B_OK + && !strcmp(name, fileName)) { + if (node->IsFile()) + return new File(fVolume, block); + if (node->IsDirectory()) + return new Directory(fVolume, block); + + return NULL; + } + } return NULL; }