From 00c853de31a77189552f575b334e4c859756bffb Mon Sep 17 00:00:00 2001 From: dreamsourcelabTAI Date: Tue, 16 Jan 2024 15:32:49 +0800 Subject: [PATCH] fix: unable to create log directory --- DSView/pv/log.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DSView/pv/log.cpp b/DSView/pv/log.cpp index c92f1fda..76d8b7b0 100644 --- a/DSView/pv/log.cpp +++ b/DSView/pv/log.cpp @@ -67,6 +67,14 @@ void dsv_log_enalbe_logfile(bool append) dsv_info("%s\"%s\"", "Store log to file: ", lf.toUtf8().data()); + QFileInfo fileInfo(lf); + QString file_dir = fileInfo.absolutePath(); + + QDir dir; + if (!dir.exists(file_dir) && !dir.mkpath(file_dir)){ + dsv_err("ERROR: failed to create log directory."); + } + std::string log_file = pv::path::ToUnicodePath(lf); int ret = xlog_add_receiver_from_file(log_ctx, log_file.c_str(), &log_file_index, append); @@ -133,4 +141,4 @@ QString get_dsv_log_path() #endif return lf; -} \ No newline at end of file +}