5 #include "EntryIterator.h"
9 EntryIterator::EntryIterator(Directory
*directory
)
10 : fDirectory(directory
),
19 EntryIterator::~EntryIterator()
26 EntryIterator::SetTo(Directory
*directory
)
29 status_t error
= (directory
? B_OK
: B_BAD_VALUE
);
31 fDirectory
= directory
;
42 EntryIterator::Unset()
44 if (fDirectory
&& fSuspended
)
55 EntryIterator::Suspend()
57 status_t error
= (fDirectory
? B_OK
: B_ERROR
);
59 if (fDirectory
->GetVolume()->IteratorLock()) {
62 fEntry
->AttachEntryIterator(this);
63 fDirectory
->GetVolume()->IteratorUnlock();
75 EntryIterator::Resume()
77 status_t error
= (fDirectory
? B_OK
: B_ERROR
);
79 if (fDirectory
->GetVolume()->IteratorLock()) {
82 fEntry
->DetachEntryIterator(this);
85 fDirectory
->GetVolume()->IteratorUnlock();
94 EntryIterator::GetNext(Entry
**entry
)
96 status_t error
= B_ENTRY_NOT_FOUND
;
97 if (!fDone
&& fDirectory
&& entry
) {
103 error
= fDirectory
->GetNextEntry(&fEntry
);
106 fDone
= (error
!= B_OK
);
112 EntryIterator::Rewind()
114 status_t error
= (fDirectory
? B_OK
: B_ERROR
);
116 if (fDirectory
->GetVolume()->IteratorLock()) {
117 if (fSuspended
&& fEntry
)
118 fEntry
->DetachEntryIterator(this);
122 fDirectory
->GetVolume()->IteratorUnlock();
131 EntryIterator::SetCurrent(Entry
*entry
, bool isNext
)