Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVmDoc::read ( const GURL url  ) 

Reads the DjVu multipage document in either {bundled} or {indirect} format.

{ Note:} For {bundled} documents the file is not read into memory. We just open it and access data directly there. Thus you should not modify the file contents.

Parameters:
name For {bundled} documents this is the name of the document. For {indirect} documents this is the name of the top-level file of the document (containing the {DjVmDir} with the list of all files). The rest of the files are expected to be in the same directory and will be read by this function as well.

Definition at line 468 of file DjVmDoc.cpp.

References GURL::base(), IFFByteStream::close_chunk(), ByteStream::create(), DataPool::create(), DjVmDir::decode(), GMapTemplate< KTYPE, VTYPE, TI >::empty(), IFFByteStream::get_bytestream(), IFFByteStream::get_chunk(), DjVmDir::get_files_list(), DjVmDir::is_bundled(), and read().

{
   DEBUG_MSG("DjVmDoc::read(): reading the doc contents from the HDD\n");
   DEBUG_MAKE_INDENT(3);

   GP<DataPool> pool=DataPool::create(url);
   const GP<ByteStream> str(pool->get_stream());
   GP<IFFByteStream> giff=IFFByteStream::create(str);
   IFFByteStream &iff=*giff;
   GUTF8String chkid;
   iff.get_chunk(chkid);
   if (chkid!="FORM:DJVM")
      G_THROW( ERR_MSG("DjVmDoc.no_form_djvm2") );

   iff.get_chunk(chkid);
   if (chkid!="DIRM")
      G_THROW( ERR_MSG("DjVmDoc.no_dirm_chunk") );
   dir->decode(iff.get_bytestream());
   iff.close_chunk();

   if (dir->is_bundled())
     read(pool);
   else
   {
//      GUTF8String full_name=GOS::expand_name(name);
//      GUTF8String dir_name=GOS::dirname(GOS::url_to_filename(url.base()));
      GURL dirbase=url.base();

      data.empty();

      GPList<DjVmDir::File> files_list=dir->get_files_list();
      for(GPosition pos=files_list;pos;++pos)
      {
       DjVmDir::File * f=files_list[pos];
      
       DEBUG_MSG("reading contents of file '" << f->get_load_name() << "'\n");

         const GURL::UTF8 url(f->get_load_name(),dirbase);
       data[f->get_load_name()]=DataPool::create(url);
      }
   }
}


Generated by  Doxygen 1.6.0   Back to index