libzypp 17.31.23
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
18#include <zypp/base/ReferenceCounted.h>
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-core/OnMediaLocation>
26#include <zypp/ManagedFile.h>
27
29namespace zypp
30{
31
33
35 //
36 // CLASS NAME : MediaSetAccess
37 //
81 {
82 friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
83
84 public:
92 MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" );
94 MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" );
96
100 void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
101
105 const std::string & label() const
106 { return _label; }
107
111 void setLabel( const std::string & label_r )
112 { _label = label_r; }
113
115 {
121 };
123
134 void precacheFiles(const std::vector<OnMediaLocation> &files);
135
163 Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT );
164
168 ZYPP_DEPRECATED Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options, const Pathname &deltafile );
169
190 Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
191
199 Pathname provideOptionalFile( const Pathname & file, unsigned media_nr = 1 );
200
218 static ManagedFile provideFileFromUrl( const Url & file_url, ProvideFileOptions options = PROVIDE_DEFAULT );
219
227 static ManagedFile provideOptionalFileFromUrl( const Url & file_url );
228
235 void releaseFile( const OnMediaLocation &resource );
236
237
245 void releaseFile(const Pathname & file, unsigned media_nr = 1 );
246
263 {
267 : _media( media_r )
268 , _loc( loc_r )
269 {}
271 { _media.releaseFile( _loc ); }
272 private:
275 };
276
294 Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
295
310 bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
311
315 void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
316 bool dots = true, unsigned media_nr = 1 );
317
323 void release();
324
339 static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
340
341 protected:
357 Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
358
359 typedef function<void( media::MediaAccessId, const OnMediaLocation & )> ProvideOperation;
360
361 void provide( ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options );
362
364 virtual std::ostream & dumpOn( std::ostream & str ) const;
365
366 private:
369
377
378 std::string _label;
379
380 typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
381 typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
382
387 };
389 ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions);
390
392 inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
393 { return obj.dumpOn( str ); }
394
395
396} // namespace zypp
398#endif // ZYPP_SOURCE_MediaSetAccess_H
MediaVerifierRef verifier
Pathname deltafile
Media access layer responsible for handling files distributed on a set of media with media change and...
ZYPP_DECLARE_FLAGS(ProvideFileOptions, ProvideFileOption)
VerifierMap _verifiers
Mapping between media number and corespondent verifier.
media::MediaAccessId getMediaAccessId(media::MediaNr medianr)
Pathname provideDir(const Pathname &dir, bool recursive, unsigned media_nr=1, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides direcotry dir from media number media_nr.
MediaMap _medias
Mapping between media number and Media Access ID.
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream & operator<<.
void precacheFiles(const std::vector< OnMediaLocation > &files)
Tries to fetch the given files and precaches them.
friend std::ostream & operator<<(std::ostream &str, const MediaSetAccess &obj)
std::map< media::MediaNr, media::MediaAccessId > MediaMap
function< void(media::MediaAccessId, const OnMediaLocation &)> ProvideOperation
static ManagedFile provideFileFromUrl(const Url &file_url, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides file from url.
@ PROVIDE_DEFAULT
The user is not asked anything, and the error exception is just propagated.
Pathname provideFile(const OnMediaLocation &resource, ProvideFileOptions options=PROVIDE_DEFAULT)
Provides a file from a media location.
void setLabel(const std::string &label_r)
Set the label identifing this media set and to be sent in a media change request.
Pathname provideOptionalFile(const Pathname &file, unsigned media_nr=1)
Provides an optional file from media media_nr.
static ManagedFile provideOptionalFileFromUrl(const Url &file_url)
Provides an optional file from url.
void setVerifier(unsigned media_nr, media::MediaVerifierRef verifier)
Sets a MediaVerifier verifier for given media number.
bool doesFileExist(const Pathname &file, unsigned media_nr=1)
Checks if a file exists on the specified media, with user callbacks.
void dirInfo(filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true, unsigned media_nr=1)
Fills retlist with directory information.
std::map< media::MediaNr, media::MediaVerifierRef > VerifierMap
void release()
Release all attached media of this set.
Pathname _prefAttachPoint
Prefered mount point.
Pathname provideFileInternal(const OnMediaLocation &resource, ProvideFileOptions options)
Provides the file from medium number media_nr and returns its local path.
static Url rewriteUrl(const Url &url_r, const media::MediaNr medianr)
Replaces media number in specified url with given medianr.
void provide(ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options)
Url _url
Media or media set URL.
const std::string & label() const
The label identifing this media set and to be sent in a media change request.
void releaseFile(const OnMediaLocation &resource)
Release file from media.
Describes a resource file located on a medium.
Url manipulation class.
Definition: Url.h:92
Base class for reference counted objects.
String related utilities and Regular expression matching.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
std::list< DirEntry > DirContent
Returned by readdir.
Definition: PathInfo.h:518
unsigned int MediaNr
Definition: MediaManager.h:32
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:29
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
ReleaseFileGuard(MediaSetAccess &media_r, const OnMediaLocation &loc_r)
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3....
Definition: Globals.h:99
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
Definition: Flags.h:177
#define DEFINE_PTR_TYPE(NAME)
Forward declaration of Ptr types.
Definition: PtrTypes.h:623