Example #1
0
void WriteOneByOneAndEnd( Stream& stream, DataRef data )
{
  for ( const uint8_t* it = data.Start(); it != data.End(); it++ )
  {
    stream.Write( DataRef( it, it + 1 ) );
    stream.Write( DataRef() );
  }

  stream.End();
}
Example #2
0
void ArchiveReader::Write( DataRef data )
{
  const uint8_t* start = data.Start();
  const uint8_t* end = data.End();

  while ( start != end )
  {
    switch ( m_state )
    {
    case STATE_PATH_ENCODING:
      start = PathEncoding( start, end );
      break;

    case STATE_FILE_LENGTH_LENGTH:
      start = FileLengthLength( start, end );
      break;

    case STATE_PATH_LENGTH:
      start = PathLength( start, end );
      break;

    case STATE_PATH:
      start = Path( start, end );
      break;

    case STATE_DATE_LENGTH:
      start = DateLength( start, end );
      break;

    case STATE_DATE:
      start = Date( start, end );
      break;

    case STATE_FILE_LENGTH:
      start = FileLength( start, end );
      break;

    case STATE_FILE:
      start = File( start, end );
      break;

    case STATE_DONE:
      throw Error( "More data received after the end of the archive" );
    }
  }
}
Example #3
0
static bool HasDotDotComponent( DataRef path )
{
  const uint8_t* start = path.Start();
  const uint8_t* end = path.End();

  while ( true )
  {
    const uint8_t* slash = std::find( start, end, '/' );

    if ( DataRef( start, slash ) == DataRef( ".." ) )
      return true;

    if ( slash == end )
      return false;

    start = slash + 1;
  }
}
Example #4
0
void StringStream::Write( DataRef data )
{
  output.insert( output.end(), data.Start(), data.End() );
}