projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix #733: Open import files using binary mode
[pulseview.git]
/
pv
/
devices
/
inputfile.cpp
diff --git
a/pv/devices/inputfile.cpp
b/pv/devices/inputfile.cpp
index 13af3db9cd85c791935da6c80bf1a14220d492a0..22c9b1c8297e4e3d8d71eb73d925c122fc67c8f9 100644
(file)
--- a/
pv/devices/inputfile.cpp
+++ b/
pv/devices/inputfile.cpp
@@
-37,27
+37,32
@@
InputFile::InputFile(const std::shared_ptr<sigrok::Context> &context,
File(file_name),
context_(context),
input_(format->create_input(options)),
File(file_name),
context_(context),
input_(format->create_input(options)),
- interrupt_(false) {
+ interrupt_(false)
+{
if (!input_)
throw QString("Failed to create input");
}
if (!input_)
throw QString("Failed to create input");
}
-void InputFile::open() {
+void InputFile::open()
+{
if (session_)
close();
session_ = context_->create_session();
}
if (session_)
close();
session_ = context_->create_session();
}
-void InputFile::close() {
+void InputFile::close()
+{
if (session_)
session_->remove_devices();
}
if (session_)
session_->remove_devices();
}
-void InputFile::start() {
+void InputFile::start()
+{
}
}
-void InputFile::run() {
+void InputFile::run()
+{
char buffer[BufferSize];
bool need_device = true;
char buffer[BufferSize];
bool need_device = true;
@@
-65,7
+70,7
@@
void InputFile::run() {
assert(input_);
interrupt_ = false;
assert(input_);
interrupt_ = false;
- std::ifstream f(file_name_);
+ std::ifstream f(file_name_
, std::ios::binary
);
while (!interrupt_ && f) {
f.read(buffer, BufferSize);
const std::streamsize size = f.gcount();
while (!interrupt_ && f) {
f.read(buffer, BufferSize);
const std::streamsize size = f.gcount();
@@
-92,7
+97,8
@@
void InputFile::run() {
input_->end();
}
input_->end();
}
-void InputFile::stop() {
+void InputFile::stop()
+{
interrupt_ = true;
}
interrupt_ = true;
}