Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVmDir::set_file_name ( const GUTF8String id,
const GUTF8String name 
)

Changes the name of the file with ID id#.

Definition at line 757 of file DjVmDir.cpp.

References GMapTemplate< KTYPE, VTYPE, TI >::contains(), and GMapTemplate< KTYPE, VTYPE, TI >::del().

Referenced by DjVuDocEditor::set_file_name(), and DjVmDoc::write().

{
   DEBUG_MSG("DjVmDir::set_file_name(): id='" << id << "', name='" << name << "'\n");
   DEBUG_MAKE_INDENT(3);
   
   GCriticalSectionLock lock((GCriticalSection *) &class_lock);

   GPosition pos;
   
      // First see, if the name is unique
   for(pos=files_list;pos;++pos)
   {
      GP<File> file=files_list[pos];
      if (file->id!=id && file->name==name)
        G_THROW( ERR_MSG("DjVmDir.name_in_use") "\t" + GUTF8String(name));
   }

      // Check if ID is valid
   if (!id2file.contains(id, pos))
      G_THROW( ERR_MSG("DjVmDir.no_info") "\t" + GUTF8String(id));
   GP<File> file=id2file[pos];
   name2file.del(file->name);
   file->name=name;
   name2file[name]=file;
}


Generated by  Doxygen 1.6.0   Back to index