beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / StdinCachedFile.cc
blobdb966377bb0fc4e6e1675adec839cc8eace925de
1 //========================================================================
2 //
3 // StdinCachedFile.cc
4 //
5 // This file is licensed under the GPLv2 or later
6 //
7 // Copyright 2010 Hib Eris <hib@hiberis.nl>
8 // Copyright 2010 Albert Astals Cid <aacid@kde.org>
9 // Copyright 2010 Jonathan Liu <net147@gmail.com>
11 //========================================================================
13 #include <config.h>
15 #include "StdinCachedFile.h"
17 #ifdef _WIN32
18 #include <fcntl.h> // for O_BINARY
19 #include <io.h> // for setmode
20 #endif
21 #include <stdio.h>
23 size_t StdinCacheLoader::init(GooString *dummy, CachedFile *cachedFile)
25 size_t read, size = 0;
26 char buf[CachedFileChunkSize];
28 #ifdef _WIN32
29 setmode(fileno(stdin), O_BINARY);
30 #endif
32 CachedFileWriter writer = CachedFileWriter (cachedFile, NULL);
33 do {
34 read = fread(buf, 1, CachedFileChunkSize, stdin);
35 (writer.write) (buf, CachedFileChunkSize);
36 size += read;
38 while (read == CachedFileChunkSize);
40 return size;
43 int StdinCacheLoader::load(const std::vector<ByteRange> &ranges, CachedFileWriter *writer)
45 return 0;