utils: small tweaks

This commit is contained in:
Dirk-Jan C. Binnema 2023-08-26 18:40:55 +03:00
parent c4a141975e
commit e1308a9b40
3 changed files with 14 additions and 2 deletions

View File

@ -130,12 +130,17 @@ struct TempDir {
*
* @return the path.
*/
const std::string& path() {return path_; }
const std::string& path() const { return path_; }
private:
std::string path_;
const bool autodelete_;
};
static inline auto format_as(const TempDir& td) {
return td.path();
}
/**
* Temporary (RAII) timezone
*/

View File

@ -289,6 +289,13 @@ Mu::run_command(std::initializer_list<std::string> args)
argvec.push_back(g_strdup(arg.c_str()));
argvec.push_back({});
{
std::vector<std::string> qargs{};
for(auto&& arg: args)
qargs.emplace_back("'" + arg + "'");
mu_debug("run-command: {}", fmt::join(qargs, " "));
}
GError *err{};
int wait_status{};
gchar *std_out{}, *std_err{};

View File

@ -145,7 +145,7 @@ auto mu_join(Range&& range, std::string_view sepa) {
return fmt::join(std::forward<Range>(range), sepa);
}
template <typename T>
template <typename T=::time_t>
std::tm mu_time(T t={}, bool use_utc=false) {
::time_t tt{static_cast<::time_t>(t)};
return use_utc ? fmt::gmtime(tt) : fmt::localtime(tt);