/usr/include/x86_64-linux-gnu/zypp/MediaSetAccess.h is in libzypp-dev 14.29.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | /*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
| / / \ V /| _/ _/ |
| / /__ | | | | | | |
| /_____||_| |_| |_| |
| |
\---------------------------------------------------------------------*/
#ifndef ZYPP_MediaSetAccess_H
#define ZYPP_MediaSetAccess_H
#include <iosfwd>
#include <string>
#include <vector>
#include "zypp/base/Function.h"
#include "zypp/base/ReferenceCounted.h"
#include "zypp/base/NonCopyable.h"
#include "zypp/base/Flags.h"
#include "zypp/base/PtrTypes.h"
#include "zypp/media/MediaManager.h"
#include "zypp/Pathname.h"
#include "zypp/CheckSum.h"
#include "zypp/OnMediaLocation.h"
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
DEFINE_PTR_TYPE(MediaSetAccess);
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : MediaSetAccess
//
/**
* Media access layer responsible for handling files distributed on a set
* of media with media change and abort/retry/ingore user callback handling.
*
* This is provided as a means to handle CD or DVD sets accessible through
* dir, iso, nfs or other URL schemes other than cd/dvd (see
* \ref MediaManager for info on different implemented media backends).
* Currently it handles URLs containing cdN, CDN, dvdN, and DVDN strings,
* where N is the number of particular media in the set.
*
* Examples:
* \code
* "iso:/?iso=/path/to/iso/images/openSUSE-10.3-Alpha2plus-DVD-x86_64-DVD1.iso"
* "dir:/path/to/cdset/sources/openSUSE-10.3/Alpha2plus/CD1"
* \endcode
*
* MediaSetAccess accesses files on desired media by rewriting
* the original URL, replacing the digit (usually) 1 with requested media
* number and uses \ref MediaManager to get the files from the new URL.
*
* Additionaly, each media number can be assined a media verifier which
* checks if the media we are trying to access is the desired one. See
* \ref MediaVerifierBase for more info.
*
* Code example:
* \code
* Url url("dir:/path/to/cdset/sources/openSUSE-10.3/Alpha2plus/CD1");
*
* MediaSetAccess access(url);
*
* access.setVerifier(1, media1VerifierRef);
* access.setVerifier(2, media2VerifierRef);
*
* Pathname file1 = "/some/file/on/media1";
* Pathname providedfile1 = access.provideFile(file1, 1);
* Pathname file2 = "/some/file/on/media2";
* Pathname providedfile2 = access.provideFile(file1, 2);
*
* \endcode
*/
class MediaSetAccess : public base::ReferenceCounted, private base::NonCopyable
{
friend std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj );
public:
/**
* Creates a callback enabled media access for specified \a url.
*
* \param url
* \param prefered_attach_point Prefered attach (mount) point. Use, if
* you want to mount the media to a specific directory.
*/
MediaSetAccess( const Url &url, const Pathname & prefered_attach_point = "" );
/** \overload Also taking a \ref label. */
MediaSetAccess( const std::string & label_r, const Url &url, const Pathname & prefered_attach_point = "" );
~MediaSetAccess();
/**
* Sets a \ref MediaVerifier verifier for given media number.
*/
void setVerifier( unsigned media_nr, media::MediaVerifierRef verifier );
/**
* The label identifing this media set and to be sent in a media change request.
*/
const std::string & label() const
{ return _label; }
/**
* Set the label identifing this media set and to be sent in a media change request.
*/
void setLabel( const std::string & label_r )
{ _label = label_r; }
enum ProvideFileOption
{
/**
* The user is not asked anything, and the error
* exception is just propagated */
PROVIDE_DEFAULT = 0x0,
PROVIDE_NON_INTERACTIVE = 0x1
};
ZYPP_DECLARE_FLAGS(ProvideFileOptions,ProvideFileOption);
/**
* Provides a file from a media location.
*
* \param resource location of the file on media
* \return local pathname of the requested file
*
* \throws MediaException if a problem occured and user has chosen to
* abort the operation. The calling code should take care
* to quit the current operation.
* \throws SkipRequestException if a problem occured and user has chosen
* to skip the current operation. The calling code should continue
* with the next one, if possible.
*
*
* If the resource is marked as optional, no Exception is thrown
* and Pathname() is returned
*
* the optional deltafile argument describes a file that can
* be used for delta download algorithms.
*
* \note interaction with the user does not ocurr if
* \ref ProvideFileOptions::NON_INTERACTIVE is set.
*
* \note OnMediaLocation::optional() hint has no effect on the transfer.
*
* \see zypp::media::MediaManager::provideFile()
*/
Pathname provideFile( const OnMediaLocation & resource, ProvideFileOptions options = PROVIDE_DEFAULT, const Pathname &deltafile = Pathname() );
/**
* Provides \a file from media \a media_nr.
*
* \param file path to the file relative to media URL
* \param media_nr the media number in the media set
* \return local pathname of the requested file
*
* \note interaction with the user does not ocurr if
* \ref ProvideFileOptions::NON_INTERACTIVE is set.
*
* \note OnMediaLocation::optional() hint has no effect on the transfer.
*
* \throws MediaException if a problem occured and user has chosen to
* abort the operation. The calling code should take care
* to quit the current operation.
* \throws SkipRequestException if a problem occured and user has chosen
* to skip the current operation. The calling code should continue
* with the next one, if possible.
* \see zypp::media::MediaManager::provideFile()
*/
Pathname provideFile(const Pathname & file, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
/**
* Release file from media.
* This signal that file is not needed anymore.
*
* \param resource location of the file on media
*/
void releaseFile( const OnMediaLocation &resource );
/**
* Release file from media.
* This signal that file is not needed anymore.
*
* \param file path to the file relative to media URL
* \param media_nr the media number in the media set
*/
void releaseFile(const Pathname & file, unsigned media_nr = 1 );
/**
* Provides direcotry \a dir from media number \a media_nr.
*
* \param dir path to the directory relative to media URL
* \param recursive whether to provide the whole directory subtree
* \param media_nr the media number in the media set
* \return local pathname of the requested directory
*
* \throws MediaException if a problem occured and user has chosen to
* abort the operation. The calling code should take care
* to quit the current operation.
* \todo throw SkipRequestException if a problem occured and user has chosen
* to skip the current operation. The calling code should continue
* with the next one, if possible.
* \see zypp::media::MediaManager::provideDir()
* \see zypp::media::MediaManager::provideDirTree()
*/
Pathname provideDir(const Pathname & dir, bool recursive, unsigned media_nr = 1, ProvideFileOptions options = PROVIDE_DEFAULT );
/**
* Checks if a file exists on the specified media, with user callbacks.
*
* \param file file to check
* \param media_nr Media number
*
* \throws MediaException if a problem occured and user has chosen to
* abort the operation. The calling code should take care
* to quit the current operation.
* \throws SkipRequestException if a problem occured and user has chosen
* to skip the current operation. The calling code should continue
* with the next one, if possible.
* \see zypp::media::MediaManager::doesFileExist(MediaAccessId,const Pathname&)
*/
bool doesFileExist(const Pathname & file, unsigned media_nr = 1 );
/**
* Fills \ref retlist with directory information.
*/
void dirInfo( filesystem::DirContent &retlist, const Pathname &dirname,
bool dots = true, unsigned media_nr = 1 );
/**
* Release all attached media of this set.
*
* \throws MediaNotOpenException for invalid access IDs.
*/
void release();
/**
* Replaces media number in specified url with given \a medianr.
*
* Media number in the URL is searched for with regex
* <tt> "^(.*(cd|dvd))([0-9]+)(\\.iso)$" </tt> for iso scheme and
* with <tt> "^(.*(cd|dvd))([0-9]+)(/?)$" </tt> for other schemes.
*
* For cd and dvd scheme it returns the original URL, as well as for
* URL which do not match the above regexes.
*
* \param url_r original URL
* \param medianr requested media number
* \return rewritten URL if applicable, the original URL otherwise
*/
static Url rewriteUrl (const Url & url_r, const media::MediaNr medianr);
protected:
/**
* Provides the \a file from medium number \a media_nr and returns its
* local path.
*
* \note The method must not throw if \a checkonly is <tt>true</tt>.
*
* \throws MediaException \a checkonly is <tt>false</tt> and
* a problem occured and user has chosen to
* abort the operation. The calling code should take care
* to quit the current operation.
* \throws SkipRequestException \a checkonly is <tt>false</tt> and
* a problem occured and user has chosen
* to skip the current operation. The calling code should continue
* with the next one, if possible.
*/
Pathname provideFileInternal( const OnMediaLocation &resource, ProvideFileOptions options );
typedef function<void( media::MediaAccessId, const Pathname & )> ProvideOperation;
void provide( ProvideOperation op, const OnMediaLocation &resource, ProvideFileOptions options, const Pathname &deltafile );
media::MediaAccessId getMediaAccessId (media::MediaNr medianr);
virtual std::ostream & dumpOn( std::ostream & str ) const;
private:
/** Media or media set URL */
Url _url;
/**
* Prefered mount point.
*
* \see MediaManager::open(Url,Pathname)
* \see MediaHandler::_attachPoint
*/
Pathname _prefAttachPoint;
std::string _label;
typedef std::map<media::MediaNr, media::MediaAccessId> MediaMap;
typedef std::map<media::MediaNr, media::MediaVerifierRef > VerifierMap;
/** Mapping between media number and Media Access ID */
MediaMap _medias;
/** Mapping between media number and corespondent verifier */
VerifierMap _verifiers;
};
///////////////////////////////////////////////////////////////////
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(MediaSetAccess::ProvideFileOptions);
/** \relates MediaSetAccess Stream output */
inline std::ostream & operator<<( std::ostream & str, const MediaSetAccess & obj )
{ return obj.dumpOn( str ); }
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_SOURCE_MediaSetAccess_H
|