]> sigrok.org Git - pulseview.git/blame - pv/device/file.cpp
Don't attempt to set SR_CONF_LIMIT_SAMPLES when it's not supported
[pulseview.git] / pv / device / file.cpp
CommitLineData
ae2d1bc5
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2014 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "file.h"
22#include "inputfile.h"
23#include "sessionfile.h"
24
25#include <libsigrok/libsigrok.h>
26
27using std::string;
28
29namespace pv {
30namespace device {
31
32File::File(const std::string path) :
33 _path(path)
34{
35}
36
37std::string File::format_device_title() const
38{
39 return _path;
40}
41
42File* File::create(const string &name)
43{
44 if (sr_session_load(name.c_str()) == SR_OK) {
45 GSList *devlist = NULL;
46 sr_session_dev_list(&devlist);
47 sr_session_destroy();
48
49 if (devlist) {
50 sr_dev_inst *const sdi = (sr_dev_inst*)devlist->data;
51 g_slist_free(devlist);
52 if (sdi) {
53 sr_dev_close(sdi);
54 sr_dev_clear(sdi->driver);
55 return new SessionFile(name);
56 }
57 }
58 }
59
60 return new InputFile(name);
61}
62
63} // device
64} // pv