cleaned up several uses of timestamps for filenames

This commit is contained in:
oy 2010-12-08 00:32:50 +01:00
parent 9ef5e64916
commit 665934ee09
3 changed files with 20 additions and 50 deletions

View file

@ -29,7 +29,6 @@
#include <engine/console.h>
#include <math.h>
#include <time.h>
#include "graphics.h"
@ -883,28 +882,11 @@ void CGraphics_SDL::Swap()
{
if(m_DoScreenshot)
{
// find filename
char aFilename[128];
static int Index = 1;
time_t Time;
char aDate[20];
time(&Time);
tm* TimeInfo = localtime(&Time);
strftime(aDate, sizeof(aDate), "%Y-%m-%d_%I-%M", TimeInfo);
for(; Index < 10000; Index++)
{
IOHANDLE io;
str_format(aFilename, sizeof(aFilename), "screenshots/screenshot%s-%05d.png", aDate, Index);
io = m_pStorage->OpenFile(aFilename, IOFLAG_READ, IStorage::TYPE_SAVE);
if(io)
io_close(io);
else
break;
}
str_timestamp(aDate, sizeof(aDate));
str_format(aFilename, sizeof(aFilename), "screenshots/screenshot_%s.png", aDate);
ScreenshotDirect(aFilename);
m_DoScreenshot = false;
}

View file

@ -1,7 +1,6 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <math.h>
#include <time.h>
#include <game/generated/client_data.h>
@ -593,18 +592,11 @@ void CGameConsole::Dump(int Type)
{
CInstance *pConsole = Type == CONSOLETYPE_REMOTE ? &m_RemoteConsole : &m_LocalConsole;
char aFilename[128];
time_t Time;
char aDate[20];
time(&Time);
tm* TimeInfo = localtime(&Time);
strftime(aDate, sizeof(aDate), "%Y-%m-%d_%I-%M", TimeInfo);
for(int i = 0; i < 10; i++)
{
IOHANDLE io;
str_format(aFilename, sizeof(aFilename), "dumps/%s_dump%s-%05d.txt", Type==CONSOLETYPE_REMOTE?"remote_console":"local_console", aDate, i);
io = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);
str_timestamp(aDate, sizeof(aDate));
str_format(aFilename, sizeof(aFilename), "dumps/%s_dump_%s.txt", Type==CONSOLETYPE_REMOTE?"remote_console":"local_console", aDate);
IOHANDLE io = Storage()->OpenFile(aFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);
if(io)
{
#if defined(CONF_FAMILY_WINDOWS)
@ -619,8 +611,6 @@ void CGameConsole::Dump(int Type)
io_write(io, Newline, sizeof(Newline)-1);
}
io_close(io);
break;
}
}
}

View file

@ -1,7 +1,5 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <time.h>
#include <base/math.h>
#include <engine/demo.h>
@ -103,10 +101,10 @@ void CMenus::RenderGame(CUIRect MainView)
if(!Recording)
{
char aFilename[128];
time_t Time;
time(&Time);
tm* TimeInfo = localtime(&Time);
strftime(aFilename, sizeof(aFilename), "demo-%Y-%m-%d_%H-%M-%S", TimeInfo);
char aDate[20];
str_timestamp(aDate, sizeof(aDate));
str_format(aFilename, sizeof(aFilename), "demo_%s.png", aDate);
Client()->DemoRecorder_Start(aFilename);
}
else