|
bool elaboradar::Assets::save_acq_time |
( |
time_t |
acq_time = 0 | ) |
|
Save acq_time in $LAST_FILE, comparing it with the previous value.
- Parametri
-
[in] | acq_time | - Volume acquisition time |
- Restituisce
- false, if acq_time is older than the previous file processed
-
true, if acq_time is newer, if $LAST_FILE does not exist or if $LAST_FILE is not set.
Definizione alla linea 53 del file assets.cpp.
55 if (acq_time == 0) acq_time = conf_acq_time;
58 const char* last_file = getenv( "LAST_FILE");
59 if (last_file == NULL)
61 LOG_INFO( "$LAST_FILE not set");
68 FILE* fp = fopen(last_file, "r");
73 LOG_INFO( "$LAST_FILE=%s does not exist", last_file);
79 if (fread(&last_time, 4, 1, fp) != 1)
81 LOG_INFO( "$LAST_FILE=%s cannot be read", last_file);
88 int diff = acq_time - last_time;
89 LOG_INFO( "%s: new acq_time is old %c %d", last_file, diff < 0 ? '-' : '+', abs(diff));
92 if (acq_time <= last_time)
97 if ((fp = fopen(last_file, "w")) == NULL)
99 LOG_WARN( "cannot write to %s: %s", last_file, strerror(errno));
100 throw std::runtime_error( "cannot (re)create $LAST_FILE");
104 last_time = acq_time;
105 if (fwrite(&last_time, 4, 1, fp) != 1)
107 LOG_WARN( "cannot write to %s: %s", last_file, strerror(errno));
108 throw std::runtime_error( "cannot write to $LAST_FILE");
|