*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
char *name;
int failed;
int serial;
+ int flight;
int sequence;
};
aoview_file_start(struct aoview_file *file)
{
char base[50];
+ char seq[20];
struct tm tm;
time_t now;
char *full;
if (file->failed)
return FALSE;
- now = time(NULL);
- (void) localtime_r(&now, &tm);
- aoview_mkdir(aoview_file_dir);
- for (;;) {
- snprintf(base, sizeof (base), "%04d-%02d-%02d-serial-%03d-flight-%03d.%s",
- tm.tm_year + 1900,
- tm.tm_mon + 1,
- tm.tm_mday,
- file->serial,
- file->sequence,
- file->ext);
- full = aoview_fullname(aoview_file_dir, base);
- r = access(full, F_OK);
- if (r < 0) {
- file->file = fopen(full, "w");
- if (!file->file) {
- aoview_file_open_failed(full);
- free(full);
- file->failed = 1;
- return FALSE;
- } else {
- setlinebuf(file->file);
- file->name = full;
- return TRUE;
- }
- }
+ full = cc_make_filename(file->serial, file->flight, file->ext);
+ file->file = fopen(full, "w");
+ if (!file->file) {
+ aoview_file_open_failed(full);
free(full);
- file->sequence++;
+ file->failed = 1;
+ return FALSE;
+ } else {
+ setlinebuf(file->file);
+ file->name = full;
+ return TRUE;
}
}
return file->serial;
}
+void
+aoview_file_set_flight(struct aoview_file *file, int flight)
+{
+ if (flight != file->flight)
+ aoview_file_finish(file);
+ file->flight = flight;
+}
+
+int
+aoview_file_get_flight(struct aoview_file *file)
+{
+ return file->flight;
+}
+
void
aoview_file_init(GladeXML *xml)
{