FACT++  1.0
std::streambuf::pos_type izstream::seekoff ( std::streambuf::off_type  offset,
std::ios_base::seekdir  dir,
std::ios_base::openmode  = std::ios_base::in 
)
inline

Definition at line 102 of file izstream.h.

References clear(), and end.

Referenced by seekpos().

104  {
105  // Using a switch instead results in:
106  // In member function `virtual std::streampos izstream::seekoff(long int, std::_Ios_Seekdir, std::_Ios_Openmode)':
107  // warning: enumeration value `_M_ios_seekdir_end' not handled in switch
108  // warning: case value `0' not in enumerated type `_Ios_Seekdir'
109  // warning: case value `1' not in enumerated type `_Ios_Seekdir'
110  // warning: case value `2' not in enumerated type `_Ios_Seekdir'
111 
112  if (dir==std::ios::end)
113  {
114  clear(rdstate()|std::ios::failbit);
115  return EOF;
116  }
117 
118  // We only do relative seeking to avoid unnecessary decompression
119  // of the whole file
120  if (dir==std::ios::beg)
121  offset -= tellg();
122 
123  // Calculate future position in streambuffer
124  const char *ptr = gptr()+offset;
125 
126  // This is the number of bytes still available in the buffer
127  const size_t sbuf = egptr()-gptr();
128 
129  // Check if the new position will still be in the buffer
130  // In this case the target data was already decompressed.
131  if (ptr>=eback() && ptr<egptr())
132  {
133  // Absolute position in z-stream
134  const z_off_t zpos = gztell(fFile)-sbuf; //gzseek(fFile, 0, SEEK_CUR);
135 
136  gbump(offset);
137 
138  return zpos+offset;
139  }
140 
141  const streampos pos = gzseek(fFile, offset-sbuf, SEEK_CUR);
142 
143  // Buffer is empty - force refilling
144  setg(fBuffer+4, fBuffer+4, fBuffer+4);
145 
146  return pos<0 ? streampos(EOF) : pos;
147 
148  /*
149  // SEEK_END not supported by zlib
150  if (dir==ios::end)
151  {
152  // Position in z-stream
153  const z_off_t zpos = gzseek(fFile, offset, SEEK_END);
154  if (zpos<0)
155  return EOF;
156 
157  return fill_buffer()==EOF ? EOF : zpos;
158  }
159  */
160  return EOF;
161  }
double end
char * fBuffer
Definition: izstream.h:21
gzFile fFile
Definition: izstream.h:20
void clear()
Definition: HeadersFTM.h:216

+ Here is the call graph for this function:

+ Here is the caller graph for this function: