mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-13 13:32:53 +08:00
update: install file, and save file name convert
This commit is contained in:
parent
b0d811604b
commit
ccfb6af655
@ -22,19 +22,21 @@
|
||||
#include "file.h"
|
||||
#include "inputfile.h"
|
||||
#include "sessionfile.h"
|
||||
#include <string.h>
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <zip.h>
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
using std::string;
|
||||
#ifdef _WIN32
|
||||
#include <QTextCodec>
|
||||
#endif
|
||||
|
||||
namespace pv {
|
||||
namespace device {
|
||||
|
||||
File::File(QString path) :
|
||||
_path(path)
|
||||
File::File(QString path)
|
||||
:_path(path)
|
||||
{
|
||||
}
|
||||
|
||||
@ -50,7 +52,10 @@ QString File::format_device_title()
|
||||
|
||||
File* File::create(QString name)
|
||||
{
|
||||
if (sr_session_load(name.toUtf8().data()) == SR_OK) {
|
||||
char f_name[256];
|
||||
File::ConvertFileName(name, f_name, sizeof(f_name));
|
||||
|
||||
if (sr_session_load(f_name) == SR_OK) {
|
||||
GSList *devlist = NULL;
|
||||
sr_session_dev_list(&devlist);
|
||||
sr_session_destroy();
|
||||
@ -79,7 +84,10 @@ QJsonArray File::get_decoders()
|
||||
QJsonArray dec_array;
|
||||
QJsonParseError error;
|
||||
|
||||
archive = zip_open(_path.toUtf8().data(), 0, &ret);
|
||||
char f_name[256];
|
||||
File::ConvertFileName(_path, f_name, sizeof(f_name));
|
||||
|
||||
archive = zip_open(f_name, 0, &ret);
|
||||
if (archive) {
|
||||
/* read "decoders" */
|
||||
if (zip_stat(archive, "decoders", 0, &zs) != -1) {
|
||||
@ -111,7 +119,10 @@ QJsonDocument File::get_session()
|
||||
QJsonDocument sessionDoc;
|
||||
QJsonParseError error;
|
||||
|
||||
archive = zip_open(_path.toUtf8().data(), 0, &ret);
|
||||
char f_name[256];
|
||||
File::ConvertFileName(_path, f_name, sizeof(f_name));
|
||||
|
||||
archive = zip_open(f_name, 0, &ret);
|
||||
if (archive) {
|
||||
/* read "decoders" */
|
||||
if (zip_stat(archive, "session", 0, &zs) != -1) {
|
||||
@ -132,5 +143,29 @@ QJsonDocument File::get_session()
|
||||
return sessionDoc;
|
||||
}
|
||||
|
||||
void File::ConvertFileName(QString fileName, char *out_name, int size)
|
||||
{
|
||||
assert(out_name);
|
||||
assert(size > 0);
|
||||
memset(out_name, 0, size);
|
||||
|
||||
char *src = NULL;
|
||||
#ifdef _WIN32
|
||||
QTextCodec *code = QTextCodec::codecForName("GB2312");
|
||||
if (code != NULL){
|
||||
src = code->fromUnicode(fileName).data();
|
||||
}
|
||||
#endif
|
||||
if (src == NULL){
|
||||
src = fileName.toUtf8().data();
|
||||
}
|
||||
|
||||
int len = strlen(src);
|
||||
if (len >= size){
|
||||
assert(false);
|
||||
}
|
||||
strcpy(out_name, src);
|
||||
}
|
||||
|
||||
} // device
|
||||
} // pv
|
||||
|
@ -22,8 +22,6 @@
|
||||
#ifndef DSVIEW_PV_DEVICE_FILE_H
|
||||
#define DSVIEW_PV_DEVICE_FILE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <QJsonArray>
|
||||
#include <QJsonDocument>
|
||||
#include <QFile>
|
||||
@ -43,14 +41,14 @@ public:
|
||||
~File();
|
||||
|
||||
static File* create(QString name);
|
||||
|
||||
QJsonArray get_decoders();
|
||||
|
||||
QJsonDocument get_session();
|
||||
|
||||
public:
|
||||
QString format_device_title();
|
||||
|
||||
static void ConvertFileName(QString fileName, char *out_name, int size);
|
||||
|
||||
protected:
|
||||
const QString _path;
|
||||
};
|
||||
|
@ -43,7 +43,10 @@ void SessionFile::use(SigSession *owner)
|
||||
release_source();
|
||||
}
|
||||
|
||||
if (sr_session_load(_path.toUtf8().data()) != SR_OK)
|
||||
char f_name[256];
|
||||
File::ConvertFileName(_path, f_name, sizeof(f_name));
|
||||
|
||||
if (sr_session_load(f_name) != SR_OK)
|
||||
throw tr("Failed to open file.\n");
|
||||
|
||||
GSList *devlist = NULL;
|
||||
|
@ -181,7 +181,7 @@ bool StoreSession::save_start()
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string _filename = getFileName(_file_name);
|
||||
std::string _filename = getFileName();
|
||||
if (m_zipDoc.CreateNew(_filename.c_str(), false))
|
||||
{
|
||||
if ( !m_zipDoc.AddFromBuffer("header", meta_data.c_str(), meta_data.size())
|
||||
@ -948,7 +948,8 @@ bool StoreSession::json_decoders(QJsonArray &array)
|
||||
auto rows = stack->get_rows_gshow();
|
||||
for (auto i = rows.begin(); i != rows.end(); i++) {
|
||||
pv::data::decode::Row _row = (*i).first;
|
||||
show_obj[_row.title()] = QJsonValue::fromVariant((*i).second);
|
||||
QString kn = _row.title();
|
||||
show_obj[kn] = QJsonValue::fromVariant((*i).second);
|
||||
}
|
||||
dec_obj["show"] = show_obj;
|
||||
|
||||
@ -1323,14 +1324,15 @@ void StoreSession::MakeChunkName(char *chunk_name, int chunk_num, int index, int
|
||||
}
|
||||
}
|
||||
|
||||
std::string StoreSession::getFileName(QString fileName)
|
||||
std::string StoreSession::getFileName()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#ifdef _WIN32
|
||||
QTextCodec *code = QTextCodec::codecForName("GB2312");
|
||||
return code->fromUnicode(fileName).data();
|
||||
#else
|
||||
return _file_name.toUtf8().toStdString();
|
||||
if (code != NULL){
|
||||
return code->fromUnicode(_file_name).data();
|
||||
}
|
||||
#endif
|
||||
return _file_name.toUtf8().toStdString();
|
||||
}
|
||||
|
||||
} // pv
|
||||
|
@ -94,7 +94,7 @@ private:
|
||||
QList<QString> getSuportedExportFormats();
|
||||
double get_integer(GVariant * var);
|
||||
void MakeChunkName(char *chunk_name, int chunk_num, int index, int type, int version);
|
||||
std:: string getFileName(QString fileName);
|
||||
std:: string getFileName();
|
||||
|
||||
signals:
|
||||
void progress_updated();
|
||||
|
46
INSTALL
46
INSTALL
@ -8,26 +8,20 @@ Requirements
|
||||
- gcc (>= 4.0)
|
||||
- g++
|
||||
- make
|
||||
- libtool
|
||||
- autoconf >= 2.63
|
||||
- automake >= 1.11
|
||||
- cmake >= 2.6
|
||||
- Qt >= 5.0
|
||||
- libtool
|
||||
- libglib >= 2.32.0
|
||||
- libzip >= 0.10
|
||||
- zlib
|
||||
- libusb-1.0 >= 1.0.16
|
||||
On FreeBSD, this is an integral part of the FreeBSD libc, not an extra package/library.
|
||||
This is part of the standard OpenBSD install (not an extra package), apparently.
|
||||
- libboost >= 1.42 (including the following libs):
|
||||
- libboost-system
|
||||
- pkg-config >= 0.22
|
||||
This is part of the standard OpenBSD install (not an extra package), apparently.
|
||||
- check >= 0.9.4 (optional, only needed to run unit tests)
|
||||
- libboost >= 1.42
|
||||
- libfftw3 >= 3.3
|
||||
- zlib (on ubuntu, zlib package name is zlib1g-dev)
|
||||
|
||||
|
||||
- libpython > 3.2
|
||||
- libtool
|
||||
- pkg-config >= 0.22
|
||||
|
||||
|
||||
Building and installing
|
||||
-----------------------
|
||||
@ -36,18 +30,30 @@ Step1: Installing the requirements:
|
||||
|
||||
please check your respective distro's package manager tool if you use other distros
|
||||
Debian/Ubuntu:
|
||||
$ sudo apt-get install git-core build-essential cmake autoconf automake libtool pkg-config \
|
||||
libglib2.0-dev libzip-dev libudev-dev libusb-1.0-0-dev \
|
||||
python3-dev qt5-default qtbase5-dev libboost-dev libboost-test-dev check libfftw3-dev
|
||||
$ sudo apt install git gcc g++ make cmake qt5-default libglib2.0-dev libzip-dev zlib1g-dev \
|
||||
libusb-1.0-0-dev libboost-dev libfftw3-dev python3-dev libudev-dev
|
||||
|
||||
How to install qt on ubuntu?
|
||||
qt5: qt5-default,qtbase5-dev
|
||||
qt6: qt6-base-dev,libQt6Svg*
|
||||
|
||||
Fedora (18, 19):
|
||||
$ sudo yum install git gcc g++ make cmake autoconf automake libtool pkgconfig glib2-devel \
|
||||
$ sudo yum install git gcc g++ make cmake libtool pkgconfig glib2-devel \
|
||||
libzip-devel libudev-devel libusb1-devel \
|
||||
python3-devel qt-devel boost-devel check libfftw3-devel
|
||||
python3-devel qt-devel boost-devel libfftw3-devel
|
||||
|
||||
Arch:
|
||||
$ pacman -S base-devel git cmake glib2 libzip libusb check
|
||||
$ pacman -S base-devel git cmake glib2 libzip libusb
|
||||
python boost qt5 fftw
|
||||
|
||||
Mac:
|
||||
install Xcode
|
||||
install hombrew
|
||||
brew install git
|
||||
brew install gcc
|
||||
brew install g++
|
||||
brew install make
|
||||
brew install cmake
|
||||
|
||||
|
||||
Step2: Get the DSView source code
|
||||
@ -59,6 +65,8 @@ Step3: Building
|
||||
$ sudo make install
|
||||
|
||||
See the following wiki page for more (OS-specific) instructions:
|
||||
|
||||
http://sigrok.org/wiki/Building
|
||||
|
||||
The latest source code:
|
||||
https://github.com/DreamSourceLab/DSView
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user