Some small updates to the way filenames are generated for the screenshots
This commit is contained in:
@@ -157,24 +157,26 @@ char *generate_filename(void)
|
|||||||
while (*tmp!=0) tmp++;
|
while (*tmp!=0) tmp++;
|
||||||
while ((*tmp!='/') && (tmp!=&fnames)) tmp--;
|
while ((*tmp!='/') && (tmp!=&fnames)) tmp--;
|
||||||
tmp++;
|
tmp++;
|
||||||
// I assume that fnames has already an extension
|
|
||||||
// allocates enough memory to store the filename
|
// allocates enough memory to store the filename
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
filename = (char *)malloc(strlen(tmp)+6);
|
filename = (char *)malloc(strlen(tmp)+10);
|
||||||
#endif
|
#endif
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
filename = (char *)malloc(strlen(tmp)+25);
|
filename = (char *)malloc(strlen(tmp)+25);
|
||||||
#endif
|
#endif
|
||||||
strcpy(filename, tmp);
|
strcpy(filename, tmp);
|
||||||
tmp = filename;
|
tmp = filename;
|
||||||
while (*tmp!='.') tmp++;
|
while (*tmp!='.') {
|
||||||
|
if (*tmp == ' ') *tmp = '_';
|
||||||
|
tmp++;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
/*get system time.*/
|
/*get system time.*/
|
||||||
GetLocalTime(&time);
|
GetLocalTime(&time);
|
||||||
|
|
||||||
/*make filename from local time*/
|
/*make filename from local time*/
|
||||||
wsprintf(tmp," %d_%02d_%02d_%02d-%02d-%02d.png\0", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
|
wsprintf(tmp," %d %02d_%02d %02d-%02d-%02d.png\0", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
|
||||||
#endif
|
#endif
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
/*find first unused file*/
|
/*find first unused file*/
|
||||||
@@ -183,9 +185,7 @@ char *generate_filename(void)
|
|||||||
|
|
||||||
for(i=0;i<10000;i++)
|
for(i=0;i<10000;i++)
|
||||||
{
|
{
|
||||||
if(i>1000)
|
sprintf(tmp, "_%04d.png", i);
|
||||||
sprintf(tmp, " %03d.png", i);
|
|
||||||
else sprintf(tmp, " %04d.png", i);
|
|
||||||
if(stat(filename, &buf)==-1)
|
if(stat(filename, &buf)==-1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user