Logo Search packages:      
Sourcecode: djvulibre version File versions

void DjVmDir::delete_file ( const GUTF8String id  ) 

Removes a file record with ID id#.

Definition at line 719 of file DjVmDir.cpp.

References GListTemplate< TYPE, TI >::del(), GMapTemplate< KTYPE, VTYPE, TI >::del(), GArrayTemplate< TYPE >::resize(), and GArrayTemplate< TYPE >::size().

Referenced by DjVmDoc::delete_file().

{
   DEBUG_MSG("Deleting file with id='" << (const char *)id << "'\n");
   DEBUG_MAKE_INDENT(3);

   GCriticalSectionLock lock((GCriticalSection *) &class_lock);
   
   for(GPosition pos=files_list;pos;++pos)
   {
      GP<File> & f=files_list[pos];
      if (id == f->id)
      {
         name2file.del(f->name);
         id2file.del(f->id);
         title2file.del(f->title);
         if (f->is_page())
         {
            for(int page=0;page<page2file.size();page++)
            {
               if (page2file[page]==f)
               {
                  int i;
                  for(i=page;i<page2file.size()-1;i++)
                     page2file[i]=page2file[i+1];
                  page2file.resize(page2file.size()-2);
                  for(i=page;i<page2file.size();i++)
                     page2file[i]->page_num=i;
                  break;
               }
            }
         }
         files_list.del(pos);
         break;
      }
   }
}


Generated by  Doxygen 1.6.0   Back to index