forked from Ivasoft/DSView
update: Log file path supports unicode string
This commit is contained in:
@@ -26,14 +26,14 @@
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
#include <QWidget>
|
||||
#include <string>
|
||||
|
||||
#include "devicemanager.h"
|
||||
#include "sigsession.h"
|
||||
#include "dsvdef.h"
|
||||
#include "config/appconfig.h"
|
||||
#include "log.h"
|
||||
#include <QTextCodec>
|
||||
#include <string.h>
|
||||
#include "utility/path.h"
|
||||
|
||||
AppControl::AppControl()
|
||||
{
|
||||
@@ -81,16 +81,10 @@ bool AppControl::Init()
|
||||
}
|
||||
_session->set_sr_context(sr_ctx);
|
||||
|
||||
// firmware resource directory
|
||||
QString resdir = GetResourceDir();
|
||||
char res_path[256] = {0};
|
||||
#ifdef _WIN32
|
||||
QTextCodec *codec = QTextCodec::codecForName("System");
|
||||
QByteArray str_tmp = codec->fromUnicode(resdir);
|
||||
strncpy(res_path, str_tmp.data(), sizeof(res_path) - 1);
|
||||
#else
|
||||
strncpy(res_path, resdir.toUtf8().data(), sizeof(res_path) - 1);
|
||||
#endif
|
||||
sr_set_firmware_resource_dir(res_path);
|
||||
std::string res_path = pv::path::ToUnicodePath(resdir);
|
||||
sr_set_firmware_resource_dir(res_path.c_str());
|
||||
|
||||
#if defined(_WIN32) && defined(DEBUG_INFO)
|
||||
//able run debug with qtcreator
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include "config/appconfig.h"
|
||||
#include "utility/path.h"
|
||||
#include <string>
|
||||
|
||||
xlog_writer *dsv_log = nullptr;
|
||||
static xlog_context *log_ctx = nullptr;
|
||||
@@ -71,10 +73,12 @@ void dsv_log_enalbe_logfile(bool append)
|
||||
|
||||
dsv_info("%s\"%s\"", "Store log to file: ", lf.toUtf8().data());
|
||||
|
||||
int ret = xlog_add_receiver_from_file(log_ctx, lf.toUtf8().data(), &log_file_index, append);
|
||||
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);
|
||||
if (ret != 0){
|
||||
dsv_err("%s", "Create log file error!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
*/
|
||||
|
||||
#include "path.h"
|
||||
#ifdef _WIN32
|
||||
#include <QTextCodec>
|
||||
#endif
|
||||
|
||||
namespace pv{
|
||||
namespace path{
|
||||
@@ -38,5 +41,20 @@ namespace path{
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
std::string ToUnicodePath(QString path)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
#ifdef _WIN32
|
||||
QTextCodec *codec = QTextCodec::codecForName("System");
|
||||
QByteArray str_tmp = codec->fromUnicode(path);
|
||||
str = str_tmp.data();
|
||||
#else
|
||||
str = path.toUtf8().data();
|
||||
#endif
|
||||
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,8 @@ namespace path{
|
||||
std::string ConvertPath(QString fileName);
|
||||
|
||||
QString GetDirectoryName(QString path);
|
||||
|
||||
std::string ToUnicodePath(QString path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user