Logo Search packages:      
Sourcecode: djvulibre version File versions

bool IFFByteStream::compare ( IFFByteStream iff  ) 

This is a simple compare method. The IFFByteStream may be read for the sake of the comparison. Since IFFByteStreams are non-seekable, the stream is not valid for use after comparing, regardless of the result.

Definition at line 523 of file IFFByteStream.cpp.

References close_chunk(), get_chunk(), and read().

{
  bool retval=(&iff == this);
  if(!retval)
  {
    GUTF8String chkid1, chkid2;
    int size;
    while((size=get_chunk(chkid1)) == iff.get_chunk(chkid2))
    {
      if(chkid1 != chkid2)
      {
        break;
      }
      if(!size)
      {
        retval=true;
        break;
      }
      char buf[4096];
      int len;
      while((len=read(buf,sizeof(buf))))
      {
        int s=0;
        char buf2[sizeof(buf)];
        while(s<len)
        {
          const int i=iff.read(buf2+s,len-s);
          if(!i)
            break;
          s+=i;
        }
        if((s != len)||memcmp(buf,buf2,len))
          break;
      }
      if(len)
        break;
      iff.close_chunk();
      close_chunk();
    }
  }
  return retval;
}


Generated by  Doxygen 1.6.0   Back to index