btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / bin / makeudfimage / EmbeddedStream.cpp
blobcd3a5d30423fc47f4e622073073359cedb7626a0
1 //----------------------------------------------------------------------
2 // This software is part of the OpenBeOS distribution and is covered
3 // by the MIT License.
4 //
5 // Copyright (c) 2003 Tyler Dauwalder, tyler@dauwalder.net
6 //----------------------------------------------------------------------
8 /*! \file EmbeddedStream.cpp
9 */
11 #include "EmbeddedStream.h"
13 #include <stdlib.h>
14 #include <string.h>
16 EmbeddedStream::EmbeddedStream(DataStream &stream, off_t offset, size_t size)
17 : SimulatedStream(stream)
18 , fOffset(offset)
19 , fSize(size)
23 /*! \brief Returns the largest extent in the underlying data stream
24 corresponding to the extent starting at byte position \a pos of
25 byte length \a size in the output parameter \a extent.
27 NOTE: If the position is at or beyond the end of the stream, the
28 function will return B_OK, but the value of extent.size will be 0.
30 status_t
31 EmbeddedStream::_GetExtent(off_t pos, size_t size, data_extent &extent)
33 if (pos >= fSize) {
34 // end of stream
35 extent.offset = fOffset + fSize;
36 extent.size = 0;
37 } else {
38 // valid position
39 extent.offset = fOffset + pos;
40 extent.size = fSize - pos;
42 return B_OK;
45 /*! \brief Returns the current size of the stream.
47 off_t
48 EmbeddedStream::_Size()
50 return fSize;