Changeset 480 for trunk


Ignore:
Timestamp:
Apr 4, 2011, 4:00:22 PM (10 years ago)
Author:
Silvan Scherrer
Message:

search poppler-data also in bin dir

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/poppler/mypoppler/poppler/GlobalParams.cc

    r473 r480  
    3232//========================================================================
    3333
     34#ifdef __OS2__
     35#define INCL_DOSPROCESS
     36#define INCL_DOSMODULEMGR
     37#define INCL_DOSERRORS
     38#endif
     39
    3440#include <config.h>
    3541
     
    192198  }
    193199  strcat (retval, "\\share\\poppler");
     200
     201  beenhere = 1;
     202
     203  return retval;
     204}
     205
     206#undef POPPLER_DATADIR
     207#define POPPLER_DATADIR get_poppler_datadir ()
     208
     209#endif
     210
     211#ifdef __OS2__
     212
     213// we search within the exe first of the data-dir
     214static char *
     215get_poppler_datadir(void)
     216{
     217   char sExeName[_MAX_PATH];
     218   char sDrive[_MAX_PATH], sDir[_MAX_DIR];
     219   static char retval[_MAX_PATH];
     220   static int beenhere = 0;
     221   APIRET rc = NO_ERROR;
     222   PPIB ppib = NULL;
     223   DIR *dir = NULL;
     224
     225  if (beenhere)
     226    return retval;
     227
     228  // we search for the infoblock to get the module name
     229  rc = DosGetInfoBlocks(NULL, &ppib);
     230  if (rc != NO_ERROR)
     231  {
     232        return POPPLER_DATADIR;
     233  }
     234
     235  // with the module name we get the path (including the exe name)
     236  rc = DosQueryModuleName(ppib->pib_hmte, sizeof(sExeName), sExeName);
     237  if (rc != NO_ERROR)
     238  {
     239        return POPPLER_DATADIR;
     240  }
     241
     242  // we split to the different values
     243  _splitpath(sExeName, sDrive, sDir, NULL, NULL);
     244  strncat(sDrive, sDir, strlen(sDir) -1);
     245  strcpy(retval, sDrive);
     246
     247  // now we see if there is a datadir in the exe dir 
     248  // allocate buffer large enough to append "/nameToUnicode"
     249  size_t bufSize = strlen(retval) + strlen("/nameToUnicode") + 1;
     250  char *dataPathBuffer = new char[bufSize];
     251 
     252  snprintf(dataPathBuffer, bufSize, "%s/nameToUnicode", retval);
     253  dir = opendir(dataPathBuffer);
     254  if (!dir)
     255  {
     256    retval[0] = '\0';
     257    strncpy(retval, POPPLER_DATADIR, sizeof(retval) -1);
     258  }
     259  if (dir)
     260  closedir(dir);
     261 
     262  delete[] dataPathBuffer;
    194263
    195264  beenhere = 1;
Note: See TracChangeset for help on using the changeset viewer.