| iMatix home page
| << | < | > | >>
SFL Logo SFL
Version 2.11

 

file_cycle_needed

#include "sflfile.h"
Bool
file_cycle_needed (
    const char *filename,
    int how)

Synopsis

Checks whether the file should be cycled or not. Returns TRUE if the file needs to be cycled, FALSE if not. The how argument must be one of:
CYCLE ALWAYS Cycle file unconditionally
CYCLE HOURLY Cycle file if hour has changed
CYCLE DAILY Cycle file if day has changed
CYCLE WEEKLY Cycle file if week has changed
CYCLE MONTHLY Cycle file if month has changed
CYCLE NEVER Don't cycle the file
If the specified file does not exist or is not accessible, returns FALSE.

Source Code - (sflfile.c)

{
    long
        curr_time,                      /*  Current time                     */
        curr_date,                      /*  Current date                     */
        file_date,                      /*  Timestamp of file                */
        file_time;                      /*  Datestamp of file                */
    Bool
        cycle;                          /*  Do we want to cycle the file?    */

    ASSERT (filename);
    if (!file exists (filename))        /*  Not found - nothing more to do   */
        return (FALSE);

    file_time = timer to time (get file time (filename));
    file_date = timer to date (get file time (filename));
    curr_time = time now ();
    curr_date = date now ();

    switch (how)
      {
        case CYCLE_ALWAYS:
            cycle = TRUE;
            break;
        case CYCLE_HOURLY:
            cycle = GET_HOUR (file_time) != GET_HOUR (curr_time);
            break;
        case CYCLE_DAILY:
            cycle = GET_DAY (file_date) != GET_DAY (curr_date);
            break;
        case CYCLE_WEEKLY:
            cycle = week of year (file_date) != week of year (curr_date);
            break;
        case CYCLE_MONTHLY:
            cycle = GET_MONTH (file_date) != GET_MONTH (curr_date);
            break;
        case CYCLE_NEVER:
            cycle = FALSE;
            break;
        default:
            cycle = FALSE;
      }
    return (cycle);
}

| << | < | > | >> iMatix Copyright © 1996-2000 iMatix Corporation