提交 52ddee97 编写于 作者: J jp9000

UI: Add function to generate time/date filenames

上级 765ac2a7
......@@ -423,34 +423,37 @@ static void get_last_log(void)
}
}
static void create_log_file(fstream &logFile)
string GenerateTimeDateFilename(const char *extension)
{
stringstream dst;
time_t now = time(0);
struct tm *cur_time;
get_last_log();
time_t now = time(0);
char file[256] = {};
struct tm *cur_time;
cur_time = localtime(&now);
if (cur_time) {
char file[256] = {};
snprintf(file, sizeof(file), "%d-%02d-%02d %02d-%02d-%02d.%s",
cur_time->tm_year+1900,
cur_time->tm_mon+1,
cur_time->tm_mday,
cur_time->tm_hour,
cur_time->tm_min,
cur_time->tm_sec,
extension);
return string(file);
}
snprintf(file, sizeof(file), "%d-%02d-%02d %02d-%02d-%02d.txt",
cur_time->tm_year+1900,
cur_time->tm_mon+1,
cur_time->tm_mday,
cur_time->tm_hour,
cur_time->tm_min,
cur_time->tm_sec);
static void create_log_file(fstream &logFile)
{
stringstream dst;
currentLogFile = file;
get_last_log();
dst << "obs-studio/logs/" << file;
currentLogFile = GenerateTimeDateFilename("txt");
dst << "obs-studio/logs/" << currentLogFile.c_str();
BPtr<char> path(os_get_config_path(dst.str().c_str()));
logFile.open(path,
ios_base::in | ios_base::out | ios_base::trunc);
}
BPtr<char> path(os_get_config_path(dst.str().c_str()));
logFile.open(path,
ios_base::in | ios_base::out | ios_base::trunc);
if (logFile.is_open()) {
delete_oldest_log();
......
......@@ -28,6 +28,7 @@
std::string CurrentTimeString();
std::string CurrentDateTimeString();
std::string GenerateTimeDateFilename(const char *extension);
struct BaseLexer {
lexer lex;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册