1 // StreamUtils.h
2
3 #ifndef ZIP7_INC_STREAM_UTILS_H
4 #define ZIP7_INC_STREAM_UTILS_H
5
6 #include "../IStream.h"
7
InStream_SeekSet(IInStream * stream,UInt64 offset)8 inline HRESULT InStream_SeekSet(IInStream *stream, UInt64 offset) throw()
9 { return stream->Seek((Int64)offset, STREAM_SEEK_SET, NULL); }
InStream_GetPos(IInStream * stream,UInt64 & curPosRes)10 inline HRESULT InStream_GetPos(IInStream *stream, UInt64 &curPosRes) throw()
11 { return stream->Seek(0, STREAM_SEEK_CUR, &curPosRes); }
InStream_GetSize_SeekToEnd(IInStream * stream,UInt64 & sizeRes)12 inline HRESULT InStream_GetSize_SeekToEnd(IInStream *stream, UInt64 &sizeRes) throw()
13 { return stream->Seek(0, STREAM_SEEK_END, &sizeRes); }
14
15 HRESULT InStream_SeekToBegin(IInStream *stream) throw();
16 HRESULT InStream_AtBegin_GetSize(IInStream *stream, UInt64 &size) throw();
17 HRESULT InStream_GetPos_GetSize(IInStream *stream, UInt64 &curPosRes, UInt64 &sizeRes) throw();
18
InStream_GetSize_SeekToBegin(IInStream * stream,UInt64 & sizeRes)19 inline HRESULT InStream_GetSize_SeekToBegin(IInStream *stream, UInt64 &sizeRes) throw()
20 {
21 RINOK(InStream_SeekToBegin(stream))
22 return InStream_AtBegin_GetSize(stream, sizeRes);
23 }
24
25
26 HRESULT ReadStream(ISequentialInStream *stream, void *data, size_t *size) throw();
27 HRESULT ReadStream_FALSE(ISequentialInStream *stream, void *data, size_t size) throw();
28 HRESULT ReadStream_FAIL(ISequentialInStream *stream, void *data, size_t size) throw();
29 HRESULT WriteStream(ISequentialOutStream *stream, const void *data, size_t size) throw();
30
31 #endif
32