* Applied our coding guidelines

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26883 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Salvatore Benedetto 2008-08-09 08:14:40 +00:00
parent d9409b5cda
commit 90b73f5f3f
3 changed files with 79 additions and 103 deletions

View File

@ -53,17 +53,16 @@ private:
void _Rewind(); void _Rewind();
void _WalkContinuationChain(Descriptor *descriptor); void _WalkContinuationChain(Descriptor *descriptor);
Accessor fAccessor;
CachedBlock fAdditionalDescriptors; CachedBlock fAdditionalDescriptors;
off_t fBlockIndex;
int32 fDescriptorIndex;
int32 fDescriptorNumber;
Icb *fIcb; Icb *fIcb;
Descriptor *fIcbDescriptors; Descriptor *fIcbDescriptors;
int32 fIcbDescriptorsSize; int32 fIcbDescriptorsSize;
bool fReadFromIcb; bool fReadFromIcb;
Volume *fVolume; Volume *fVolume;
Accessor fAccessor;
int32 fDescriptorIndex;
int32 fDescriptorNumber;
off_t fBlockIndex;
}; };
@ -74,10 +73,10 @@ AllocationDescriptorList<Accessor>::AllocationDescriptorList(Icb *icb,
fAccessor(accessor), fAccessor(accessor),
fAdditionalDescriptors(icb->GetVolume()), fAdditionalDescriptors(icb->GetVolume()),
fBlockIndex(0), fBlockIndex(0),
fIcb(icb),
fIcbDescriptors((Descriptor *)icb->AllocationDescriptors()),
fDescriptorIndex(0), fDescriptorIndex(0),
fDescriptorNumber(0), fDescriptorNumber(0),
fIcb(icb),
fIcbDescriptors((Descriptor *)icb->AllocationDescriptors()),
fIcbDescriptorsSize(icb->AllocationDescriptorsSize()), fIcbDescriptorsSize(icb->AllocationDescriptorsSize()),
fReadFromIcb(true), fReadFromIcb(true),
fVolume(icb->GetVolume()) fVolume(icb->GetVolume())

View File

@ -1,24 +1,19 @@
//---------------------------------------------------------------------- /*
// This software is part of the Haiku distribution and is covered * Copyright 2003, Tyler Dauwalder, tyler@dauwalder.net.
// by the MIT license. * Distributed under the terms of the MIT License.
// */
// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
//---------------------------------------------------------------------
/*! \file DirectoryIterator.cpp /*! \file DirectoryIterator.cpp */
*/
#include "DirectoryIterator.h" #include "DirectoryIterator.h"
#include "Icb.h"
#include "UdfString.h"
#include "Utils.h"
#include <dirent.h> #include <dirent.h>
#include <stdio.h> #include <stdio.h>
#include "Icb.h"
#include "UdfString.h"
#include "Utils.h"
using namespace Udf;
status_t status_t
DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id) 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(("fPosition: %Ld\n", fPosition));
PRINT(("Parent()->Length(): %Ld\n", Parent()->Length())); PRINT(("Parent()->Length(): %Ld\n", Parent()->Length()));
status_t error = B_OK; status_t error = B_OK;
if (fAtBeginning) { if (fAtBeginning) {
sprintf(name, "."); sprintf(name, ".");
@ -41,65 +35,62 @@ DirectoryIterator::GetNextEntry(char *name, uint32 *length, ino_t *id)
fAtBeginning = false; fAtBeginning = false;
} else { } else {
if (uint64(fPosition) >= Parent()->Length()) if (uint64(fPosition) >= Parent()->Length())
RETURN(B_ENTRY_NOT_FOUND); RETURN(B_ENTRY_NOT_FOUND);
uint8 data[kMaxFileIdSize]; uint8 data[kMaxFileIdSize];
file_id_descriptor *entry = reinterpret_cast<file_id_descriptor*>(data); file_id_descriptor *entry = reinterpret_cast<file_id_descriptor*>(data);
uint32 block = 0; uint32 block = 0;
off_t offset = fPosition; off_t offset = fPosition;
size_t entryLength = kMaxFileIdSize; size_t entryLength = kMaxFileIdSize;
// First read in the static portion of the file id descriptor, // First read in the static portion of the file id descriptor,
// then, based on the information therein, read in the variable // then, based on the information therein, read in the variable
// length tail portion as well. // length tail portion as well.
error = Parent()->Read(offset, entry, &entryLength, &block); error = Parent()->Read(offset, entry, &entryLength, &block);
if (!error && entryLength >= sizeof(file_id_descriptor) && entry->tag().init_check(block) == B_OK) { if (!error && entryLength >= sizeof(file_id_descriptor)
PDUMP(entry); && entry->tag().init_check(block) == B_OK) {
offset += entry->total_length(); 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());
}
if (!error) if (entry->is_parent()) {
fPosition = offset; 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); 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 void
DirectoryIterator::Rewind() DirectoryIterator::Rewind()
{ {
fPosition = 0;
fAtBeginning = true; fAtBeginning = true;
fPosition = 0;
} }
// #pragma - Private methods
DirectoryIterator::DirectoryIterator(Icb *parent) DirectoryIterator::DirectoryIterator(Icb *parent)
: fParent(parent) :
, fPosition(0) fAtBeginning(true),
, fAtBeginning(true) fParent(parent),
fPosition(0)
{ {
} }
void
DirectoryIterator::Invalidate()
{
fParent = NULL;
}

View File

@ -1,54 +1,40 @@
//---------------------------------------------------------------------- /*
// This software is part of the Haiku distribution and is covered * Copyright 2003, Tyler Dauwalder, tyler@dauwalder.net.
// by the MIT license. * Distributed under the terms of the MIT License.
// */
// Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
//---------------------------------------------------------------------
#ifndef _UDF_DIRECTORY_ITERATOR_H #ifndef _UDF_DIRECTORY_ITERATOR_H
#define _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" #include "UdfDebug.h"
namespace Udf { #include <util/kernel_cpp.h>
class Icb; class Icb;
class DirectoryIterator { class DirectoryIterator {
public: public:
status_t GetNextEntry(char *name, uint32 *length, ino_t *id); status_t GetNextEntry(char *name, uint32 *length,
void Rewind(); ino_t *id);
Icb* Parent() { return fParent; } Icb *Parent() { return fParent; }
const Icb* Parent() const { return fParent; } const Icb *Parent() const { return fParent; }
void Rewind();
private: private:
friend class Icb; friend class Icb;
DirectoryIterator(); // unimplemented /* The following is called by Icb::GetDirectoryIterator() */
DirectoryIterator(Icb *parent); // called by Icb::GetDirectoryIterator() DirectoryIterator(Icb *parent);
void Invalidate(); // called by Icb::~Icb() /* The following is called by Icb::~Icb() */
void _Invalidate() { fParent = NULL; }
Icb *fParent; bool fAtBeginning;
off_t fPosition; Icb *fParent;
bool fAtBeginning; off_t fPosition;
}; };
}; // namespace Udf
#endif // _UDF_DIRECTORY_ITERATOR_H #endif // _UDF_DIRECTORY_ITERATOR_H