libzypp  17.37.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-core/OnMediaLocation>
26 #include <zypp/ManagedFile.h>
27 #include <zypp/media/MediaUrl.h>
28 
30 namespace zypp
31 {
32 
34 
36  //
37  // CLASS NAME : MediaSetAccess
38  //
82  {
83  friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
84 
85  public:
93  MediaSetAccess( Url url, Pathname prefered_attach_point = "" );
95  MediaSetAccess( std::string label_r, Url url, Pathname prefered_attach_point = "" );
96 
104  MediaSetAccess( std::vector<media::MediaUrl> urls, Pathname prefered_attach_point = "" );
106  MediaSetAccess( std::string label_r, std::vector<media::MediaUrl> urls, Pathname prefered_attach_point = "" );
107 
108 
109  MediaSetAccess(const MediaSetAccess &) = delete;
110  MediaSetAccess(MediaSetAccess &&) = delete;
111  MediaSetAccess &operator=(const MediaSetAccess &) = delete;
112  MediaSetAccess &operator=(MediaSetAccess &&) = delete;
113 
114  ~MediaSetAccess() override;
115 
119  void setVerifier( unsigned media_nr, const media::MediaVerifierRef& verifier );
120 
124  const std::string & label() const;
125 
129  void setLabel( const std::string & label_r );
130 
132  {
136  PROVIDE_DEFAULT = 0x0,
137  PROVIDE_NON_INTERACTIVE = 0x1
138  };
139  ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption);
140 
151  void precacheFiles(const std::vector<OnMediaLocation> &files);
152 
180  Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT );
181 
185  ZYPP_DEPRECATED Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options, const Pathname &deltafile );
186 
207  Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
208 
216  Pathname provideOptionalFile( const Pathname & file, unsigned media_nr = 1 );
217 
235  static ManagedFile provideFileFromUrl( const Url & file_url, ProvideFileOptions options = PROVIDE_DEFAULT );
236 
244  static ManagedFile provideOptionalFileFromUrl( const Url & file_url );
245 
252  void releaseFile( const OnMediaLocation &resource );
253 
254 
262  void releaseFile(const Pathname & file, unsigned media_nr = 1 );
263 
280  {
283  ReleaseFileGuard( MediaSetAccess & media_r, const OnMediaLocation & loc_r )
284  : _media( media_r )
285  , _loc( loc_r )
286  {}
288  { _media.releaseFile( _loc ); }
289  private:
292  };
293 
311  Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
312 
327  bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
328 
332  void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
333  bool dots = true, unsigned media_nr = 1 );
334 
340  void release();
341 
356  static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
357 
358  protected:
374  Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
375 
376  using ProvideOperation = function<void (media::MediaAccessId, const OnMediaLocation &)>;
377 
378  void provide( const ProvideOperation& op, const OnMediaLocation &resource, ProvideFileOptions options );
379 
380  media::MediaAccessId getMediaAccessId (media::MediaNr medianr);
381  std::ostream & dumpOn( std::ostream & str ) const override;
382 
383  private:
384  class Impl;
386  std::unique_ptr<Impl> _pimpl;
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
ZYPP_DECLARE_FLAGS(VendorSupportOptions, VendorSupportOption)
Pathname deltafile
Describes a resource file located on a medium.
std::unique_ptr< Impl > _pimpl
Pointer to implementation.
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(DiskUsageCounter::MountPoint::HintFlags)
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
std::ostream & operator<<(std::ostream &str, const MediaSetAccess &obj)
std::list< DirEntry > DirContent
Returned by readdir.
Definition: PathInfo.h:526
std::ostream & dumpOn(std::ostream &str) const override
Overload to realize std::ostream & operator<<.
unsigned int MediaAccessId
Media manager access Id type.
Definition: MediaSource.h:30
MediaHandle _media
ManagedFile provideFile(RepoInfo repo_r, const OnMediaLocation &loc_r, const ProvideFilePolicy &policy_r)
Provide a file from a Repository.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition: ResTraits.h:93
DEFINE_PTR_TYPE(Application)
ReleaseFileGuard(MediaSetAccess &media_r, const OnMediaLocation &loc_r)
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:580
Base class for reference counted objects.
#define NON_MOVABLE(CLASS)
Delete move ctor and move assign.
Definition: Easy.h:59
MediaVerifierRef verifier
unsigned int MediaNr
Definition: MediaManager.h:32
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:292
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:94
#define NON_COPYABLE(CLASS)
Delete copy ctor and copy assign.
Definition: Easy.h:49
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
function< void(media::MediaAccessId, const OnMediaLocation &)> ProvideOperation
#define ZYPP_DEPRECATED
The ZYPP_DEPRECATED macro can be used to trigger compile-time warnings with gcc >= 3...
Definition: Globals.h:112
bool provide(const Pathname &delta_r, const Pathname &new_r, const Progress &report_r)
Apply a binary delta to on-disk data to re-create a new rpm.
Url manipulation class.
Definition: Url.h:92
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26