HostInterface: Add a helper function for generating timestamp-based filenames

This commit is contained in:
Connor McLaughlin 2020-03-15 22:03:53 +10:00
parent c7a74cabaa
commit 198a64eb5e
2 changed files with 13 additions and 0 deletions

View File

@ -696,6 +696,15 @@ std::string HostInterface::GetUserDirectoryRelativePath(const char* format, ...)
}
}
TinyString HostInterface::GetTimestampStringForFileName()
{
const Timestamp ts(Timestamp::Now());
TinyString str;
ts.ToString(str, "%Y-%m-%d_%H-%M-%S");
return str;
}
std::string HostInterface::GetSettingsFileName() const
{
return GetUserDirectoryRelativePath("settings.ini");

View File

@ -1,4 +1,5 @@
#pragma once
#include "common/string.h"
#include "common/timer.h"
#include "settings.h"
#include "types.h"
@ -86,6 +87,9 @@ public:
/// Returns a path relative to the user directory.
std::string GetUserDirectoryRelativePath(const char* format, ...) const;
/// Returns a string which can be used as part of a filename, based on the current date/time.
static TinyString GetTimestampStringForFileName();
/// Displays a loading screen with the logo, rendered with ImGui. Use when executing possibly-time-consuming tasks
/// such as compiling shaders when starting up.
void DisplayLoadingScreen(const char* message, int progress_min = -1, int progress_max = -1, int progress_value = -1);