9eff514b6337d237ee566583303a3aecde134b8a
[platform/upstream/libzypp.git] / zypp / ProvideFilePolicy.cc
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9
10 #include <iostream>
11 #include <fstream>
12 #include <sstream>
13 #include "zypp/base/Logger.h"
14
15 #include "zypp/ProvideFilePolicy.h"
16
17 using std::endl;
18
19 ///////////////////////////////////////////////////////////////////
20 namespace zypp
21 { /////////////////////////////////////////////////////////////////
22   ///////////////////////////////////////////////////////////////////
23   //
24   //    CLASS NAME : ProvideFilePolicy
25   //
26   ///////////////////////////////////////////////////////////////////
27
28   ///////////////////////////////////////////////////////////////////
29   namespace
30   { /////////////////////////////////////////////////////////////////
31
32     bool yes() { return true; }
33     bool no()  { return false; }
34
35     /////////////////////////////////////////////////////////////////
36   } // namespace
37   ///////////////////////////////////////////////////////////////////
38
39   ProvideFilePolicy & ProvideFilePolicy::failOnChecksumErrorCB( bool yesno_r )
40   {
41     _failOnChecksumErrorCB = (yesno_r ? &yes : &no);
42     return *this;
43   }
44
45   bool ProvideFilePolicy::progress( int value ) const
46   {
47     if ( _progressCB )
48       return _progressCB( value );
49     return true;
50   }
51
52   bool ProvideFilePolicy::failOnChecksumError() const
53   {
54     if ( _failOnChecksumErrorCB )
55       return _failOnChecksumErrorCB();
56     return true;
57   }
58
59 } // namespace zypp
60 ///////////////////////////////////////////////////////////////////