libzypp  11.13.5
MediaSetAccess.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
9 
10 #ifndef ZYPP_MediaSetAccess_H
11 #define ZYPP_MediaSetAccess_H
12 
13 #include <iosfwd>
14 #include <string>
15 #include <vector>
16 #include "zypp/base/Function.h"
17 
19 #include "zypp/base/NonCopyable.h"
20 #include "zypp/base/Flags.h"
21 #include "zypp/base/PtrTypes.h"
23 #include "zypp/Pathname.h"
24 #include "zypp/CheckSum.h"
25 #include "zypp/OnMediaLocation.h"
26 
28 namespace zypp
29 {
30 
31  DEFINE_PTR_TYPE(MediaSetAccess);
32 
34  //
35  // CLASS NAME : MediaSetAccess
36  //
78  {
79  friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
80 
81  public:
89  MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" );
91  MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" );
93 
97  void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
98 
102  const std::string & label() const
103  { return _label; }
104 
108  void setLabel( const std::string & label_r )
109  { _label = label_r; }
110 
112  {
118  };
119  ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption);
120 
148  Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT, const Pathname &deltafile = Pathname() );
149 
170  Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
171 
178  void releaseFile( const OnMediaLocation &resource );
179 
180 
188  void releaseFile(const Pathname & file, unsigned media_nr = 1 );
189 
207  Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
208 
223  bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
224 
228  void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
229  bool dots = true, unsigned media_nr = 1 );
230 
236  void release();
237 
252  static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
253 
254  protected:
270  Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
271 
272  typedef function<void( media::MediaAccessId, const Pathname & )> ProvideOperation;
273 
274  void provide( ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile );
275 
277  virtual std::ostream & dumpOn( std::ostream & str ) const;
278 
279  private:
282 
290 
291  std::string _label;
292 
293  typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
294  typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
295 
300  };
302  ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions);
303 
305  inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
306  { return obj.dumpOn( str ); }
307 
308 
309 } // namespace zypp
311 #endif // ZYPP_SOURCE_MediaSetAccess_H