/src/poppler/poppler/FILECacheLoader.cc
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // FILECacheLoader.cc |
4 | | // |
5 | | // This file is licensed under the GPLv2 or later |
6 | | // |
7 | | // Copyright 2010 Hib Eris <hib@hiberis.nl> |
8 | | // Copyright 2010, 2022, 2025 Albert Astals Cid <aacid@kde.org> |
9 | | // Copyright 2010 Jonathan Liu <net147@gmail.com> |
10 | | // Copyright 2021 Peter Williams <peter@newton.cx> |
11 | | // Copyright 2021 Christian Persch <chpe@src.gnome.org> |
12 | | // |
13 | | //======================================================================== |
14 | | |
15 | | #include <config.h> |
16 | | |
17 | | #include "FILECacheLoader.h" |
18 | | |
19 | | #if defined(_WIN32) || defined(__CYGWIN__) |
20 | | # include <fcntl.h> // for O_BINARY |
21 | | # include <io.h> // for _setmode |
22 | | #endif |
23 | | |
24 | | FILECacheLoader::~FILECacheLoader() |
25 | 0 | { |
26 | 0 | if (file != stdin) { |
27 | 0 | fclose(file); |
28 | 0 | } |
29 | 0 | } |
30 | | |
31 | | size_t FILECacheLoader::init(CachedFile *cachedFile) |
32 | 0 | { |
33 | 0 | size_t read, size = 0; |
34 | 0 | char buf[CachedFileChunkSize]; |
35 | |
|
36 | | #if defined(_WIN32) || defined(__CYGWIN__) |
37 | | _setmode(fileno(file), O_BINARY); |
38 | | #endif |
39 | |
|
40 | 0 | CachedFileWriter writer = CachedFileWriter(cachedFile, nullptr); |
41 | 0 | do { |
42 | 0 | read = fread(buf, 1, CachedFileChunkSize, file); |
43 | 0 | (writer.write)(buf, CachedFileChunkSize); |
44 | 0 | size += read; |
45 | 0 | } while (read == CachedFileChunkSize); |
46 | |
|
47 | 0 | return size; |
48 | 0 | } |
49 | | |
50 | | int FILECacheLoader::load(const std::vector<ByteRange> & /*ranges*/, CachedFileWriter * /*writer*/) |
51 | 0 | { |
52 | 0 | return 0; |
53 | 0 | } |