Logo Search packages:      
Sourcecode: xchm version File versions

CHMInputStream::CHMInputStream ( const wxString &  archive,
const wxString &  file 
)

Creates a stream.

Parameters:
archive The .chm file name on disk. It makes sense to pass the empty string if you're sure file is a link to a page, in the form of "/MS-ITS:archive.chm::/filename.html".
file The file requested from the archive.

Definition at line 52 of file chminputstream.cpp.

References CHMFile::HomePage(), Init(), and CHMFile::ResolveObject().

      : _currPos(0)
{
      wxString filename = file;

      if(!archive.IsEmpty())
            _path = archive.BeforeLast(wxT('/')) + wxT("/");

      memset(&_ui, 0, sizeof(_ui));

      // Maybe the cached chmFile* isn't valid anymore,
      // or maybe there is no chached chmFile* yet.
      if(!archive.IsEmpty() && !Init(archive)) {
            m_lasterror = wxSTREAM_READ_ERROR;
            return;
      }

      // Somebody's looking for the homepage.
      if(file.IsSameAs(wxT("/")))
            filename = _archiveCache->HomePage();

      if(!filename.Left(8).CmpNoCase(wxT("/MS-ITS:"))) {
            // If this ever happens chances are Microsoft
            // decided that even if we went through the
            // trouble to open this archive and check out
            // the index file, the index file is just a
            // link to a file in another archive.

            wxString arch_link = 
                  filename.AfterFirst(wxT(':')).BeforeFirst(wxT(':'));

            filename = filename.AfterLast(wxT(':'));

            // Reset the cached chmFile* and all.
            if(!Init(arch_link))
                  if(!Init(_path + arch_link)) {
                        m_lasterror = wxSTREAM_READ_ERROR;
                        return;
                  }
      }

      assert(_archiveCache != NULL);

      // See if the file really is in the archive.
      if(!_archiveCache->ResolveObject(filename, &_ui)) {
            m_lasterror = wxSTREAM_READ_ERROR;
            return;
      }
}


Generated by  Doxygen 1.6.0   Back to index