~ubuntu-branches/ubuntu/wily/sysdig/wily

« back to all changes in this revision

Viewing changes to userspace/libsinsp/dumper.cpp

  • Committer: Package Import Robot
  • Author(s): Evgeni Golov
  • Date: 2014-05-01 14:53:09 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140501145309-yy0hkts9nlu43omp
Tags: 0.1.81-1
* New upstream release
* Add B-D on zlib1g-dev and use it for building
* drop LuaJIT from debian/copyright, upstream does not ship the
  copy anymore
* Only require and execute dh_dkms when building arch-independent
  stuff

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
        }
36
36
}
37
37
 
38
 
void sinsp_dumper::open(const string& filename)
 
38
void sinsp_dumper::open(const string& filename, bool compress)
39
39
{
40
40
        if(m_inspector->m_h == NULL)
41
41
        {
42
42
                throw sinsp_exception("can't start event dump, inspector not opened yet");
43
43
        }
44
44
 
45
 
        m_dumper = scap_dump_open(m_inspector->m_h, filename.c_str());
 
45
        if(compress)
 
46
        {
 
47
                m_dumper = scap_dump_open(m_inspector->m_h, filename.c_str(), SCAP_COMPRESSION_GZIP);
 
48
        }
 
49
        else
 
50
        {
 
51
                m_dumper = scap_dump_open(m_inspector->m_h, filename.c_str(), SCAP_COMPRESSION_NONE);
 
52
        }
 
53
 
46
54
        if(m_dumper == NULL)
47
55
        {
48
56
                throw sinsp_exception(scap_getlasterr(m_inspector->m_h));
72
80
                throw sinsp_exception("dumper not opened yet");
73
81
        }
74
82
 
75
 
        return scap_dump_ftell(m_dumper);       
 
83
        int64_t written_bytes = scap_dump_get_offset(m_dumper);
 
84
        if(written_bytes == -1)
 
85
        {
 
86
                throw sinsp_exception("error getting offset");          
 
87
        }
 
88
 
 
89
        return written_bytes;
 
90
}
 
91
 
 
92
void sinsp_dumper::flush()
 
93
{
 
94
        if(m_dumper == NULL)
 
95
        {
 
96
                throw sinsp_exception("dumper not opened yet");
 
97
        }
 
98
 
 
99
        scap_dump_flush(m_dumper);
76
100
}