#include <sys/stat.h>
#include <QDebug>
+#include <QDir>
#include <QFileInfo>
#include "devicemanager.hpp"
settings.endGroup();
}
- shared_ptr<devices::SessionFile> sessionfile_device =
- dynamic_pointer_cast<devices::SessionFile>(device_);
-
- if (sessionfile_device) {
+ // Having saved the data to srzip overrides the current device. This is
+ // a crappy hack around the fact that saving e.g. an imported file to
+ // srzip would require changing the underlying libsigrok device
+ if (!save_path_.isEmpty()) {
+ QFileInfo fi = QFileInfo(QDir(save_path_), name_);
settings.setValue("device_type", "sessionfile");
settings.beginGroup("device");
- settings.setValue("filename", QString::fromStdString(
- sessionfile_device->full_name()));
+ settings.setValue("filename", fi.absoluteFilePath());
settings.endGroup();
- }
+ } else {
+ shared_ptr<devices::SessionFile> sessionfile_device =
+ dynamic_pointer_cast<devices::SessionFile>(device_);
+
+ if (sessionfile_device) {
+ settings.setValue("device_type", "sessionfile");
+ settings.beginGroup("device");
+ settings.setValue("filename", QString::fromStdString(
+ sessionfile_device->full_name()));
+ settings.endGroup();
+ }
- shared_ptr<devices::InputFile> inputfile_device =
- dynamic_pointer_cast<devices::InputFile>(device_);
+ shared_ptr<devices::InputFile> inputfile_device =
+ dynamic_pointer_cast<devices::InputFile>(device_);
- if (inputfile_device) {
- settings.setValue("device_type", "inputfile");
- settings.beginGroup("device");
- inputfile_device->save_meta_to_settings(settings);
- settings.endGroup();
+ if (inputfile_device) {
+ settings.setValue("device_type", "inputfile");
+ settings.beginGroup("device");
+ inputfile_device->save_meta_to_settings(settings);
+ settings.endGroup();
+ }
}
save_setup(settings);
}
if (!selection_only) {
- session_.set_name(QFileInfo(file_name).fileName());
-
- if (format == session_.device_manager().context()->output_formats()["srzip"])
+ if (format == session_.device_manager().context()->output_formats()["srzip"]) {
session_.set_save_path(QFileInfo(file_name).absolutePath());
- else
+ session_.set_name(QFileInfo(file_name).fileName());
+ } else
session_.set_save_path("");
}
return;
}
- QFileInfo fi = QFileInfo(session_.save_path(), session_.name());
+ QFileInfo fi = QFileInfo(QDir(session_.save_path()), session_.name());
export_file(session_.device_manager().context()->output_formats()["srzip"], false,
fi.absoluteFilePath());
}