Coverage Report

Created: 2026-03-31 07:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/poppler/glib/poppler-input-stream.cc
Line
Count
Source
1
/* poppler-input-stream.cc: glib interface to poppler
2
 *
3
 * Copyright (C) 2012 Carlos Garcia Campos <carlosgc@gnome.org>
4
 * Copyright (C) 2025, 2026 g10 Code GmbH, Author: Sune Stolborg Vuorela <sune@vuorela.dk>
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, or (at your option)
9
 * 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 Street - Fifth Floor, Boston, MA 02110-1301, USA.
19
 */
20
21
#include "config.h"
22
#include "poppler-input-stream.h"
23
24
0
PopplerInputStream::PopplerInputStream(GInputStream *inputStreamA, GCancellable *cancellableA, Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA) : BaseSeekInputStream(startA, limitedA, lengthA, std::move(dictA))
25
0
{
26
0
    inputStream = (GInputStream *)g_object_ref(inputStreamA);
27
0
    cancellable = cancellableA ? (GCancellable *)g_object_ref(cancellableA) : nullptr;
28
0
}
29
30
PopplerInputStream::~PopplerInputStream()
31
0
{
32
0
    close();
33
0
    g_object_unref(inputStream);
34
0
    if (cancellable) {
35
0
        g_object_unref(cancellable);
36
0
    }
37
0
}
38
39
std::unique_ptr<BaseStream> PopplerInputStream::copy()
40
0
{
41
0
    return std::make_unique<PopplerInputStream>(inputStream, cancellable, start, limited, length, dict.copy());
42
0
}
43
44
std::unique_ptr<Stream> PopplerInputStream::makeSubStream(Goffset startA, bool limitedA, Goffset lengthA, Object &&dictA)
45
0
{
46
0
    return std::make_unique<PopplerInputStream>(inputStream, cancellable, startA, limitedA, lengthA, std::move(dictA));
47
0
}
48
49
Goffset PopplerInputStream::currentPos() const
50
0
{
51
0
    GSeekable *seekable = G_SEEKABLE(inputStream);
52
0
    return g_seekable_tell(seekable);
53
0
}
54
55
void PopplerInputStream::setCurrentPos(Goffset offset)
56
0
{
57
0
    GSeekable *seekable = G_SEEKABLE(inputStream);
58
0
    g_seekable_seek(seekable, offset, G_SEEK_SET, cancellable, nullptr);
59
0
}
60
61
Goffset PopplerInputStream::read(char *buffer, Goffset count)
62
0
{
63
0
    return g_input_stream_read(inputStream, buffer, count, cancellable, nullptr);
64
0
}