CMS 3D CMS Logo

Functions
7zStream.cc File Reference
#include <cstring>
#include "Types.h"

Go to the source code of this file.

Functions

SRes LookInStream_LookRead (ILookInStream *stream, void *buf, size_t *size)
 
SRes LookInStream_Read (ILookInStream *stream, void *buf, size_t size)
 
SRes LookInStream_Read2 (ILookInStream *stream, void *buf, size_t size, SRes errorType)
 
SRes LookInStream_SeekTo (ILookInStream *stream, UInt64 offset)
 
void LookToRead_CreateVTable (CLookToRead *p, int lookahead)
 
void LookToRead_Init (CLookToRead *p)
 
static SRes LookToRead_Look_Exact (void *pp, const void **buf, size_t *size)
 
static SRes LookToRead_Look_Lookahead (void *pp, const void **buf, size_t *size)
 
static SRes LookToRead_Read (void *pp, void *buf, size_t *size)
 
static SRes LookToRead_Seek (void *pp, Int64 *pos, ESzSeek origin)
 
static SRes LookToRead_Skip (void *pp, size_t offset)
 
void SecToLook_CreateVTable (CSecToLook *p)
 
static SRes SecToLook_Read (void *pp, void *buf, size_t *size)
 
void SecToRead_CreateVTable (CSecToRead *p)
 
static SRes SecToRead_Read (void *pp, void *buf, size_t *size)
 
SRes SeqInStream_Read (ISeqInStream *stream, void *buf, size_t size)
 
SRes SeqInStream_Read2 (ISeqInStream *stream, void *buf, size_t size, SRes errorType)
 
SRes SeqInStream_ReadByte (ISeqInStream *stream, Byte *buf)
 

Function Documentation

SRes LookInStream_LookRead ( ILookInStream stream,
void *  buf,
size_t *  size 
)

Definition at line 35 of file 7zStream.cc.

References ILookInStream::Look, RINOK, ILookInStream::Skip, and SZ_OK.

Referenced by SecToLook_Read().

35  {
36  const void *lookBuf;
37  if (*size == 0)
38  return SZ_OK;
39  RINOK(stream->Look(stream, &lookBuf, size));
40  memcpy(buf, lookBuf, *size);
41  return stream->Skip(stream, *size);
42 }
size
Write out results.
#define SZ_OK
Definition: Types.h:25
SRes(* Look)(void *p, const void **buf, size_t *size)
Definition: Types.h:163
SRes(* Skip)(void *p, size_t offset)
Definition: Types.h:167
#define RINOK(x)
Definition: Types.h:52
SRes LookInStream_Read ( ILookInStream stream,
void *  buf,
size_t  size 
)

Definition at line 56 of file 7zStream.cc.

References LookInStream_Read2(), and SZ_ERROR_INPUT_EOF.

56  {
57  return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);
58 }
size
Write out results.
#define SZ_ERROR_INPUT_EOF
Definition: Types.h:32
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType)
Definition: 7zStream.cc:44
SRes LookInStream_Read2 ( ILookInStream stream,
void *  buf,
size_t  size,
SRes  errorType 
)

Definition at line 44 of file 7zStream.cc.

References ILookInStream::Read, RINOK, findQualityFiles::size, and SZ_OK.

Referenced by LookInStream_Read().

44  {
45  while (size != 0) {
46  size_t processed = size;
47  RINOK(stream->Read(stream, buf, &processed));
48  if (processed == 0)
49  return errorType;
50  buf = (void *)((Byte *)buf + processed);
51  size -= processed;
52  }
53  return SZ_OK;
54 }
size
Write out results.
#define SZ_OK
Definition: Types.h:25
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:170
#define RINOK(x)
Definition: Types.h:52
unsigned char Byte
Definition: Types.h:60
SRes LookInStream_SeekTo ( ILookInStream stream,
UInt64  offset 
)

Definition at line 30 of file 7zStream.cc.

References hltrates_dqm_sourceclient-live_cfg::offset, ILookInStream::Seek, SZ_SEEK_SET, and OrderedSet::t.

30  {
31  Int64 t = offset;
32  return stream->Seek(stream, &t, SZ_SEEK_SET);
33 }
SRes(* Seek)(void *p, Int64 *pos, ESzSeek origin)
Definition: Types.h:172
long long int Int64
Definition: Types.h:87
void LookToRead_CreateVTable ( CLookToRead p,
int  lookahead 
)

Definition at line 118 of file 7zStream.cc.

References ILookInStream::Look, LookToRead_Look_Exact(), LookToRead_Look_Lookahead(), LookToRead_Read(), LookToRead_Seek(), LookToRead_Skip(), ILookInStream::Read, CLookToRead::s, ILookInStream::Seek, and ILookInStream::Skip.

118  {
120  p->s.Skip = LookToRead_Skip;
121  p->s.Read = LookToRead_Read;
122  p->s.Seek = LookToRead_Seek;
123 }
static SRes LookToRead_Read(void *pp, void *buf, size_t *size)
Definition: 7zStream.cc:99
static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size)
Definition: 7zStream.cc:60
static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size)
Definition: 7zStream.cc:76
SRes(* Seek)(void *p, Int64 *pos, ESzSeek origin)
Definition: Types.h:172
ILookInStream s
Definition: Types.h:185
static SRes LookToRead_Skip(void *pp, size_t offset)
Definition: 7zStream.cc:93
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:170
static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin)
Definition: 7zStream.cc:112
SRes(* Look)(void *p, const void **buf, size_t *size)
Definition: Types.h:163
SRes(* Skip)(void *p, size_t offset)
Definition: Types.h:167
void LookToRead_Init ( CLookToRead p)

Definition at line 125 of file 7zStream.cc.

References CLookToRead::pos, and CLookToRead::size.

125 { p->pos = p->size = 0; }
size_t size
Definition: Types.h:188
size_t pos
Definition: Types.h:187
static SRes LookToRead_Look_Exact ( void *  pp,
const void **  buf,
size_t *  size 
)
static

Definition at line 76 of file 7zStream.cc.

References CLookToRead::buf, LookToRead_BUF_SIZE, AlCaHLTBitMon_ParallelJobs::p, CLookToRead::pos, ISeekInStream::Read, CLookToRead::realStream, CLookToRead::size, findQualityFiles::size, and SZ_OK.

Referenced by LookToRead_CreateVTable().

76  {
77  SRes res = SZ_OK;
79  size_t size2 = p->size - p->pos;
80  if (size2 == 0 && *size > 0) {
81  p->pos = 0;
84  res = p->realStream->Read(p->realStream, p->buf, size);
85  size2 = p->size = *size;
86  }
87  if (size2 < *size)
88  *size = size2;
89  *buf = p->buf + p->pos;
90  return res;
91 }
size
Write out results.
Byte buf[(1<< 14)]
Definition: Types.h:189
Definition: Electron.h:6
int SRes
Definition: Types.h:43
ISeekInStream * realStream
Definition: Types.h:186
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:158
#define SZ_OK
Definition: Types.h:25
#define LookToRead_BUF_SIZE
Definition: Types.h:182
size_t size
Definition: Types.h:188
size_t pos
Definition: Types.h:187
static SRes LookToRead_Look_Lookahead ( void *  pp,
const void **  buf,
size_t *  size 
)
static

Definition at line 60 of file 7zStream.cc.

References CLookToRead::buf, LookToRead_BUF_SIZE, AlCaHLTBitMon_ParallelJobs::p, CLookToRead::pos, ISeekInStream::Read, CLookToRead::realStream, CLookToRead::size, and SZ_OK.

Referenced by LookToRead_CreateVTable().

60  {
61  SRes res = SZ_OK;
63  size_t size2 = p->size - p->pos;
64  if (size2 == 0 && *size > 0) {
65  p->pos = 0;
66  size2 = LookToRead_BUF_SIZE;
67  res = p->realStream->Read(p->realStream, p->buf, &size2);
68  p->size = size2;
69  }
70  if (size2 < *size)
71  *size = size2;
72  *buf = p->buf + p->pos;
73  return res;
74 }
size
Write out results.
Byte buf[(1<< 14)]
Definition: Types.h:189
Definition: Electron.h:6
int SRes
Definition: Types.h:43
ISeekInStream * realStream
Definition: Types.h:186
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:158
#define SZ_OK
Definition: Types.h:25
#define LookToRead_BUF_SIZE
Definition: Types.h:182
size_t size
Definition: Types.h:188
size_t pos
Definition: Types.h:187
static SRes LookToRead_Read ( void *  pp,
void *  buf,
size_t *  size 
)
static

Definition at line 99 of file 7zStream.cc.

References CLookToRead::buf, AlCaHLTBitMon_ParallelJobs::p, CLookToRead::pos, ISeekInStream::Read, CLookToRead::realStream, CLookToRead::size, findQualityFiles::size, and SZ_OK.

Referenced by LookToRead_CreateVTable().

99  {
100  CLookToRead *p = (CLookToRead *)pp;
101  size_t rem = p->size - p->pos;
102  if (rem == 0)
103  return p->realStream->Read(p->realStream, buf, size);
104  if (rem > *size)
105  rem = *size;
106  memcpy(buf, p->buf + p->pos, rem);
107  p->pos += rem;
108  *size = rem;
109  return SZ_OK;
110 }
size
Write out results.
Byte buf[(1<< 14)]
Definition: Types.h:189
ISeekInStream * realStream
Definition: Types.h:186
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:158
#define SZ_OK
Definition: Types.h:25
size_t size
Definition: Types.h:188
size_t pos
Definition: Types.h:187
static SRes LookToRead_Seek ( void *  pp,
Int64 pos,
ESzSeek  origin 
)
static

Definition at line 112 of file 7zStream.cc.

References AlCaHLTBitMon_ParallelJobs::p, CLookToRead::pos, CLookToRead::realStream, ISeekInStream::Seek, and CLookToRead::size.

Referenced by LookToRead_CreateVTable().

112  {
113  CLookToRead *p = (CLookToRead *)pp;
114  p->pos = p->size = 0;
115  return p->realStream->Seek(p->realStream, pos, origin);
116 }
ISeekInStream * realStream
Definition: Types.h:186
size_t size
Definition: Types.h:188
size_t pos
Definition: Types.h:187
SRes(* Seek)(void *p, Int64 *pos, ESzSeek origin)
Definition: Types.h:159
static SRes LookToRead_Skip ( void *  pp,
size_t  offset 
)
static
void SecToLook_CreateVTable ( CSecToLook p)

Definition at line 132 of file 7zStream.cc.

References ISeqInStream::Read, CSecToLook::s, and SecToLook_Read().

132 { p->s.Read = SecToLook_Read; }
static SRes SecToLook_Read(void *pp, void *buf, size_t *size)
Definition: 7zStream.cc:127
ISeqInStream s
Definition: Types.h:196
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:139
static SRes SecToLook_Read ( void *  pp,
void *  buf,
size_t *  size 
)
static

Definition at line 127 of file 7zStream.cc.

References LookInStream_LookRead(), AlCaHLTBitMon_ParallelJobs::p, and CSecToLook::realStream.

Referenced by SecToLook_CreateVTable().

127  {
128  CSecToLook *p = (CSecToLook *)pp;
129  return LookInStream_LookRead(p->realStream, buf, size);
130 }
size
Write out results.
ILookInStream * realStream
Definition: Types.h:197
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size)
Definition: 7zStream.cc:35
void SecToRead_CreateVTable ( CSecToRead p)

Definition at line 139 of file 7zStream.cc.

References ISeqInStream::Read, CSecToRead::s, and SecToRead_Read().

139 { p->s.Read = SecToRead_Read; }
static SRes SecToRead_Read(void *pp, void *buf, size_t *size)
Definition: 7zStream.cc:134
ISeqInStream s
Definition: Types.h:203
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:139
static SRes SecToRead_Read ( void *  pp,
void *  buf,
size_t *  size 
)
static

Definition at line 134 of file 7zStream.cc.

References AlCaHLTBitMon_ParallelJobs::p, ILookInStream::Read, and CSecToRead::realStream.

Referenced by SecToRead_CreateVTable().

134  {
135  CSecToRead *p = (CSecToRead *)pp;
136  return p->realStream->Read(p->realStream, buf, size);
137 }
size
Write out results.
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:170
ILookInStream * realStream
Definition: Types.h:204
SRes SeqInStream_Read ( ISeqInStream stream,
void *  buf,
size_t  size 
)

Definition at line 20 of file 7zStream.cc.

References SeqInStream_Read2(), and SZ_ERROR_INPUT_EOF.

Referenced by LzmaFile::Open().

20  {
21  return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);
22 }
size
Write out results.
#define SZ_ERROR_INPUT_EOF
Definition: Types.h:32
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType)
Definition: 7zStream.cc:8
SRes SeqInStream_Read2 ( ISeqInStream stream,
void *  buf,
size_t  size,
SRes  errorType 
)

Definition at line 8 of file 7zStream.cc.

References ISeqInStream::Read, RINOK, findQualityFiles::size, and SZ_OK.

Referenced by SeqInStream_Read().

8  {
9  while (size != 0) {
10  size_t processed = size;
11  RINOK(stream->Read(stream, buf, &processed));
12  if (processed == 0)
13  return errorType;
14  buf = (void *)((Byte *)buf + processed);
15  size -= processed;
16  }
17  return SZ_OK;
18 }
size
Write out results.
#define SZ_OK
Definition: Types.h:25
#define RINOK(x)
Definition: Types.h:52
unsigned char Byte
Definition: Types.h:60
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:139
SRes SeqInStream_ReadByte ( ISeqInStream stream,
Byte buf 
)

Definition at line 24 of file 7zStream.cc.

References ISeqInStream::Read, RINOK, SZ_ERROR_INPUT_EOF, and SZ_OK.

24  {
25  size_t processed = 1;
26  RINOK(stream->Read(stream, buf, &processed));
27  return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF;
28 }
#define SZ_ERROR_INPUT_EOF
Definition: Types.h:32
#define SZ_OK
Definition: Types.h:25
#define RINOK(x)
Definition: Types.h:52
SRes(* Read)(void *p, void *buf, size_t *size)
Definition: Types.h:139