mightymandel v16

GPU-based Mandelbrot set explorer

filename.c
Go to the documentation of this file.
1 // mightymandel -- GPU-based Mandelbrot Set explorer
2 // Copyright (C) 2012,2013,2014,2015 Claude Heiland-Allen
3 // License GPL3+ http://www.gnu.org/licenses/gpl.html
4 
5 #include <stdio.h>
6 #include <string.h>
7 #include <time.h>
8 
9 #include "filename.h"
10 
11 void filename_begin(struct filename *s) {
12  time(&s->t);
13 #ifndef MIGHTYMANDEL_WIN32
14  localtime_r(&s->t, &s->tm);
15 #else
16  memset(&s->tm, 0, sizeof(s->tm));
17 #endif
18 }
19 
20 char *filename_name(struct filename *s, const char *ext, int seqno, int tilex, int tiley) {
21  char name[1024];
22  if (tilex == -1 && tiley == -1) {
23  snprintf(name, 1000, "mightymandel_%04d-%02d-%02d_%02d-%02d-%02d_%04d.%s", 1900+s->tm.tm_year, 1+s->tm.tm_mon, s->tm.tm_mday, s->tm.tm_hour, s->tm.tm_min, s->tm.tm_sec, seqno, ext);
24  } else {
25  snprintf(name, 1000, "mightymandel_%04d-%02d-%02d_%02d-%02d-%02d_%04d_%02d_%02d.%s", 1900+s->tm.tm_year, 1+s->tm.tm_mon, s->tm.tm_mday, s->tm.tm_hour, s->tm.tm_min, s->tm.tm_sec, seqno, tiley, tilex, ext);
26  }
27  return strdup(name);
28 }