From 90b73f5f3ff6dd94cc160cdc3ab4604ac8d90d9a Mon Sep 17 00:00:00 2001 From: Salvatore Benedetto Date: Sat, 9 Aug 2008 08:14:40 +0000 Subject: [PATCH] * Applied our coding guidelines git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26883 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../udf/AllocationDescriptorList.h | 13 +- .../file_systems/udf/DirectoryIterator.cpp | 111 ++++++++---------- .../file_systems/udf/DirectoryIterator.h | 58 ++++----- 3 files changed, 79 insertions(+), 103 deletions(-) diff --git a/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h b/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h index 6fd42e0454..f7bd94a49d 100644 --- a/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h +++ b/src/add-ons/kernel/file_systems/udf/AllocationDescriptorList.h @@ -53,17 +53,16 @@ private: void _Rewind(); void _WalkContinuationChain(Descriptor *descriptor); + Accessor fAccessor; CachedBlock fAdditionalDescriptors; + off_t fBlockIndex; + int32 fDescriptorIndex; + int32 fDescriptorNumber; Icb *fIcb; Descriptor *fIcbDescriptors; int32 fIcbDescriptorsSize; bool fReadFromIcb; Volume *fVolume; - - Accessor fAccessor; - int32 fDescriptorIndex; - int32 fDescriptorNumber; - off_t fBlockIndex; }; @@ -74,10 +73,10 @@ AllocationDescriptorList::AllocationDescriptorList(Icb *icb, fAccessor(accessor), fAdditionalDescriptors(icb->GetVolume()), fBlockIndex(0), - fIcb(icb), - fIcbDescriptors((Descriptor *)icb->AllocationDescriptors()), fDescriptorIndex(0), fDescriptorNumber(0), + fIcb(icb), + fIcbDescriptors((Descriptor *)icb->AllocationDescriptors()), fIcbDescriptorsSize(icb->AllocationDescriptorsSize()), fReadFromIcb(true), fVolume(icb->GetVolume()) diff --git a/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp b/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp index 91f6e7f2ce..c55c7bd5eb 100644 --- a/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp +++ b/src/add-ons/kernel/file_systems/udf/DirectoryIterator.cpp @@ -1,24 +1,19 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2003, Tyler Dauwalder, tyler@dauwalder.net. + * Distributed under the terms of the MIT License. + */ -/*! \file DirectoryIterator.cpp -*/ +/*! \file DirectoryIterator.cpp */ #include "DirectoryIterator.h" +#include "Icb.h" +#include "UdfString.h" +#include "Utils.h" + #include #include -#include "Icb.h" - -#include "UdfString.h" -#include "Utils.h" - -using namespace Udf; status_t DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id) @@ -32,7 +27,6 @@ DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id) PRINT(("fPosition: %Ld\n", fPosition)); PRINT(("Parent()->Length(): %Ld\n", Parent()->Length())); - status_t error = B_OK; if (fAtBeginning) { sprintf(name, "."); @@ -41,65 +35,62 @@ DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id) fAtBeginning = false; } else { - if (uint64(fPosition) >= Parent()->Length()) - RETURN(B_ENTRY_NOT_FOUND); + if (uint64(fPosition) >= Parent()->Length()) + RETURN(B_ENTRY_NOT_FOUND); - uint8 data[kMaxFileIdSize]; - file_id_descriptor *entry = reinterpret_cast(data); + uint8 data[kMaxFileIdSize]; + file_id_descriptor *entry = reinterpret_cast(data); - uint32 block = 0; - off_t offset = fPosition; + uint32 block = 0; + off_t offset = fPosition; - size_t entryLength = kMaxFileIdSize; - // First read in the static portion of the file id descriptor, - // then, based on the information therein, read in the variable - // length tail portion as well. - error = Parent()->Read(offset, entry, &entryLength, &block); - if (!error && entryLength >= sizeof(file_id_descriptor) && entry->tag().init_check(block) == B_OK) { - PDUMP(entry); - offset += entry->total_length(); - - if (entry->is_parent()) { - sprintf(name, ".."); - *length = 3; - } else { - String string(entry->id(), entry->id_length()); - PRINT(("id == `%s'\n", string.Utf8())); - DUMP(entry->icb()); - sprintf(name, "%s", string.Utf8()); - *length = string.Utf8Length(); - } - *id = to_vnode_id(entry->icb()); - } + size_t entryLength = kMaxFileIdSize; + // First read in the static portion of the file id descriptor, + // then, based on the information therein, read in the variable + // length tail portion as well. + error = Parent()->Read(offset, entry, &entryLength, &block); + if (!error && entryLength >= sizeof(file_id_descriptor) + && entry->tag().init_check(block) == B_OK) { + PDUMP(entry); + offset += entry->total_length(); - if (!error) - fPosition = offset; + if (entry->is_parent()) { + sprintf(name, ".."); + *length = 3; + } else { + UdfString string(entry->id(), entry->id_length()); + PRINT(("id == `%s'\n", string.Utf8())); + DUMP(entry->icb()); + sprintf(name, "%s", string.Utf8()); + *length = string.Utf8Length(); + } + *id = to_vnode_id(entry->icb()); + } + + if (!error) + fPosition = offset; } - + RETURN(error); } -/* \brief Rewinds the iterator to point to the first - entry in the directory. -*/ + +/* \brief Rewinds the iterator to point to the first entry in the directory. */ void DirectoryIterator::Rewind() { - fPosition = 0; fAtBeginning = true; + fPosition = 0; } + +// #pragma - Private methods + + DirectoryIterator::DirectoryIterator(Icb *parent) - : fParent(parent) - , fPosition(0) - , fAtBeginning(true) + : + fAtBeginning(true), + fParent(parent), + fPosition(0) { } - -void -DirectoryIterator::Invalidate() -{ - fParent = NULL; -} - - diff --git a/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h b/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h index 265eef5aa0..85283e461e 100644 --- a/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h +++ b/src/add-ons/kernel/file_systems/udf/DirectoryIterator.h @@ -1,54 +1,40 @@ -//---------------------------------------------------------------------- -// This software is part of the Haiku distribution and is covered -// by the MIT license. -// -// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net -//--------------------------------------------------------------------- +/* + * Copyright 2003, Tyler Dauwalder, tyler@dauwalder.net. + * Distributed under the terms of the MIT License. + */ #ifndef _UDF_DIRECTORY_ITERATOR_H #define _UDF_DIRECTORY_ITERATOR_H -/*! \file DirectoryIterator.h -*/ +/*! \file DirectoryIterator.h */ -#ifndef _IMPEXP_KERNEL -# define _IMPEXP_KERNEL -#endif -#ifdef COMPILE_FOR_R5 -extern "C" { -#endif - #include "fsproto.h" -#ifdef COMPILE_FOR_R5 -} -#endif - -#include "kernel_cpp.h" #include "UdfDebug.h" -namespace Udf { +#include class Icb; class DirectoryIterator { public: - status_t GetNextEntry(char *name, uint32 *length, ino_t *id); - void Rewind(); - - Icb* Parent() { return fParent; } - const Icb* Parent() const { return fParent; } - + status_t GetNextEntry(char *name, uint32 *length, + ino_t *id); + + Icb *Parent() { return fParent; } + const Icb *Parent() const { return fParent; } + + void Rewind(); + private: - friend class Icb; +friend class Icb; - DirectoryIterator(); // unimplemented - DirectoryIterator(Icb *parent); // called by Icb::GetDirectoryIterator() - void Invalidate(); // called by Icb::~Icb() + /* The following is called by Icb::GetDirectoryIterator() */ + DirectoryIterator(Icb *parent); + /* The following is called by Icb::~Icb() */ + void _Invalidate() { fParent = NULL; } - Icb *fParent; - off_t fPosition; - bool fAtBeginning; + bool fAtBeginning; + Icb *fParent; + off_t fPosition; }; -}; // namespace Udf - #endif // _UDF_DIRECTORY_ITERATOR_H