Beispiel #1
0
void fillFnam(char *dest, const char * const pattern
 , const char * const fnam)
{
#if 0
  char *dr, *pa, *fn, *ex;
  char *pfn, *pex;
#else
  char dr[MAXDRIVE], pa[MAXDIR], fn[MAXFILE], ex[MAXEXT], pfn[MAXFILE],
       pex[MAXEXT];
#endif
  char dfn[MAXFILE], dex[MAXEXT];

  assert(fnam);
  assert(pattern);

  if(strchr(pattern, '?') == 0 && strchr(pattern, '*') == 0)
#if 0
    return strdup(pattern);
#else
    strcpy(dest, pattern);
#endif

#if 0
  if(!dfnsplit(pattern, &dr, &pa, &fn, &ex))
    return 0;

  if(!dfnsplit(fnam, 0, 0, &pfn, &pex)) {
    free(fn);
    free(ex);
    free(dr);
    free(pa);
    return 0;
  }
#else
  myfnsplit(pattern, dr, pa, fn, ex);
  myfnsplit(fnam, 0, 0, pfn, pex);
#endif

  fillComp(dfn, fn, pfn, MAXFILE);
  fillComp(dex, ex, pex, MAXEXT);

#if 0
  p = dfnmerge(0, dr, pa, dfn, dex);
#else
  myfnmerge(dest, dr, pa, dfn, dex);
#endif

#if 0
  free(pfn);
  free(pex);
  free(dr);
  free(pa);
  free(fn);
  free(ex);

  return p;
#endif
}
Beispiel #2
0
char *fillFnam(const char * const pattern
 , const char * const fnam)
{ char *dr, *pa, *fn, *ex;
  char *pfn, *pex;
  char dfn[MAXFILE], dex[MAXEXT];
  char *p;

  assert(fnam);
  assert(pattern);

  if(strchr(pattern, '?') == 0 && strchr(pattern, '*') == 0)
    return strdup(pattern);

  if(!dfnsplit(pattern, &dr, &pa, &fn, &ex))
    return 0;

  if(!dfnsplit(fnam, 0, 0, &pfn, &pex)) {
    free(fn);
    free(ex);
    free(dr);
    free(pa);
    return 0;
  }

  fillComp(dfn, fn, pfn, MAXFILE);
  fillComp(dex, ex, pex, MAXEXT);

  p = dfnmerge(0, dr, pa, dfn, dex);

  free(pfn);
  free(pex);
  free(dr);
  free(pa);
  free(fn);
  free(ex);

  return p;
}