foobar2000 SDK  2015-08-03
Public Member Functions | Static Public Member Functions | Private Attributes
stream_reader_chunk

#include <filesystem_helper.h>

+ Inheritance diagram for stream_reader_chunk:

Public Member Functions

 stream_reader_chunk (stream_reader *p_reader)
 
void flush (abort_callback &p_abort)
 
t_size read (void *p_buffer, t_size p_bytes, abort_callback &p_abort)
 

Static Public Member Functions

static void g_skip (stream_reader *p_stream, abort_callback &p_abort)
 

Private Attributes

unsigned char m_buffer [255]
 
t_size m_buffer_size
 
t_size m_buffer_state
 
bool m_eof
 
stream_readerm_reader
 

Detailed Description

Definition at line 359 of file filesystem_helper.h.

Constructor & Destructor Documentation

stream_reader_chunk::stream_reader_chunk ( stream_reader p_reader)
inline

Definition at line 362 of file filesystem_helper.h.

Member Function Documentation

void stream_reader_chunk::flush ( abort_callback p_abort)

Definition at line 64 of file filesystem_helper.cpp.

64  {
65  while(!m_eof) {
66  p_abort.check_e();
67  t_uint8 temp;
68  m_reader->read_lendian_t(temp,p_abort);
69  m_buffer_size = temp;
70  if (temp != sizeof(m_buffer)) m_eof = true;
71  m_buffer_state = 0;
72  if (m_buffer_size>0) {
73  m_reader->skip_object(m_buffer_size,p_abort);
74  }
75  }
76 }
uint8_t t_uint8
Definition: int_types.h:9
unsigned char m_buffer[255]
stream_reader * m_reader
void stream_reader_chunk::g_skip ( stream_reader p_stream,
abort_callback p_abort 
)
static

Definition at line 85 of file filesystem_helper.cpp.

85  {
86  stream_reader_chunk(p_stream).flush(p_abort);
87 }
stream_reader_chunk(stream_reader *p_reader)
t_size stream_reader_chunk::read ( void *  p_buffer,
t_size  p_bytes,
abort_callback p_abort 
)

Definition at line 35 of file filesystem_helper.cpp.

36 {
37  t_size todo = p_bytes, done = 0;
38  while(todo > 0) {
40  if (m_eof) break;
41  t_uint8 temp;
42  m_reader->read_lendian_t(temp,p_abort);
43  m_buffer_size = temp;
44  if (temp != sizeof(m_buffer)) m_eof = true;
45  m_buffer_state = 0;
46  if (m_buffer_size>0) {
47  m_reader->read_object(m_buffer,m_buffer_size,p_abort);
48  }
49  }
50 
51 
53  if (delta > todo) delta = todo;
54  if (delta > 0) {
55  memcpy((unsigned char*)p_buffer + done,m_buffer + m_buffer_state,delta);
56  todo -= delta;
57  done += delta;
58  m_buffer_state += delta;
59  }
60  }
61  return done;
62 }
uint8_t t_uint8
Definition: int_types.h:9
size_t t_size
Definition: int_types.h:48
unsigned char m_buffer[255]
stream_reader * m_reader

Field Documentation

unsigned char stream_reader_chunk::m_buffer[255]
private

Definition at line 374 of file filesystem_helper.h.

t_size stream_reader_chunk::m_buffer_size
private

Definition at line 372 of file filesystem_helper.h.

t_size stream_reader_chunk::m_buffer_state
private

Definition at line 372 of file filesystem_helper.h.

bool stream_reader_chunk::m_eof
private

Definition at line 373 of file filesystem_helper.h.

stream_reader* stream_reader_chunk::m_reader
private

Definition at line 371 of file filesystem_helper.h.


The documentation for this class was generated from the following files: