| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflfile.h" Bool file_cycle_needed ( const char *filename, int how)
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 |
{ 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); }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |