libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00009 00010 #ifndef ZYPP_MediaSetAccess_H 00011 #define ZYPP_MediaSetAccess_H 00012 00013 #include <iosfwd> 00014 #include <string> 00015 #include <vector> 00016 #include <zypp/base/Function.h> 00017 00018 #include "zypp/base/ReferenceCounted.h" 00019 #include "zypp/base/NonCopyable.h" 00020 #include "zypp/base/Flags.h" 00021 #include "zypp/base/PtrTypes.h" 00022 #include "zypp/media/MediaManager.h" 00023 #include "zypp/Pathname.h" 00024 #include "zypp/CheckSum.h" 00025 #include "zypp/OnMediaLocation.h" 00026 00028 namespace zypp 00029 { 00030 00031 DEFINE_PTR_TYPE(MediaSetAccess); 00032 00034 // 00035 // CLASS NAME : MediaSetAccess 00036 // 00077 class MediaSetAccess : public base::ReferenceCounted, private base::NonCopyable 00078 { 00079 friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj ); 00080 00081 public: 00089 MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" ); 00091 MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" ); 00092 ~MediaSetAccess(); 00093 00097 void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier ); 00098 00102 const std::string & label() const 00103 { return _label; } 00104 00108 void setLabel( const std::string & label_r ) 00109 { _label = label_r; } 00110 00111 enum ProvideFileOption 00112 { 00116 PROVIDE_DEFAULT = 0x0, 00117 PROVIDE_NON_INTERACTIVE = 0x1 00118 }; 00119 ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption); 00120 00148 Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT, const Pathname &deltafile = Pathname() ); 00149 00170 Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT ); 00171 00178 void releaseFile( const OnMediaLocation &resource ); 00179 00180 00188 void releaseFile(const Pathname & file, unsigned media_nr = 1 ); 00189 00207 Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT ); 00208 00223 bool doesFileExist(const Pathname & file, unsigned media_nr = 1 ); 00224 00228 void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname, 00229 bool dots = true, unsigned media_nr = 1 ); 00230 00236 void release(); 00237 00252 static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr); 00253 00254 protected: 00270 Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options ); 00271 00272 typedef function<void( media::MediaAccessId, const Pathname & )> ProvideOperation; 00273 00274 void provide( ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile ); 00275 00276 media::MediaAccessId getMediaAccessId (media::MediaNr medianr); 00277 virtual std::ostream & dumpOn( std::ostream & str ) const; 00278 00279 private: 00281 Url _url; 00282 00289 Pathname _prefAttachPoint; 00290 00291 std::string _label; 00292 00293 typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap; 00294 typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap; 00295 00297 MediaMap _medias; 00299 VerifierMap _verifiers; 00300 }; 00302 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions); 00303 00305 inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj ) 00306 { return obj.dumpOn( str ); } 00307 00308 00309 } // namespace zypp 00311 #endif // ZYPP_SOURCE_MediaSetAccess_H