1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/base/InputStream.cc
13 #include "zypp/base/LogTools.h"
15 #include "zypp/base/InputStream.h"
16 #include "zypp/base/GzStream.h"
18 #include "zypp/PathInfo.h"
22 ///////////////////////////////////////////////////////////////////
24 { /////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
30 inline std::streamoff _heplerInitSize( const Pathname & file_r )
33 if ( p.isFile() && filesystem::zipType( file_r ) == filesystem::ZT_NONE )
38 /////////////////////////////////////////////////////////////////
40 ///////////////////////////////////////////////////////////////////
42 ///////////////////////////////////////////////////////////////////
44 // METHOD NAME : InputStream::InputStream
45 // METHOD TYPE : Constructor
47 InputStream::InputStream()
48 : _stream( &std::cin, NullDeleter() )
52 ///////////////////////////////////////////////////////////////////
54 // METHOD NAME : InputStream::InputStream
55 // METHOD TYPE : Constructor
57 InputStream::InputStream( std::istream & stream_r,
58 const std::string & name_r )
59 : _stream( &stream_r, NullDeleter() )
63 ///////////////////////////////////////////////////////////////////
65 // METHOD NAME : InputStream::InputStream
66 // METHOD TYPE : Constructor
68 InputStream::InputStream( const Pathname & file_r )
70 , _stream( new ifgzstream( _path.asString().c_str() ) )
71 , _name( _path.asString() )
72 , _size( _heplerInitSize( _path ) )
75 ///////////////////////////////////////////////////////////////////
77 // METHOD NAME : InputStream::InputStream
78 // METHOD TYPE : Constructor
80 InputStream::InputStream( const Pathname & file_r,
81 const std::string & name_r )
83 , _stream( new ifgzstream( _path.asString().c_str() ) )
85 , _size( _heplerInitSize( _path ) )
88 ///////////////////////////////////////////////////////////////////
90 // METHOD NAME : InputStream::InputStream
91 // METHOD TYPE : Constructor
93 InputStream::InputStream( const std::string & file_r )
95 , _stream( new ifgzstream( _path.asString().c_str() ) )
96 , _name( _path.asString() )
97 , _size( _heplerInitSize( _path ) )
100 ///////////////////////////////////////////////////////////////////
102 // METHOD NAME : InputStream::InputStream
103 // METHOD TYPE : Constructor
105 InputStream::InputStream( const std::string & file_r,
106 const std::string & name_r )
108 , _stream( new ifgzstream( _path.asString().c_str() ) )
110 , _size( _heplerInitSize( _path ) )
113 ///////////////////////////////////////////////////////////////////
115 // METHOD NAME : InputStream::InputStream
116 // METHOD TYPE : Constructor
118 InputStream::InputStream( const char * file_r )
120 , _stream( new ifgzstream( _path.asString().c_str() ) )
121 , _name( _path.asString() )
122 , _size( _heplerInitSize( _path ) )
125 ///////////////////////////////////////////////////////////////////
127 // METHOD NAME : InputStream::InputStream
128 // METHOD TYPE : Constructor
130 InputStream::InputStream( const char * file_r,
131 const std::string & name_r )
133 , _stream( new ifgzstream( _path.asString().c_str() ) )
135 , _size( _heplerInitSize( _path ) )
138 ///////////////////////////////////////////////////////////////////
140 // METHOD NAME : InputStream::~InputStream
141 // METHOD TYPE : Destructor
143 InputStream::~InputStream()
146 /******************************************************************
148 ** FUNCTION NAME : operator<<
149 ** FUNCTION TYPE : std::ostream &
151 std::ostream & operator<<( std::ostream & str, const InputStream & obj )
153 return str << obj.name() << obj.stream();
156 /////////////////////////////////////////////////////////////////
158 ///////////////////////////////////////////////////////////////////