|
libzypp
9.1.2
|
Media access layer responsible for handling files distributed on a set of media with media change and abort/retry/ingore user callback handling. More...
#include <MediaSetAccess.h>

Public Types | |
| enum | ProvideFileOption { PROVIDE_DEFAULT = 0x0, PROVIDE_NON_INTERACTIVE = 0x1 } |
Public Member Functions | |
| MediaSetAccess (const Url &url, const Pathname &prefered_attach_point="") | |
| Creates a callback enabled media access for specified url. | |
| MediaSetAccess (const std::string &label_r, const Url &url, const Pathname &prefered_attach_point="") | |
| ~MediaSetAccess () | |
| void | setVerifier (unsigned media_nr, media::MediaVerifierRef verifier) |
| Sets a MediaVerifier verifier for given media number. | |
| const std::string & | label () const |
| The label identifing this media set and to be sent in a media change request. | |
| void | setLabel (const std::string &label_r) |
| Set the label identifing this media set and to be sent in a media change request. | |
| ZYPP_DECLARE_FLAGS (ProvideFileOptions, ProvideFileOption) | |
| Pathname | provideFile (const OnMediaLocation &resource, ProvideFileOptions options=PROVIDE_DEFAULT, const Pathname &deltafile=Pathname()) |
| Provides a file from a media location. | |
| Pathname | provideFile (const Pathname &file, unsigned media_nr=1, ProvideFileOptions options=PROVIDE_DEFAULT) |
| Provides file from media media_nr. | |
| void | releaseFile (const OnMediaLocation &resource) |
| Release file from media. | |
| void | releaseFile (const Pathname &file, unsigned media_nr=1) |
| Release file from media. | |
| Pathname | provideDir (const Pathname &dir, bool recursive, unsigned media_nr=1, ProvideFileOptions options=PROVIDE_DEFAULT) |
| Provides direcotry dir from media number media_nr. | |
| 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. | |
| void | release () |
| Release all attached media of this set. | |
Static Public Member Functions | |
| static Url | rewriteUrl (const Url &url_r, const media::MediaNr medianr) |
| Replaces media number in specified url with given medianr. | |
Protected Types | |
| typedef function< void(media::MediaAccessId, const Pathname &)> | ProvideOperation |
Protected Member Functions | |
| Pathname | provideFileInternal (const OnMediaLocation &resource, ProvideFileOptions options) |
| Provides the file from medium number media_nr and returns its local path. | |
| 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 |
| Overload to realize std::ostream & operator<<. | |
Private Types | |
| typedef std::map < media::MediaNr, media::MediaAccessId > | MediaMap |
| typedef std::map < media::MediaNr, media::MediaVerifierRef > | VerifierMap |
Private Attributes | |
| Url | _url |
| Media or media set URL. | |
| Pathname | _prefAttachPoint |
| Prefered mount point. | |
| std::string | _label |
| MediaMap | _medias |
| Mapping between media number and Media Access ID. | |
| VerifierMap | _verifiers |
| Mapping between media number and corespondent verifier. | |
Friends | |
| std::ostream & | operator<< (std::ostream &str, const MediaSetAccess &obj) |
Related Functions | |
(Note that these are not member functions.) | |
| std::ostream & | operator<< (std::ostream &str, const MediaSetAccess &obj) |
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 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:
"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"
MediaSetAccess accesses files on desired media by rewriting the original URL, replacing the digit (usually) 1 with requested media number and uses 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 MediaVerifierBase for more info.
Code example:
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);
Definition at line 77 of file MediaSetAccess.h.
typedef function<void( media::MediaAccessId, const Pathname & )> zypp::MediaSetAccess::ProvideOperation [protected] |
Definition at line 272 of file MediaSetAccess.h.
typedef std::map<media::MediaNr, media::MediaAccessId> zypp::MediaSetAccess::MediaMap [private] |
Definition at line 293 of file MediaSetAccess.h.
typedef std::map<media::MediaNr, media::MediaVerifierRef > zypp::MediaSetAccess::VerifierMap [private] |
Definition at line 294 of file MediaSetAccess.h.
| PROVIDE_DEFAULT |
The user is not asked anything, and the error exception is just propagated. |
| PROVIDE_NON_INTERACTIVE |
Definition at line 111 of file MediaSetAccess.h.
| zypp::MediaSetAccess::MediaSetAccess | ( | const Url & | url, |
| const Pathname & | prefered_attach_point = "" |
||
| ) |
Creates a callback enabled media access for specified url.
| url | |
| prefered_attach_point | Prefered attach (mount) point. Use, if you want to mount the media to a specific directory. |
Definition at line 31 of file MediaSetAccess.cc.
| zypp::MediaSetAccess::MediaSetAccess | ( | const std::string & | label_r, |
| const Url & | url, | ||
| const Pathname & | prefered_attach_point = "" |
||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 37 of file MediaSetAccess.cc.
Definition at line 45 of file MediaSetAccess.cc.
References release().
| void zypp::MediaSetAccess::setVerifier | ( | unsigned | media_nr, |
| media::MediaVerifierRef | verifier | ||
| ) |
Sets a MediaVerifier verifier for given media number.
Definition at line 55 of file MediaSetAccess.cc.
References _medias, _verifiers, zypp::media::MediaManager::addVerifier(), and verifier.
| const std::string& zypp::MediaSetAccess::label | ( | ) | const [inline] |
The label identifing this media set and to be sent in a media change request.
Definition at line 102 of file MediaSetAccess.h.
References _label.
| void zypp::MediaSetAccess::setLabel | ( | const std::string & | label_r | ) | [inline] |
Set the label identifing this media set and to be sent in a media change request.
Definition at line 108 of file MediaSetAccess.h.
References _label.
| zypp::MediaSetAccess::ZYPP_DECLARE_FLAGS | ( | ProvideFileOptions | , |
| ProvideFileOption | |||
| ) |
| Pathname zypp::MediaSetAccess::provideFile | ( | const OnMediaLocation & | resource, |
| ProvideFileOptions | options = PROVIDE_DEFAULT, |
||
| const Pathname & | deltafile = Pathname() |
||
| ) |
Provides a file from a media location.
| resource | location of the file on media |
| MediaException | if a problem occured and user has chosen to abort the operation. The calling code should take care to quit the current operation. |
| 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.
Definition at line 157 of file MediaSetAccess.cc.
References provide(), and zypp::ProvideFileOperation::result.
Referenced by zypp::Fetcher::Impl::provideToDest(), zypp::readRepoFile(), zypp::repo::RepoMirrorList::RepoMirrorList(), zypp::repo::susetags::Downloader::status(), and zypp::repo::yum::Downloader::status().
| Pathname zypp::MediaSetAccess::provideFile | ( | const Pathname & | file, |
| unsigned | media_nr = 1, |
||
| ProvideFileOptions | options = PROVIDE_DEFAULT |
||
| ) |
Provides file from media media_nr.
| file | path to the file relative to media URL |
| media_nr | the media number in the media set |
| MediaException | if a problem occured and user has chosen to abort the operation. The calling code should take care to quit the current operation. |
| 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. |
Definition at line 164 of file MediaSetAccess.cc.
References provide(), zypp::ProvideFileOperation::result, and zypp::OnMediaLocation::setLocation().
| void zypp::MediaSetAccess::releaseFile | ( | const OnMediaLocation & | resource | ) |
Release file from media.
This signal that file is not needed anymore.
| resource | location of the file on media |
Definition at line 74 of file MediaSetAccess.cc.
References zypp::OnMediaLocation::filename(), and zypp::OnMediaLocation::medianr().
Referenced by zypp::Fetcher::Impl::provideToDest().
| void zypp::MediaSetAccess::releaseFile | ( | const Pathname & | file, |
| unsigned | media_nr = 1 |
||
| ) |
Release file from media.
This signal that file is not needed anymore.
| file | path to the file relative to media URL |
| media_nr | the media number in the media set |
Definition at line 79 of file MediaSetAccess.cc.
References DBG, getMediaAccessId(), zypp::media::MediaManager::isAttached(), and zypp::media::MediaManager::releaseFile().
| Pathname zypp::MediaSetAccess::provideDir | ( | const Pathname & | dir, |
| bool | recursive, | ||
| unsigned | media_nr = 1, |
||
| ProvideFileOptions | options = PROVIDE_DEFAULT |
||
| ) |
Provides direcotry dir from media number media_nr.
| dir | path to the directory relative to media URL |
| recursive | whether to provide the whole directory subtree |
| media_nr | the media number in the media set |
| MediaException | if a problem occured and user has chosen to abort the operation. The calling code should take care to quit the current operation. |
Definition at line 329 of file MediaSetAccess.cc.
References provide(), zypp::ProvideDirTreeOperation::result, zypp::ProvideDirOperation::result, and zypp::OnMediaLocation::setLocation().
| bool zypp::MediaSetAccess::doesFileExist | ( | const Pathname & | file, |
| unsigned | media_nr = 1 |
||
| ) |
Checks if a file exists on the specified media, with user callbacks.
| file | file to check |
| media_nr | Media number |
| MediaException | if a problem occured and user has chosen to abort the operation. The calling code should take care to quit the current operation. |
| 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. |
Definition at line 173 of file MediaSetAccess.cc.
References provide(), PROVIDE_DEFAULT, zypp::ProvideFileExistenceOperation::result, and zypp::OnMediaLocation::setLocation().
Referenced by zypp::RepoManager::probe(), and zypp::RepoManager::probeService().
| void zypp::MediaSetAccess::dirInfo | ( | filesystem::DirContent & | retlist, |
| const Pathname & | dirname, | ||
| bool | dots = true, |
||
| unsigned | media_nr = 1 |
||
| ) |
Fills retlist with directory information.
Definition at line 94 of file MediaSetAccess.cc.
References zypp::media::MediaManager::attach(), zypp::media::MediaManager::dirInfo(), getMediaAccessId(), and zypp::media::MediaManager::isAttached().
Referenced by zypp::Fetcher::Impl::getDirectoryContent().
| void zypp::MediaSetAccess::release | ( | ) |
Release all attached media of this set.
| MediaNotOpenException | for invalid access IDs. |
Definition at line 429 of file MediaSetAccess.cc.
References _medias, DBG, and zypp::media::MediaManager::release().
Referenced by ~MediaSetAccess().
| Url zypp::MediaSetAccess::rewriteUrl | ( | const Url & | url_r, |
| const media::MediaNr | medianr | ||
| ) | [static] |
Replaces media number in specified url with given medianr.
Media number in the URL is searched for with regex "^(.*(cd|dvd))([0-9]+)(\\.iso)$" for iso scheme and with "^(.*(cd|dvd))([0-9]+)(/?)$" 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.
| url_r | original URL |
| medianr | requested media number |
Definition at line 386 of file MediaSetAccess.cc.
References DBG, zypp::Url::getPathName(), zypp::Url::getQueryParam(), zypp::Url::getScheme(), zypp::str::regex::icase, zypp::str::numstring(), zypp::str::regex_match(), zypp::Url::setPathName(), zypp::Url::setQueryParam(), and url.
Referenced by getMediaAccessId().
| Pathname zypp::MediaSetAccess::provideFileInternal | ( | const OnMediaLocation & | resource, |
| ProvideFileOptions | options | ||
| ) | [protected] |
Provides the file from medium number media_nr and returns its local path.
true.| MediaException | checkonly is false and a problem occured and user has chosen to abort the operation. The calling code should take care to quit the current operation. |
| SkipRequestException | checkonly is false and a problem occured and user has chosen to skip the current operation. The calling code should continue with the next one, if possible. |
| void zypp::MediaSetAccess::provide | ( | ProvideOperation | op, |
| const OnMediaLocation & | resource, | ||
| ProvideFileOptions | options, | ||
| const Pathname & | deltafile | ||
| ) | [protected] |
Definition at line 182 of file MediaSetAccess.cc.
References _label, _medias, _url, zypp::media::MediaChangeReport::ABORT, zypp::Exception::asUserString(), zypp::media::MediaManager::attach(), zypp::media::MediaChangeReport::CHANGE_URL, zypp::media::MediaManager::close(), DBG, zypp::media::MediaChangeReport::EJECT, zypp::OnMediaLocation::filename(), zypp::media::MediaManager::getDetectedDevices(), getMediaAccessId(), zypp::media::MediaChangeReport::IGNORE, zypp::media::MediaChangeReport::INVALID, zypp::media::MediaChangeReport::IO_SOFT, zypp::media::MediaManager::isAttached(), zypp::OnMediaLocation::medianr(), MIL, zypp::media::MediaChangeReport::NOT_FOUND, zypp::OnMediaLocation::optional(), PROVIDE_NON_INTERACTIVE, zypp::media::MediaManager::release(), zypp::media::MediaManager::releaseAll(), report, zypp::media::MediaChangeReport::RETRY, zypp::media::MediaManager::setDeltafile(), zypp::media::MediaChangeReport::WRONG, ZYPP_CAUGHT, ZYPP_RETHROW, and ZYPP_THROW.
Referenced by doesFileExist(), provideDir(), and provideFile().
| media::MediaAccessId zypp::MediaSetAccess::getMediaAccessId | ( | media::MediaNr | medianr | ) | [protected] |
Definition at line 347 of file MediaSetAccess.cc.
References _medias, _prefAttachPoint, _url, _verifiers, zypp::media::MediaManager::addVerifier(), zypp::media::MediaManager::delVerifier(), zypp::media::MediaManager::open(), rewriteUrl(), url, WAR, and ZYPP_CAUGHT.
Referenced by dirInfo(), provide(), and releaseFile().
| std::ostream & zypp::MediaSetAccess::dumpOn | ( | std::ostream & | str | ) | const [protected, virtual] |
Overload to realize std::ostream & operator<<.
Reimplemented from zypp::base::ReferenceCounted.
Definition at line 437 of file MediaSetAccess.cc.
References _prefAttachPoint, and _url.
Referenced by operator<<().
| std::ostream& operator<< | ( | std::ostream & | str, |
| const MediaSetAccess & | obj | ||
| ) | [friend] |
| std::ostream & operator<< | ( | std::ostream & | str, |
| const MediaSetAccess & | obj | ||
| ) | [related] |
Url zypp::MediaSetAccess::_url [private] |
Media or media set URL.
Definition at line 281 of file MediaSetAccess.h.
Referenced by dumpOn(), getMediaAccessId(), and provide().
Pathname zypp::MediaSetAccess::_prefAttachPoint [private] |
Prefered mount point.
Definition at line 289 of file MediaSetAccess.h.
Referenced by dumpOn(), and getMediaAccessId().
std::string zypp::MediaSetAccess::_label [private] |
Definition at line 291 of file MediaSetAccess.h.
Referenced by label(), provide(), and setLabel().
MediaMap zypp::MediaSetAccess::_medias [private] |
Mapping between media number and Media Access ID.
Definition at line 297 of file MediaSetAccess.h.
Referenced by getMediaAccessId(), provide(), release(), and setVerifier().
VerifierMap zypp::MediaSetAccess::_verifiers [private] |
Mapping between media number and corespondent verifier.
Definition at line 299 of file MediaSetAccess.h.
Referenced by getMediaAccessId(), and setVerifier().
1.7.6.1