* 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:
parent
d9409b5cda
commit
90b73f5f3f
@ -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<Accessor>::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())
|
||||
|
@ -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 <dirent.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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<file_id_descriptor*>(data);
|
||||
uint8 data[kMaxFileIdSize];
|
||||
file_id_descriptor *entry = reinterpret_cast<file_id_descriptor*>(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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 <util/kernel_cpp.h>
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user