Logo Search packages:      
Sourcecode: djvulibre version File versions  Download package

void DjVmDoc::insert_file ( ByteStream data,
DjVmDir::File::FILE_TYPE  file_type,
const GUTF8String name,
const GUTF8String id,
const GUTF8String title = GUTF8String(),
int  pos = -1 
)

Inserts a file into the document.

Parameters:
data ByteStream containing the file data.
file_type Describes the type of the file to be inserted. See {DjVmDir::File} for details.
name Name of the file in the document (e.g. an URL).
id Identifier of the file (as used in INCL chunks).
title Optional title of the file (shown in browsers).
pos Position of the file in the document (default is append).

Definition at line 190 of file DjVmDoc.cpp.

References DataPool::create(), and ByteStream::read().

Referenced by insert_file().

{
   const GP<DjVmDir::File> file(
     DjVmDir::File::create(name, id, title, file_type));
   const GP<DataPool> pool(DataPool::create());
      // Cannot connect to a bytestream.
      // Must copy data into the datapool.
   int nbytes;
   char buffer[1024];
   while ((nbytes = data.read(buffer, sizeof(buffer))))
      pool->add_data(buffer, nbytes);
   pool->set_eof();
      // Call low level insert
   insert_file(file, pool, pos);
}


Generated by  Doxygen 1.6.0   Back to index