File* File::create(QString name) { if (sr_session_load(name.toLocal8Bit().data()) == SR_OK) { GSList *devlist = NULL; sr_session_dev_list(&devlist); sr_session_destroy(); if (devlist) { sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data; g_slist_free(devlist); if (sdi) { sr_dev_close(sdi); sr_dev_clear(sdi->driver); return new SessionFile(name); } } } return new InputFile(name); }
void SessionFile::use(SigSession *owner) throw(QString) { assert(!_sdi); if (sr_session_load(_path.c_str()) != SR_OK) throw tr("Failed to open file.\n"); GSList *devlist = NULL; sr_session_dev_list(&devlist); if (!devlist || !devlist->data) { if (devlist) g_slist_free(devlist); throw tr("Failed to start session."); } _sdi = (sr_dev_inst*)devlist->data; g_slist_free(devlist); File::use(owner); }
File* File::create(const string &name) { struct sr_session *temp_session; if (sr_session_load(name.c_str(), &temp_session) == SR_OK) { GSList *devlist = NULL; sr_session_dev_list(temp_session, &devlist); sr_session_destroy(temp_session); if (devlist) { sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data; g_slist_free(devlist); if (sdi) { sr_dev_close(sdi); sr_dev_clear(sdi->driver); return new SessionFile(name); } } } return NULL; }