Пример #1
0
static void
appendPath(const GURL &url, 
           GMap<GUTF8String,void *> &map,
           GList<GURL> &list)
{
  if( !url.is_empty() && !map.contains(url.get_string()) )
    {
      map[url.get_string()]=0;
      list.append(url);
    }
}
Пример #2
0
GP<DjVuFile>
lt_XMLParser::Impl::get_file(const GURL &url,GUTF8String id)
{
  GP<DjVuFile> dfile;
  GP<DjVuDocument> doc;
  GCriticalSectionLock lock(&xmlparser_lock);
  {
    GPosition pos=m_docs.contains(url.get_string());
    if(pos)
    {
      doc=m_docs[pos];
    }else
    {
      doc=DjVuDocument::create_wait(url);
      if(! doc->wait_for_complete_init())
      {
        G_THROW(( ERR_MSG("XMLAnno.fail_init") "\t")+url.get_string() );
      }
      m_docs[url.get_string()]=doc;
    }
    if(id.is_int())
    {
      const int xpage=id.toInt(); //atoi((char const *)page); 
      if(xpage>0)
        id=doc->page_to_id(xpage-1);
    }else if(!id.length())
    { 
      id=doc->page_to_id(0);
    }
  }
  const GURL fileurl(doc->id_to_url(id));
  GPosition dpos(m_files.contains(fileurl.get_string()));
  if(!dpos)
  {
    if(!doc->get_id_list().contains(id))
    {
      G_THROW( ERR_MSG("XMLAnno.bad_page") );
    }
    dfile=doc->get_djvu_file(id,false);
    if(!dfile)
    {
      G_THROW( ERR_MSG("XMLAnno.bad_page") );
    }
    m_files[fileurl.get_string()]=dfile;
  }else
  {
    dfile=m_files[dpos];
  }
  return dfile;
}
GURL 
getExecDir(void)
{
  // This is the same as GetModulePath in DjVuMessage.cpp
 GURL retval;
 GUTF8String &xprogramname=DjVuMessage::programname();
 if(xprogramname.length())
 {
   if(xprogramname[1]=='/'
     ||!xprogramname.cmp("../",3)
     ||!xprogramname.cmp("./",2))
   {
     retval=GURL::Filename::UTF8(xprogramname);
   }
   if(retval.is_empty() || !retval.is_file())
   {
     GList<GURL> paths(parsePATH());
     GMap<GUTF8String,void *> pathMAP;
     for(GPosition pos=paths;pos;++pos)
     {
       retval=GURL::UTF8(xprogramname,paths[pos]);
       const GUTF8String path(retval.get_string());
       if(!pathMAP.contains(path))
       {
         if(retval.is_file())
           break;
         pathMAP[path]=0;
       }
     }
   }
   if (! retval.is_empty() )
     retval = retval.follow_symlinks();
   if (! retval.is_empty() )
     retval = retval.base();
 }
 return retval;
}