From 752c3f1a0cf7e52df29630afaaf422746dea7643 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Thu, 12 Nov 2020 22:17:34 +0100 Subject: [PATCH] helpers: add function to get backup suffix Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/427a949807d82cebb57f5b4c0b946420e665d272 Author: vanhofen Date: 2020-11-12 (Thu, 12 Nov 2020) Origin message was: ------------------ - helpers: add function to get backup suffix --- src/system/helpers.cpp | 8 ++++++++ src/system/helpers.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index ecff434b2..5abb2b9bb 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -54,6 +54,7 @@ //#include #include #include +#include #include #include #define MD5_DIGEST_LENGTH 16 @@ -623,6 +624,13 @@ std::string getFileExt(std::string &file) return _getBaseName(f, "."); } +std::string getBackupSuffix() +{ + std::string hostName = ""; + netGetHostname(hostName); + + return hostName + getNowTimeStr("_%Y%m%d_%H%M"); +} std::string getNowTimeStr(const char* format) { diff --git a/src/system/helpers.h b/src/system/helpers.h index 8ef730d52..75e3e4107 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -71,6 +71,7 @@ std::string getPathName(std::string &path); std::string getBaseName(std::string &path); std::string getFileName(std::string &file); std::string getFileExt(std::string &file); +std::string getBackupSuffix(); std::string getNowTimeStr(const char* format); std::string trim(std::string &str, const std::string &trimChars = " \n\r\t"); std::string ltrim(std::string &str, const std::string &trimChars = " \n\r\t");