Changeset 6158 for trunk/tools


Ignore:
Timestamp:
Jul 3, 2001, 11:59:56 PM (24 years ago)
Author:
bird
Message:

Added caching - better use of existing .depend file. Now it's fast!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/fastdep/fastdep.c

    r6141 r6158  
    1 /* $Id: fastdep.c,v 1.28 2001-07-02 18:21:02 bird Exp $
     1/* $Id: fastdep.c,v 1.29 2001-07-03 21:59:56 bird Exp $
    22 *
    33 * Fast dependents. (Fast = Quick and Dirty!)
     
    1616#define INCL_DOSERRORS
    1717#define INCL_FILEMGR
     18#define INCL_DOSMISC
     19
    1820
    1921/*
     
    2325 */
    2426#if defined(UNICODE) && !defined(__WIN32OS2__)
    25 #define CBNEWLINE     (2)
     27#define CBNEWLINE       (2)
    2628#else
    27 #define CBNEWLINE     (1)
     29#define CBNEWLINE       (1)
    2830#endif
    2931
     32
     33/*
     34 * Time stamp size.
     35 */
     36#define TS_SIZE         (48)
    3037
    3138
     
    122129    const char *    pszSuperDependency; /* Name for super dependency rule. */
    123130    BOOL            fForceScan;         /* Force scan of all files. */
    124     FDATE           fDepDate;           /* The date which files are to be search from. */
    125131} OPTIONS, *POPTIONS;
    126132
     
    130136 */
    131137typedef int ( _FNLANG)  (const char *pszFilename, const char *pszNormFilename,
    132                          FDATE FileDate, BOOL fHeader);
     138                         const char *pszTS, BOOL fHeader);
    133139typedef _FNLANG    *PFNLANG;
    134140
     
    158164    char **         papszDep;           /* Pointer to an array of pointers to dependants. */
    159165    BOOL            fUpdated;           /* If we have updated this entry during current run. */
     166    char            szTS[TS_SIZE];      /* Time stamp. */
    160167} DEPRULE, *PDEPRULE;
    161168
     
    172179*******************************************************************************/
    173180static void syntax(void);
    174 static int makeDependent(const char *pszFilename, FDATE FileDate);
    175 
    176 static int langC_CPP(const char *pszFilename, const char *pszNormFilename, FDATE FileDate, BOOL fHeader);
    177 static int langAsm(  const char *pszFilename, const char *pszNormFilename, FDATE FileDate, BOOL fHeader);
    178 static int langRC(   const char *pszFilename, const char *pszNormFilename, FDATE FileDate, BOOL fHeader);
    179 static int langCOBOL(const char *pszFilename, const char *pszNormFilename, FDATE FileDate, BOOL fHeader);
     181static int makeDependent(const char *pszFilename, const char *pszTS);
     182
     183static int langC_CPP(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
     184static int langAsm(  const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
     185static int langRC(   const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
     186static int langCOBOL(const char *pszFilename, const char *pszNormFilename, const char *pszTS, BOOL fHeader);
    180187
    181188
     
    230237static BOOL  depWriteFile(const char *pszFilename);
    231238static void  depRemoveAll(void);
    232 static void *depAddRule(const char *pszRulePath, const char *pszName, const char *pszExt, FDATE FileDate);
     239static void *depAddRule(const char *pszRulePath, const char *pszName, const char *pszExt, const char *pszTS);
    233240static BOOL  depAddDepend(void *pvRule, const char *pszDep, BOOL fCheckCyclic);
     241static void  depMarkNotFound(void *pvRule);
    234242static BOOL  depCheckCyclic(PDEPRULE pdepRule, const char *pszDep);
     243static BOOL  depValidate(PDEPRULE pdepRule);
     244INLINE char *depMakeTS(char *pszTS, PFILEFINDBUF3 pfindbuf3);
    235245
    236246
     
    334344    szExcludeFiles,  /* pszExcludeFiles */
    335345    NULL,            /* pszSuperDependency */
    336     FALSE,           /* fForceScan */
    337     {1,1,1}          /* fDepDate */
     346    FALSE            /* fForceScan */
    338347};
    339348
     
    409418    else
    410419        pszIncludeEnv = "";
     420
     421
     422    /*
     423     * Disable hard errors.
     424     */
     425    DosError(FERR_DISABLEHARDERR | FERR_ENABLEEXCEPTION);
    411426
    412427
     
    784799                    char            szSource[CCHMAXPATH];
    785800                    BOOL            fExcluded;
     801                    char            szTS[TS_SIZE];
    786802
    787803                    /*
     
    817833                     * Analyse the file.
    818834                     */
    819                     rc -= makeDependent(&szSource[0], pfindbuf3->fdateLastWrite);
     835                    depMakeTS(szTS, pfindbuf3);
     836                    rc -= makeDependent(&szSource[0], szTS);
    820837                }
    821838
     
    903920 * @returns
    904921 * @param   pszFilename     Pointer to source filename. Correct case is assumed!
    905  * @param   FileDate        File date.
     922 * @param   pszTS           File time stamp.
    906923 * @status  completely implemented.
    907924 * @author  knut st. osmundsen
    908925 */
    909 int makeDependent(const char *pszFilename, FDATE FileDate)
     926int makeDependent(const char *pszFilename, const char *pszTS)
    910927{
    911928    int    rc = -1;
     
    937954        char szNormFile[CCHMAXPATH];
    938955        fileNormalize2(pszFilename, szNormFile);
    939         rc = (*pCfg->pfn)(pszFilename, &szNormFile[0], FileDate, fHeader);
     956        rc = (*pCfg->pfn)(pszFilename, &szNormFile[0], pszTS, fHeader);
    940957    }
    941958    else
     
    958975 * @param   pszFilename         Pointer to source filename. Correct case is assumed!
    959976 * @param   pszNormFilename     Pointer to normalized source filename.
    960  * @parma   FileDate            Date of the source file.
     977 * @param   pszTS               File time stamp.
    961978 * @parma   fHeader             True if header file is being scanned.
    962979 * @status  completely implemented.
     
    964981 */
    965982int langC_CPP(const char *pszFilename, const char *pszNormFilename,
    966               FDATE FileDate, BOOL fHeader)
     983              const char *pszTS, BOOL fHeader)
    967984{
    968985    void *  pvFile;                     /* Text buffer pointer. */
     
    9931010    {
    9941011        if (options.fNoObjectPath)
    995             pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszObjectExt, FileDate);
     1012            pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszObjectExt, pszTS);
    9961013        else
    9971014            pvRule = depAddRule(options.fObjectDir ?
     
    10001017                                fileNameNoExt(pszFilename, szBuffer + CCHMAXPATH),
    10011018                                options.pszObjectExt,
    1002                                 FileDate);
     1019                                pszTS);
    10031020
    10041021        if (options.fSrcWhenObj && pvRule)
     
    10101027    else
    10111028        pvRule = depAddRule(options.fExcludeAll || pathlistFindFile2(options.pszExclude, pszNormFilename) ?
    1012                             fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, FileDate);
     1029                            fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, pszTS);
    10131030
    10141031    /* duplicate rule? */
     
    11291146                    }
    11301147                    else
     1148                    {
    11311149                        fprintf(stderr, "%s(%d): warning include file '%s' not found!\n",
    11321150                                pszFilename, iLine, szFullname);
     1151                        depMarkNotFound(pvRule);
     1152                    }
    11331153                }
    11341154            }
     
    12541274 * @param   pszFilename         Pointer to source filename. Correct case is assumed!
    12551275 * @param   pszNormFilename     Pointer to normalized source filename.
    1256  * @parma   FileDate            Date of the source file.
     1276 * @param   pszTS               File time stamp.
    12571277 * @parma   fHeader             True if header file is being scanned.
    12581278 * @status  completely implemented.
     
    12601280 */
    12611281int langAsm(const char *pszFilename, const char *pszNormFilename,
    1262             FDATE FileDate, BOOL fHeader)
     1282            const char *pszTS, BOOL fHeader)
    12631283{
    12641284    void *  pvFile;                     /* Text buffer pointer. */
     
    12751295    {
    12761296        if (options.fNoObjectPath)
    1277             pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszObjectExt, FileDate);
     1297            pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszObjectExt, pszTS);
    12781298        else
    12791299            pvRule = depAddRule(options.fObjectDir ?
     
    12821302                                fileNameNoExt(pszFilename, szBuffer + CCHMAXPATH),
    12831303                                options.pszObjectExt,
    1284                                 FileDate);
     1304                                pszTS);
    12851305
    12861306        if (options.fSrcWhenObj && pvRule)
     
    12921312    else
    12931313        pvRule = depAddRule(options.fExcludeAll || pathlistFindFile2(options.pszExclude, pszNormFilename) ?
    1294                             fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, FileDate);
     1314                            fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, pszTS);
    12951315
    12961316    /* duplicate rule? */
     
    13711391            }
    13721392            else
     1393            {
    13731394                fprintf(stderr, "%s(%d): warning include file '%s' not found!\n",
    13741395                        pszFilename, iLine, szFullname);
     1396                depMarkNotFound(pvRule);
     1397            }
    13751398        }
    13761399    } /*while*/
     
    13851408 * Generates depend info on this Resource file, these are stored internally
    13861409 * and written to file later.
    1387  * @returns   0 on success.
    1388  *            !0 on error.
    1389  * @param     pszFilename      Pointer to source filename. Correct case is assumed!
    1390  * @param     pszNormFilename  Pointer to normalized source filename.
    1391  * @parma   FileDate            Date of the source file.
     1410 * @returns 0 on success.
     1411 *          !0 on error.
     1412 * @param   pszFilename         Pointer to source filename. Correct case is assumed!
     1413 * @param   pszNormFilename     Pointer to normalized source filename.
     1414 * @param   pszTS               File time stamp.
    13921415 * @parma   fHeader             True if header file is being scanned.
    1393  * @status    completely implemented.
    1394  * @author    knut st. osmundsen
     1416 * @status  completely implemented.
     1417 * @author  knut st. osmundsen
    13951418 */
    13961419#if 0
     
    14101433    {
    14111434        if (options.fNoObjectPath)
    1412             pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszRsrcExt, FileDate);
     1435            pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszRsrcExt, pszTS);
    14131436        else
    14141437            pvRule = depAddRule(options.fObjectDir ?
     
    14171440                                fileNameNoExt(pszFilename, szBuffer + CCHMAXPATH),
    14181441                                options.pszRsrcExt,
    1419                                 FileDate);
     1442                                pszTS);
    14201443
    14211444        if (options.fSrcWhenObj && pvRule)
     
    14281451        pvRule = depAddRule(options.fExcludeAll || pathlistFindFile2(options.pszExclude, pszNormFilename) ?
    14291452                            fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL,
    1430                             FileDate);
     1453                            pszTS);
    14311454
    14321455    /* duplicate rule? */
     
    15361559            }
    15371560            else
     1561            {
    15381562                fprintf(stderr, "%s(%d): warning include file '%s' not found!\n",
    15391563                        pszFilename, iLine, szFullname);
    1540         }     } /*while*/
     1564                depMarkNotFound(pvRule);
     1565            }
     1566        }
     1567    } /*while*/
    15411568
    15421569    textbufferDestroy(pvFile);
     
    15451572#else
    15461573int langRC(const char *pszFilename, const char *pszNormFilename,
    1547            FDATE FileDate, BOOL fHeader)
     1574           const char *pszTS, BOOL fHeader)
    15481575{
    15491576    void *  pvFile;                     /* Text buffer pointer. */
     
    15741601    {
    15751602        if (options.fNoObjectPath)
    1576             pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszRsrcExt, FileDate);
     1603            pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszRsrcExt, pszTS);
    15771604        else
    15781605            pvRule = depAddRule(options.fObjectDir ?
     
    15811608                                fileNameNoExt(pszFilename, szBuffer + CCHMAXPATH),
    15821609                                options.pszRsrcExt,
    1583                                 FileDate);
     1610                                pszTS);
    15841611
    15851612        if (options.fSrcWhenObj && pvRule)
     
    15911618    else
    15921619        pvRule = depAddRule(options.fExcludeAll || pathlistFindFile2(options.pszExclude, pszNormFilename) ?
    1593                             fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, FileDate);
     1620                            fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, pszTS);
    15941621
    15951622    /* duplicate rule? */
     
    17101737                    }
    17111738                    else
     1739                    {
    17121740                        fprintf(stderr, "%s(%d): warning include file '%s' not found!\n",
    17131741                                pszFilename, iLine, szFullname);
     1742                        depMarkNotFound(pvRule);
     1743                    }
    17141744                }
    17151745            }
     
    18401870                }
    18411871                else
     1872                {
    18421873                    fprintf(stderr, "%s(%d): warning include file '%s' not found!\n",
    18431874                            pszFilename, iLine, pszFilename);
     1875                    depMarkNotFound(pvRule);
     1876                }
    18441877            }
    18451878        }
     
    18971930 * @param   pszFilename         Pointer to source filename. Correct case is assumed!
    18981931 * @param   pszNormFilename     Pointer to normalized source filename.
    1899  * @parma   FileDate            Date of the source file.
     1932 * @param   pszTS               File time stamp.
    19001933 * @parma   fHeader             True if header file is being scanned.
    19011934 * @status  completely implemented.
     
    19031936 */
    19041937int langCOBOL(const char *pszFilename, const char *pszNormFilename,
    1905               FDATE FileDate, BOOL fHeader)
     1938              const char *pszTS, BOOL fHeader)
    19061939{
    19071940    void *  pvFile;                     /* Text buffer pointer. */
     
    19181951    {
    19191952        if (options.fNoObjectPath)
    1920             pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszObjectExt, FileDate);
     1953            pvRule = depAddRule(fileNameNoExt(pszFilename, szBuffer), NULL, options.pszObjectExt, pszTS);
    19211954        else
    19221955            pvRule = depAddRule(options.fObjectDir ?
     
    19251958                                fileNameNoExt(pszFilename, szBuffer + CCHMAXPATH),
    19261959                                options.pszObjectExt,
    1927                                 FileDate);
     1960                                pszTS);
    19281961
    19291962        if (options.fSrcWhenObj && pvRule)
     
    19351968    else
    19361969        pvRule = depAddRule(options.fExcludeAll || pathlistFindFile2(options.pszExclude, pszNormFilename) ?
    1937                             fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, FileDate);
     1970                            fileName(pszFilename, szBuffer) : pszNormFilename, NULL, NULL, pszTS);
    19381971
    19391972    /* duplicate rule? */
     
    20462079            }
    20472080            else
     2081            {
    20482082                fprintf(stderr, "%s(%d): warning include file '%s' not found!\n",
    20492083                        pszFilename, iLine, szFullname);
     2084                depMarkNotFound(pvRule);
     2085            }
    20502086        }
    20512087    } /*while*/
     
    29923028BOOL  depReadFile(const char *pszFilename)
    29933029{
    2994     FILESTATUS3 fst3;
    29953030    void *      pvFile;
    29963031    char *      pszNext;
     3032    char *      pszPrev;                /* Previous line, only valid when finding new rule. */
    29973033    BOOL        fMoreDeps = FALSE;
    29983034    void *      pvRule = NULL;
     
    30043040        return FALSE;
    30053041
    3006     /* get the filedate and subtract one month from it. */
    3007     if (!DosQueryPathInfo((PSZ)pszFilename, FIL_STANDARD, &fst3, sizeof(fst3)))
    3008     {
    3009         if (fst3.fdateLastWrite.month <= 1)
    3010         {
    3011             if (fst3.fdateLastWrite.year != 0)
    3012             {
    3013                 fst3.fdateLastWrite.month = 12;
    3014                 fst3.fdateLastWrite.year--;
    3015             }
    3016         }
    3017         else
    3018             fst3.fdateLastWrite.month--;
    3019         options.fDepDate = fst3.fdateLastWrite;
    3020     }
    3021 
    30223042    /* parse the original depend file */
     3043    pszPrev = NULL;
    30233044    pszNext = pvFile;
    30243045    while (*pszNext != '\0')
     
    30573078
    30583079        if (*psz == '#')
     3080        {
     3081            pszPrev = psz;
    30593082            continue;
     3083        }
    30603084
    30613085        /* new rule? */
    3062         if (!fMoreDeps && *psz != ' ' && *psz != '\t' && *psz != '\0')
     3086        if (!fMoreDeps)
    30633087        {
    3064             i = 0;
    3065             while (psz[i] != '\0')
    3066             {
    3067                 if (psz[i] == ':'
    3068                     && (psz[i+1] == ' '
    3069                         || psz[i+1] == '\t'
    3070                         || psz[i+1] == '\0'
    3071                         || (psz[i+1] == '\\' && psz[i+2] == '\0')
     3088            if (*psz != ' ' && *psz != '\t' && *psz != '\0')
     3089            {
     3090                i = 0;
     3091                while (psz[i] != '\0')
     3092                {
     3093                    if (psz[i] == ':'
     3094                        && (psz[i+1] == ' '
     3095                            || psz[i+1] == '\t'
     3096                            || psz[i+1] == '\0'
     3097                            || (psz[i+1] == '\\' && psz[i+2] == '\0')
     3098                            )
    30723099                        )
    3073                     )
    3074                 {
    3075                     static FDATE FileDate = {0,0,0};
    3076                     char *pszCont = strchr(&psz[i], '\\');
    3077                     fMoreDeps = pszCont != NULL && pszCont[1] == '\0';
    3078 
    3079                     psz[i] = '\0';
    3080                     pvRule = depAddRule(trimQuotes(trimR(psz)), NULL, NULL, FileDate);
    3081                     ((PDEPRULE)pvRule)->fUpdated = FALSE;
    3082                     psz += i + 1;
    3083                     cch -= i + 1;
    3084                     break;
     3100                    {
     3101                        char    szTS[TS_SIZE];
     3102                        char *  pszCont = strchr(&psz[i], '\\');
     3103                        fMoreDeps = pszCont != NULL && pszCont[1] == '\0';
     3104
     3105                        /* read evt. timestamp. */
     3106                        szTS[0] = '\0';
     3107                        if (pszPrev && strlen(pszPrev) > 25 && *pszPrev == '#')
     3108                            strcpy(szTS, pszPrev + 2);
     3109
     3110                        psz[i] = '\0';
     3111                        pvRule = depAddRule(trimQuotes(trimR(psz)), NULL, NULL, szTS);
     3112                        ((PDEPRULE)pvRule)->fUpdated = FALSE;
     3113                        psz += i + 1;
     3114                        cch -= i + 1;
     3115                        break;
     3116                    }
     3117                    i++;
    30853118                }
    3086                 i++;
    3087             }
     3119            }
     3120            pszPrev = NULL;
    30883121        }
     3122
    30893123
    30903124        /* more dependants */
     
    31953229        while (pdep != NULL)
    31963230        {
     3231            int cchTS = strlen(pdep->szTS);
    31973232            int fQuoted = strpbrk(pdep->pszRule, " \t") != NULL; /* TODO/BUGBUG/FIXME: are there more special chars to look out for?? */
    31983233
    31993234            /* Write rule. Flush the buffer first if necessary. */
    32003235            cch = strlen(pdep->pszRule);
    3201             if (iBuffer + cch + fQuoted * 2 + 2 >= sizeof(szBuffer))
     3236            if (iBuffer + cch + fQuoted * 2 + cchTS + 9 >= sizeof(szBuffer))
    32023237            {
    32033238                fwrite(szBuffer, iBuffer, 1, phFile);
    32043239                iBuffer = 0;
    32053240            }
     3241
     3242            memcpy(szBuffer + iBuffer, "# ", 2);
     3243            memcpy(szBuffer + iBuffer + 2, pdep->szTS, cchTS);
     3244            iBuffer += cchTS + 2;
     3245            szBuffer[iBuffer++] = '\n';
     3246
    32063247            if (fQuoted) szBuffer[iBuffer++] = '"';
    32073248            strcpy(szBuffer + iBuffer, pdep->pszRule);
     
    33013342 *                          NULL if pszRulePath or pszRulePath and pszName contains the entire rule.
    33023343 */
    3303 void *depAddRule(const char *pszRulePath, const char *pszName, const char *pszExt, FDATE FileDate)
     3344void *depAddRule(const char *pszRulePath, const char *pszName, const char *pszExt, const char *pszTS)
    33043345{
    33053346    char     szRule[CCHMAXPATH*2];
     
    33373378    pNew->cDeps = 0;
    33383379    pNew->papszDep = NULL;
     3380    pNew->fUpdated = TRUE;
    33393381    pNew->avlCore.Key = pNew->pszRule;
    3340     pNew->fUpdated = TRUE;
     3382    strcpy(pNew->szTS, pszTS);
    33413383
    33423384    /* Insert the rule */
     
    33503392         * Reuse the node in the tree.
    33513393         */
    3352         PDEPRULE    pOld = (PDEPRULE)AVLGet((PPAVLNODECORE)(void*)&pdepTree, pNew->avlCore.Key);
     3394        PDEPRULE    pOld = (PDEPRULE)(void*)AVLGet((PPAVLNODECORE)(void*)&pdepTree, pNew->avlCore.Key);
    33533395        assert(pOld);
    33543396        free(pNew);
     
    33573399
    33583400        pOld->fUpdated = TRUE;
    3359         if (!options.fForceScan && *(PUSHORT)&FileDate < *(PUSHORT)&options.fDepDate)
     3401        if (!options.fForceScan && !strcmp(pOld->szTS, pszTS) && depValidate(pOld))
    33603402            return NULL;
     3403        strcpy(pOld->szTS, pszTS);
    33613404
    33623405        if (pOld->papszDep)
     
    34273470    /* successful! */
    34283471    return TRUE;
     3472}
     3473
     3474
     3475/**
     3476 * Marks the file as one which is to be rescanned next time
     3477 * since not all dependencies was found...
     3478 * @param   pvRule  Rule handle...
     3479 */
     3480void  depMarkNotFound(void *pvRule)
     3481{
     3482    ((PDEPRULE)pvRule)->szTS[0] = '\0';
    34293483}
    34303484
     
    34893543
    34903544
     3545/**
     3546 * Validates that the dependencies for the file exists
     3547 * in the given locations. Dependants without path is ignored.
     3548 * @returns TRUE if all ok.
     3549 *          FALSE if one (or possibly more) dependants are non-existing.
     3550 * @param   pdepRule    Pointer to rule we're to validate.
     3551 */
     3552BOOL depValidate(PDEPRULE pdepRule)
     3553{
     3554    int i;
     3555
     3556    for (i = 0; i < pdepRule->cDeps; i++)
     3557    {
     3558        char *psz = pdepRule->papszDep[i];
     3559        if (    psz[1] == ':'
     3560            ||  strchr(psz, '\\')
     3561            ||  strchr(psz, '/')
     3562            )
     3563        {
     3564            /*
     3565             * Check existance of the file.
     3566             *   Search cache first
     3567             */
     3568            if (!filecacheFind(psz))
     3569            {
     3570                char szDir[CCHMAXPATH];
     3571
     3572                filePathSlash(psz, szDir);
     3573                if (!filecacheIsDirCached(szDir))
     3574                {
     3575                    /*
     3576                     * If caching of entire dirs are enabled, we'll
     3577                     * add the directory to the cache and search it.
     3578                     */
     3579                    if (options.fCacheSearchDirs && filecacheAddDir(szDir))
     3580                    {
     3581                        if (!filecacheFind(psz))
     3582                            return FALSE;
     3583                    }
     3584                    else
     3585                    {
     3586                        FILESTATUS3 fsts3;
     3587
     3588                        /* ask the OS */
     3589                        if (DosQueryPathInfo(psz, FIL_STANDARD, &fsts3, sizeof(fsts3)))
     3590                            return FALSE;
     3591                        /* add file to cache. */
     3592                        filecacheAddFile(psz);
     3593                    }
     3594                }
     3595            }
     3596        }
     3597    }
     3598
     3599    return TRUE;
     3600}
     3601
     3602
     3603/**
     3604 * Make a timestamp from the file data provided thru the
     3605 * search API.
     3606 * @returns Pointer to pszTS
     3607 * @param   pszTS       Pointer to timestamp (output).
     3608 * @param   pfindbuf3   Pointer to search result.
     3609 */
     3610INLINE char *depMakeTS(char *pszTS, PFILEFINDBUF3 pfindbuf3)
     3611{
     3612    sprintf(pszTS, "%04d-%02d-%02d-%02d.%02d.%02d 0x%04x%04x %d",
     3613            pfindbuf3->fdateLastWrite.year + 1980,
     3614            pfindbuf3->fdateLastWrite.month,
     3615            pfindbuf3->fdateLastWrite.day,
     3616            pfindbuf3->ftimeLastWrite.hours,
     3617            pfindbuf3->ftimeLastWrite.minutes,
     3618            pfindbuf3->ftimeLastWrite.twosecs * 2,
     3619            (ULONG)*(PUSHORT)(void*)&pfindbuf3->fdateCreation,
     3620            (ULONG)*(PUSHORT)(void*)&pfindbuf3->ftimeCreation,
     3621            pfindbuf3->cbFile);
     3622    return pszTS;
     3623}
     3624
     3625
     3626
    34913627
    34923628
Note: See TracChangeset for help on using the changeset viewer.