Changeset 832


Ignore:
Timestamp:
Sep 5, 2007, 4:09:22 AM (18 years ago)
Author:
Gregg Young
Message:

Initial implimentation of a more flexible mask matching system to address multiple "." in file names

Location:
trunk/dll
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/assoc.c

    r793 r832  
    361361      }
    362362      else
    363         exclude = FALSE;
    364       didmatch = wildcard((strchr(p, '\\') ||
    365                            strchr(p, ':')) ? datafile : file, p, FALSE);
     363          exclude = FALSE;
     364      if ((*p == '*') &&
     365          !((p[strlen(p) - 1]) == '*'))
     366        didmatch = wildcard((strchr(p, '\\') ||
     367                             strchr(p, ':')) ? datafile : file, p, FALSE);
     368      else
     369        didmatch = wildcard2((strchr(p, '\\') ||
     370                             strchr(p, ':')) ? datafile : file, p, FALSE);
    366371      if (exclude && didmatch)
    367372        didmatch = FALSE;
  • trunk/dll/avl.c

    r806 r832  
    171171              &handle,
    172172              &action,
    173               0L,
    174               0L,
     173              0,
     174              0,
    175175              OPEN_ACTION_FAIL_IF_NEW |
    176176              OPEN_ACTION_OPEN_IF_EXISTS,
     
    178178              OPEN_FLAGS_NOINHERIT |
    179179              OPEN_FLAGS_RANDOMSEQUENTIAL |
    180               OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0L))
     180              OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0))
    181181    return NULL;
    182182  // Scan signatures
     
    199199    if (!DosChgFilePtr(handle,
    200200                       abs(info->file_offset),
    201                        (info->file_offset >= 0L) ?
     201                       (info->file_offset >= 0) ?
    202202                       FILE_BEGIN : FILE_END, &len)) {
    203203      if (!DosRead(handle, buffer, l, &len) && len == l) {
  • trunk/dll/filter.c

    r793 r832  
    7373        || ((mask->antiattr & FILE_DIRECTORY)
    7474            && !(r->attrFile & FILE_DIRECTORY)))
    75       return FALSE;
     75        return FALSE;
    7676    if (*mask->szMask) {
     77      if ((*mask->szMask == '*') &&
     78          !((mask->szMask[strlen(mask->szMask)-1]) == '*')){
     79        file = strrchr(r->pszFileName, '\\');
     80        if (!file)
     81          file = strrchr(r->pszFileName, ':');
     82        if (file)
     83          file++;
     84        else
     85          file = r->pszFileName;
     86        if (mask->pszMasks[1]) {
     87          for (x = 0; mask->pszMasks[x]; x++) {
     88            if (*mask->pszMasks[x]) {
     89              if (*mask->pszMasks[x] != '/') {
     90                if (wildcard((strchr(mask->pszMasks[x], '\\') ||
     91                              strchr(mask->pszMasks[x], ':')) ?
     92                             r->pszFileName : file, mask->pszMasks[x], FALSE))
     93                  ret = TRUE;
     94              }
     95              else {
     96                if (wildcard((strchr(mask->pszMasks[x], '\\') ||
     97                              strchr(mask->pszMasks[x], ':')) ?
     98                             r->pszFileName : file, mask->pszMasks[x] + 1,
     99                             FALSE)) {
     100                  ret = FALSE;
     101                  break;
     102                }
     103              }
     104            }
     105          }
     106        }
     107        else {
     108          if (wildcard((strchr(mask->szMask, '\\') ||
     109                        strchr(mask->szMask, ':')) ?
     110                       r->pszFileName : file, mask->szMask, FALSE))
     111            ret = TRUE;
     112        }
     113      }
     114      else{
    77115      file = strrchr(r->pszFileName, '\\');
    78       if (!file)
    79         file = strrchr(r->pszFileName, ':');
    80       if (file)
    81         file++;
    82       else
    83         file = r->pszFileName;
    84       if (mask->pszMasks[1]) {
    85         for (x = 0; mask->pszMasks[x]; x++) {
    86           if (*mask->pszMasks[x]) {
    87             if (*mask->pszMasks[x] != '/') {
    88               if (wildcard((strchr(mask->pszMasks[x], '\\') ||
    89                             strchr(mask->pszMasks[x], ':')) ?
    90                            r->pszFileName : file, mask->pszMasks[x], FALSE))
    91                 ret = TRUE;
    92             }
    93             else {
    94               if (wildcard((strchr(mask->pszMasks[x], '\\') ||
    95                             strchr(mask->pszMasks[x], ':')) ?
    96                            r->pszFileName : file, mask->pszMasks[x] + 1,
    97                            FALSE)) {
    98                 ret = FALSE;
    99                 break;
    100               }
    101             }
    102           }
    103         }
    104       }
    105       else {
    106         if (wildcard((strchr(mask->szMask, '\\') ||
    107                       strchr(mask->szMask, ':')) ?
    108                      r->pszFileName : file, mask->szMask, FALSE))
    109           ret = TRUE;
    110       }
    111     }
     116        if (!file)
     117          file = strrchr(r->pszFileName, ':');
     118        if (file)
     119          file++;
     120        else
     121          file = r->pszFileName;
     122        if (mask->pszMasks[1]) {
     123          for (x = 0; mask->pszMasks[x]; x++) {
     124            if (*mask->pszMasks[x]) {
     125              if (*mask->pszMasks[x] != '/') {
     126                if (wildcard2((strchr(mask->pszMasks[x], '\\') ||
     127                              strchr(mask->pszMasks[x], ':')) ?
     128                             r->pszFileName : file, mask->pszMasks[x], FALSE))
     129                  ret = TRUE;
     130              }
     131              else {
     132                if (wildcard2((strchr(mask->pszMasks[x], '\\') ||
     133                              strchr(mask->pszMasks[x], ':')) ?
     134                             r->pszFileName : file, mask->pszMasks[x] + 1,
     135                             FALSE)) {
     136                  ret = FALSE;
     137                  break;
     138                }
     139              }
     140            }
     141          }
     142        }
     143        else {
     144          if (wildcard2((strchr(mask->szMask, '\\') ||
     145                        strchr(mask->szMask, ':')) ?
     146                       r->pszFileName : file, mask->szMask, FALSE))
     147            ret = TRUE;
     148        }
     149      }
     150  }
    112151    else
    113152      ret = TRUE;
  • trunk/dll/fm3dll.h

    r828 r832  
    872872UINT literal(PSZ pszBuf);
    873873BOOL wildcard(const PSZ pszBuf, const PSZ pszWildCard,
     874              const BOOL fNotFileSpec);
     875BOOL wildcard2(const PSZ pszBuf, const PSZ pszWildCard,
    874876              const BOOL fNotFileSpec);
    875877PSZ fixup(const PCH pachInBuf, PSZ pszOutBuf, const UINT cBufBytes,
  • trunk/dll/literal.c

    r795 r832  
    204204              const BOOL fNotFileSpec)
    205205{
    206   const CHAR *fstr = pszBuf;
    207   PSZ fcard = pszWildCard;
     206
     207  const CHAR *fstr = strrev(pszBuf);
     208  PSZ fcard = strrev(pszWildCard);
    208209  INT wmatch = TRUE;
    209 
    210210  while (wmatch && *fcard && *fstr) {
    211     switch (*fcard) {
     211  switch (*fcard) {
    212212    case '?':                                /* character substitution */
    213213      fcard++;
     
    219219      /* find next non-wild character in wildcard */
    220220      while (*fcard && (*fcard == '?' || *fcard == '*'))
    221         fcard++;
    222       if (!*fcard)                        /* if last char of wildcard is *, it matches */
     221       fcard++;
     222      if (!*fcard){                        /* if last char of wildcard is *, it matches */
     223        fstr = strrev(pszBuf);
     224        fcard = strrev(pszWildCard);
    223225        return TRUE;
     226      }
    224227      /* skip until partition, match, or eos */
    225228      while (*fstr && toupper(*fstr) != toupper(*fcard) &&
    226229             (fNotFileSpec || (*fstr != '\\' &&
    227                                *fstr != '/' && *fstr != '.')))
     230                             *fstr != '/' && *fstr != '.')))
    228231        fstr++;
    229232      if (!fNotFileSpec && !*fstr)        /* implicit '.' */
     
    234237    default:
    235238      if (!fNotFileSpec && ((*fstr == '/' || *fstr == '\\') &&
    236                             (*fcard == '/' || *fcard == '\\')))
     239                          (*fcard == '/' || *fcard == '\\')))
    237240        wmatch = TRUE;
    238241      else
     
    243246    }
    244247  }
     248  if ((*fcard && *fcard != '*') || *fstr){
     249    fstr = strrev(pszBuf);
     250    fcard = strrev(pszWildCard);
     251    return 0;
     252  }
     253  else{
     254    fstr = strrev(pszBuf);
     255    fcard = strrev(pszWildCard);
     256    return wmatch;
     257  }
     258}
     259
     260BOOL wildcard2(const PSZ pszBuf, const PSZ pszWildCard,
     261              const BOOL fNotFileSpec)
     262{
     263  const CHAR *fstr = pszBuf;
     264  PSZ fcard = pszWildCard;
     265  CHAR tcard[50];
     266  INT wmatch = TRUE;
     267
     268    while (wmatch && *fcard && *fstr) {
     269      switch (*fcard) {
     270       case '?':                                /* character substitution */
     271         fcard++;
     272         if (fNotFileSpec || (*fstr != '.' && *fstr != '/' && *fstr != '\\'))
     273           fstr++;                                /* skip (match) next character */
     274         break;
     275
     276       case '*':
     277         /* find next non-wild character in wildcard */
     278         while (*fcard && (*fcard == '?' || *fcard == '*'))
     279           fcard++;
     280         if (!*fcard)                        /* if last char of wildcard is *, it matches */
     281           return TRUE;
     282         /* skip until partition, match, or eos */
     283         while (*fstr && toupper(*fstr) != toupper(*fcard) &&
     284                (fNotFileSpec || (*fstr != '\\' &&
     285                                  *fstr != '/' && *fstr != '.')))
     286           fstr++;
     287         if (!fNotFileSpec && !*fstr)        /* implicit '.' */
     288           if (*fcard == '.')
     289             fcard++;
     290         break;
     291
     292       default:
     293         if (!fNotFileSpec && ((*fstr == '/' || *fstr == '\\') &&
     294                               (*fcard == '/' || *fcard == '\\')))
     295           wmatch = TRUE;
     296         else
     297           wmatch = (toupper(*fstr) == toupper(*fcard));
     298         fstr++;
     299         fcard++;
     300         break;
     301       }
     302  }  //while
    245303
    246304  if ((*fcard && *fcard != '*') || *fstr)
     
    249307    return wmatch;
    250308}
     309
    251310
    252311// fixup - quote literal character array
     
    298357}
    299358
    300 #pragma alloc_text(LITERAL,literal,index,fixup,wildcard)
    301 
     359#pragma alloc_text(LITERAL,literal,index,fixup,wildcard, wildcard2)
     360
Note: See TracChangeset for help on using the changeset viewer.