1 // Copyright 2018 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include <stdint.h> 6 7 #include <blobfs/format.h> 8 #include <blobfs/iterator/vector-extent-iterator.h> 9 #include <fbl/vector.h> 10 #include <zircon/types.h> 11 12 namespace blobfs { 13 VectorExtentIterator(const fbl::Vector<ReservedExtent> & extents)14VectorExtentIterator::VectorExtentIterator(const fbl::Vector<ReservedExtent>& extents) 15 : extents_(extents) {} 16 Done() const17bool VectorExtentIterator::Done() const { 18 return extent_index_ == extents_.size(); 19 } 20 Next(const Extent ** out)21zx_status_t VectorExtentIterator::Next(const Extent** out) { 22 ZX_DEBUG_ASSERT(!Done()); 23 block_count_ += extents_[extent_index_].extent().Length(); 24 *out = &extents_[extent_index_].extent(); 25 26 extent_index_++; 27 return ZX_OK; 28 } 29 BlockIndex() const30uint64_t VectorExtentIterator::BlockIndex() const { 31 return block_count_; 32 } 33 34 } // namespace blobfs 35