diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index 8f861ab0b..59fa59d40 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -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"); diff --git a/src/core/host_interface.h b/src/core/host_interface.h index 8637aa1cd..485c72aff 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -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);