Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F19244547
stream.cc
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
844 B
Referenced Files
None
Subscribers
None
stream.cc
View Options
/**
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019-2020
* \copyright GPLv2 or later
*/
#include
"HEJ/stream.hh"
#include
<array>
#include
<boost/iostreams/filter/gzip.hpp>
namespace
HEJ
{
namespace
{
bool
is_gzip
(
std
::
ifstream
&
file
){
static
constexpr
std
::
array
<
char
,
2
>
magic_bytes
=
{
'\x1f'
,
'\x8b'
};
if
(
file
.
peek
()
!=
magic_bytes
[
0
])
return
false
;
file
.
get
();
const
char
second
=
file
.
peek
();
file
.
unget
();
return
second
==
magic_bytes
[
1
];
}
}
istream
::
istream
(
std
::
string
const
&
filename
)
:
file_
{
filename
,
std
::
ios_base
::
in
|
std
::
ios_base
::
binary
},
stream_
{
std
::
make_unique
<
boost_istream
>
()}
{
if
(
is_gzip
(
file_
)){
stream_
->
push
(
boost
::
iostreams
::
gzip_decompressor
{});
}
stream_
->
push
(
file_
);
}
}
// namespace HEJ
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Tue, Sep 30, 4:43 AM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6455041
Default Alt Text
stream.cc (844 B)
Attached To
Mode
rHEJ HEJ
Attached
Detach File
Event Timeline
Log In to Comment