1 // Copyright 2015 The Chromium 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.
5 #ifndef CHROME_UTILITY_SAFE_BROWSING_MAC_DMG_ITERATOR_H_
6 #define CHROME_UTILITY_SAFE_BROWSING_MAC_DMG_ITERATOR_H_
8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/strings/string16.h"
12 #include "chrome/utility/safe_browsing/mac/udif.h"
14 namespace safe_browsing
{
20 // DMGIterator provides iterator access over all of the concrete files located
21 // on HFS+ and HFSX volumes in a UDIF/DMG file. This class maintains the
22 // limitations of its composed components.
25 // Creates a DMGIterator from a ReadStream. In most cases, this will be a
26 // FileReadStream opened from a DMG file. This does not take ownership
28 explicit DMGIterator(ReadStream
* stream
);
31 // Opens the DMG file for iteration. This must be called before any other
32 // method. If this returns false, it is illegal to call any other methods
33 // on this class. If this returns true, the iterator is advanced to an
34 // invalid element before the first item.
37 // Advances the iterator to the next file item. Returns true on success
38 // and false on end-of-iterator.
41 // Returns the full path in a DMG filesystem to the current file item.
42 base::string16
GetPath();
44 // Returns a ReadStream for the current file item.
45 scoped_ptr
<ReadStream
> GetReadStream();
48 UDIFParser udif_
; // The UDIF parser that accesses the partitions.
49 ScopedVector
<ReadStream
> partitions_
; // Streams for all the HFS partitions.
50 size_t current_partition_
; // The index in |partitions_| of the current one.
51 scoped_ptr
<HFSIterator
> hfs_
; // The HFSIterator for |current_partition_|.
53 DISALLOW_COPY_AND_ASSIGN(DMGIterator
);
57 } // namespace safe_browsing
59 #endif // CHROME_UTILITY_SAFE_BROWSING_MAC_DMG_ITERATOR_H_