libzypp: zypp::media::MediaManager Class Reference

libzypp 17.38.15

zypp::media::MediaManager Class Reference

Manages access to the 'physical' media, e.g CDROM drives, Disk volumes, directory trees, etc, using Media Access Url's. More...

`#include <zypp/media/MediaManager.h>`

Inheritance diagram for zypp::media::MediaManager:

## Public Member Functions
| MediaManager ()
| Creates a MediaManager envelope instance.
| ~MediaManager ()
| Destroys MediaManager envelope instance.
MediaAccessId | open (const Url &url, const Pathname &preferred_attach_point="")
| Opens the media access for specified with the url.
MediaAccessId | open (const MirroredOrigin &origin_r, const Pathname &preferred_attach_point="")
| Opens the media access for specified via the url list.
void | close (MediaAccessId accessId)
| Close the media access with specified id.
bool | isOpen (MediaAccessId accessId) const
| Query if the media access is open / exists.
std::string | protocol (MediaAccessId accessId) const
| Query the protocol name used by the media access handler.
bool | downloads (MediaAccessId accessId) const
| Hint if files are downloaded or not.
Url | url (MediaAccessId accessId) const
| Returns the primary Media Access Url of the media access id.
void | addVerifier (MediaAccessId accessId, const MediaVerifierRef &verifier)
| Add verifier implementation for the specified media id.
void | delVerifier (MediaAccessId accessId)
| Remove verifier for specified media id.
bool | setAttachPrefix (const Pathname &attach_prefix)
| Set or resets the directory name, where the media manager handlers create their temporary attach points (see open() function).
void | attach (MediaAccessId accessId)
| Attach the media using the concrete handler (checks all devices).
void | release (MediaAccessId accessId, const std::string &ejectDev="")
| Release the attached media and optionally eject.
void | releaseAll ()
| Release all attached media.
void | disconnect (MediaAccessId accessId)
| Disconnect a remote media.
bool | isAttached (MediaAccessId accessId) const
| Check if media is attached or not.
bool | isSharedMedia (MediaAccessId accessId) const
| Returns information if media is on a shared physical device or not.
bool | isDesiredMedia (MediaAccessId accessId) const
| Ask the registered verifier if the attached media is the desired one or not.
bool | isDesiredMedia (MediaAccessId accessId, const MediaVerifierRef &verifier) const
| Ask the specified verifier if the attached media is the desired one or not.
bool | isChangeable (MediaAccessId accessId)
| Simple check, based on media's URL scheme, telling whether the it is possible to physically change the media inside its drive, like CDs or DVDs.
Pathname | localRoot (MediaAccessId accessId) const
| Return the local directory that corresponds to medias url, no matter if media isAttached or not.
Pathname | localPath (MediaAccessId accessId, const Pathname &pathname) const
| Shortcut for 'localRoot() + pathname', but returns an empty pathname if media is not attached.
ZYPP_DEPRECATED void | provideFile (MediaAccessId accessId, const Pathname &filename, const ByteCount &expectedFileSize) const
ZYPP_DEPRECATED void | provideFile (MediaAccessId accessId, const Pathname &filename) const
void | provideFile (MediaAccessId accessId, const OnMediaLocation &file) const
| Provide provide file denoted by relative path below of the 'attach point' of the specified media and the path prefix on the media.
void | provideDir (MediaAccessId accessId, const Pathname &dirname) const
| FIXME: see MediaAccess class.
void | provideDirTree (MediaAccessId accessId, const Pathname &dirname) const
| FIXME: see MediaAccess class.
void | releaseFile (MediaAccessId accessId, const Pathname &filename) const
| FIXME: see MediaAccess class.
void | releaseDir (MediaAccessId accessId, const Pathname &dirname) const
| FIXME: see MediaAccess class.
void | releasePath (MediaAccessId accessId, const Pathname &pathname) const
| FIXME: see MediaAccess class.
void | dirInfo (MediaAccessId accessId, std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
| FIXME: see MediaAccess class.
void | dirInfo (MediaAccessId accessId, filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
| FIXME: see MediaAccess class.
bool | doesFileExist (MediaAccessId accessId, const Pathname &filename) const
| FIXME: see MediaAccess class.
void | getDetectedDevices (MediaAccessId accessId, std::vector< std::string > &devices, unsigned int &index) const
| Fill in a vector of detected ejectable devices and the index of the currently attached device within the vector.
ZYPP_DEPRECATED void | setDeltafile (MediaAccessId accessId, const Pathname &filename) const
void | precacheFiles (MediaAccessId accessId, const std::vector< OnMediaLocation > &files)
| Tries to fetch the given files and precaches them.
bool | isUseableAttachPoint (const Pathname &path, bool mtab=true) const
| Check if the specified `path` is useable as attach point.

## Static Public Member Functions
static time_t | getMountTableMTime ()
| Get the modification time of the /etc/mtab file.
static std::vector< MountEntry > | getMountEntries ()
| Get current mount entries from /etc/mtab file.

## Private Member Functions
AttachedMedia | getAttachedMedia (MediaAccessId &accessId) const
AttachedMedia | findAttachedMedia (const MediaSourceRef &media) const
void | forceReleaseShared (const MediaSourceRef &media)

## Static Private Attributes
static zypp::RW_pointer< MediaManager_Impl > | m_impl
| Static reference to the implementation (singleton).

## Friends
class | MediaHandler

## Detailed Description

Manages access to the 'physical' media, e.g CDROM drives, Disk volumes, directory trees, etc, using Media Access Url's.

Note
  The MediaManager class is just an envelope around an inner singleton like implementation.
  That is, you can create as many managers as you want, also temporary in a function call.
  But don't declare static MediaManager instances, unless you want to force (mutex) initialization order problems!

# Media Access Url

The MediaManager uses several media access handlers (backends), that can be specified by a Media Access URL in its open() method.

All URLs may contain following query parameters, that are reserved by the Source classes and unused/ignored by the media manager:

- alias: A source specific media alias string.

Currently, following access handlers (backends) are implemented:

- MediaCD - CD/DVD drives (cd, dvd)
- MediaDISK - HD disk volumes (hd)

- MediaISO - Loopback ISO images (iso)
- MediaDIR - Local directory tree (dir, file)

- MediaNFS - NFS directory tree (nfs)
- MediaCIFS - CIFS/SMB directory tree (cifs, smb)
- MediaCurl - FTP/HTTP directory tree (ftp, tftp, http, https)

## MediaCD - CD/DVD drives (cd, dvd)

The access handler for media on CD / DVD drives.

- Scheme:
  - cd: Requires a drive supporting CD media.
  - dvd: Prefers a drive supporting DVD media.
- Examples:
  "cd:/"
  "cd:/?devices=/dev/hda,/dev/hdb"
  "cd:/subdir?devices=/dev/hda,/dev/hdb"
  "dvd:/"
  "dvd:/?devices=/dev/hda,/dev/hdb"
  "dvd:/subdir?devices=/dev/hda,/dev/hdb"
  Note: You can use either "dvd:/" (just path, no authority) or "dvd:///" (path and empty authority).
- Query parameters:
  - devices: Optional parameter, containing a comma separated list of block device names to use, e.g.: "/dev/sr0,/dev/sr1".
    The device names will be verified. If one of the provided devices is not usable (not a block device, or does not support required media type), an exception is thrown.
    If the devices parameter is not provided (or empty), available CD/DVD drives will be auto-detected. The preferred device is the one denoted by "/dev/dvd" ("dvd" scheme only) or "/dev/cdrom".
- Authority: A non-empty authority URL component (e.g. containing a host name) is not allowed.
- Path name: Mandatory URL component, that specifies a subdirectory on the CD/DVD, where the desired files are located.

## MediaDISK - HD disk volumes (hd)

The access handler for media on a disk volume (partition).

- Scheme:
  - hd
- Examples:
  "hd:/?device=/dev/hda1"
  "hd:/subdir?device=/dev/sda1"
  "hd:/subdir?device=/dev/sda1&filesystem=reiserfs"
  Note: You can use either "hd:/" (just path, no authority) or "hd:///" (path and empty authority).
- Query parameters:
  - device: Mandatory parameter specifying the name of the block device of the partition to mount.
  - filesystem: The name of the filesystem. Defaults to "auto".
- Authority: A non-empty authority URL component is not allowed.
- Path name: Mandatory URL component, that specifies a subdirectory on the disk partition, where the desired files are located.

## MediaDIR - Local directory tree (dir, file)

The access handler to media stored in a local directory tree.

- Scheme:
  - dir
  - file
- Examples:
  "dir:/directory/name"
  "file:/directory/name"
- Query parameters: none
- Authority: A non-empty authority URL component (e.g. containing a host name) is not allowed.
- Path name: Mandatory URL component, that specifies a directory, where the desired files are located.

## MediaISO - Loopback ISO images (iso)

The access handler for media in a ISO image (loopback mount).

- Scheme:
  - iso
- Examples:
  "iso:/?iso=/path/to/CD1.iso"
  "iso:/?iso=CD1.iso&url=dir:/path/to"
  "iso:/?iso=CD1.iso&url=nfs://server/path/to/media"
  "iso:/?iso=CD1.iso&url=hd:/?device=/dev/hda"
  "iso:/subdir?iso=DVD1.iso&url=nfs://nfs-server/directory&mnt=/nfs/attach/point&filesystem=udf"
- Query parameters:
  - iso: Mandatory parameter specifying the name of the iso file.
    If the url parameter is missed, the iso parameter has to contain an absolute iso file name.
  - url: Optional parameter specifying the URL to the directory containing the iso file.
    The supported URL schemes are: hd, dir, file, nfs, nfs4, smb, cifs.
  - mnt: Optional parameter specifying the prefered attach point for the source media url.
  - filesystem: Optional name of the filesystem used in the iso file. Defaults to "auto".
- Authority: A non-empty authority URL component is not allowed.
- Path name: Mandatory URL component, that specifies a subdirectory inside of the iso file, where the desired files are located.

## MediaNFS - NFS directory tree (nfs)

The access handler for media on NFS exported directory tree.

- Scheme:
  - nfs
  - nfs
- Examples:
  "nfs://nfs-server/exported/path"
  "nfs://nfs-server/exported/path?mountoptions=ro"
  "nfs://nfs-server/exported/path&type=nfs4"
  "nfs4://nfs-server/exported/path"
- Query parameters:
  - mountoptions: The mount options separated by comma ','. Default is the "ro" option.
  - type=nfs4: Whether to mount as nfs4. This is the default for scheme nfs4.

Authority: The authority component has to provide a hostname. Username, password and port are currently ignored.

- Path name: Mandatory URL component, that specifies the exported (sub-)directory on the NFS server, where the desired files are located.

## MediaCIFS - CIFS/SMB directory tree (cifs, smb)

The access handler for media in a CIFS/SMB shared directory tree.

- Scheme:
  - cifs
  - smb
- Examples:
  "cifs://servername/share/path/on/the/share"
  "cifs://username:passwd@servername/share/path/on/the/share?mountoptions=ro"
  "cifs://username:passwd@servername/share/path/on/the/share?mountoptions=noguest"
  "smb://servername/share/path/on/the/share"
  "smb://username:passwd@servername/share/path/on/the/share?mountoptions=ro"
  Note: There is no difference between cifs and smb scheme (any more). In both cases the 'cifs' filesystem is used.
- Query parameters:
  - mountoptions: The mount options separated by a comma ','. Default are the "ro" and "guest" options. Specify "noguest" to turn off "guest". This is necessary if Samba is configured to reject guest connections.
  - workgroup or domain: The name of the workgroup.
  - username: Alternative username to username in URL authority.
  - password: Alternative password to password in URL authority.
  - user: Alternative username (cifs specific variant)
  - pass: Alternative password (cifs specific variant)
- Authority: The authority component has to provide a hostname. Optionally also a username and password.
- Path name: Mandatory URL component, that specifies the share name with optional subdirectory, where the desired files are located.

## MediaCurl - FTP/HTTP directory tree (ftp, tftp, http, https)

The access handler to media directory tree on a ftp/http server.

- Scheme:
  - ftp
  - tftp
  - http
  - https
- Examples:
  "ftp://server/relative/path/to/media/dir"
  "ftp://server/%2fabsolute/path/to/media/dir"
  "ftp://user:pass@server/path/to/media/dir"
  "ftp://user:pass@server/%2f/home/user/path/to/media/dir"
  "http://server/path/on/server"
  "http://user:pass@server/path"
  "https://user:pass@server/path?proxy=foo&proxyuser=me&proxypass=pw"
  Note: The "ftp" url scheme supports absolute and relative paths to the default ftp server directory (RFC1738, Section 3.2.2).
  To use an absolute path, you have to prepend the path with an additional slash, what results in a "/%2f" combination (second "/" encoded to "%2f") at the begin of the URL path.
  This is important, especially in user authenticated ftp, where the users home is usually the default directory of the server (except when the server chroots into the users home directory).
  For example, if the user "user" has a home directory "/home/user", you can use either an URL with a relative path to the home directory "ftp://user:pass@server/path/to/media" or the absolute path "ftp://user:pass@server/%2fhome/user/path/to/media" – both URLs points to the same directory on the server.
- Query parameters:
  - cookies: Turn off using cookies by setting it to "0" (or false, no, off).
  - proxy: A proxy hostname or hostname and port separated by ':'. Setting the hostname to 'none' explicitly disables the use of a proxy even if configured in /etc/sysconfig/proxy or the environment.
  - proxyport: Alternative way to provide the proxy port.
  - proxyuser: The proxy username.
  - proxypass: The proxy password.
  - ssl_capath: The absolute CA directory to use, default is /etc/ssl/certs.
  - ssl_verify: Flag to modify the ssl verify behaviour. Valid values are: 'yes', 'no' and a comma separated list of 'host' and 'peer' flags.
    - 'no': disables ssl verify
    - 'yes': enables ssl verify, this is the default and is equivalent to 'host,peer'.
    - 'host': The server is considered the intended one, when the 'Common Name' field or a 'Subject Alternate Name' field in the certificate matches the host name in the URL.
    - 'peer': Verifies whether the certificate provided by the server is authentic against the chain of digital signatures found in ssl_capath.
  - ssl_clientcert Path to the ssl client certificate for authentication to a repo (CURLOPT_SSLCERT).
  - ssl_clientkey Path to the ssl client key for authentication to a repo (CURLOPT_SSLKEY).
  - timeout: Transfer timeout in seconds between 0 and 3600, 0 disables the timeout, default timeout is 180 seconds.
  - auth: A comma separated list of http authentication method names to use: 'basic', 'digest', 'ntlm', 'negotiate', 'spnego', 'gssnego'. Note, that this list depends on the list of methods supported by the curl library.
  - mediahandler: Set the mediahandler for this url Valid values are: 'curl', 'multicurl'
- Authority: The authority component has to provide a hostname. Optionally also a username and password. In case of the 'ftp' scheme, username and password defaults to 'anonymous' and 'yast2@'.
- Path name: Mandatory URL component, that specifies the path name on the server, where the desired files are located.

Proxy settings: If no proxy settings are present in tha URLs query parameters, the media handler reads the system wide proxy settings from the /etc/sysconfig/proxy file. If a proxy setting was present, but the proxy password not, it attempts to read the proxy-user variable from the ~/.curlrc (/root/.curlrc) file.
If no proxy setting was present, then libzypp does not pass any proxy settings to curl, but curl fallbacks to use the content of the http_proxy, ftp_proxy, etc environment variables.

## MediaPlugin - custom media handler

Media access is delegated to a script located in the libzypp media plugin directory. The URLs query options are translated into commandline arguments passed to the script.

- Scheme:
  - plugin
- Examples:
  "plugin:script?loptv=lvalue&v=optv&lopt=&o&=foo"
  \__________/ \____/ \___/ | \_/
  __________/__ ____/_ _|_ \ \___
  / \ / \ / \ /\ / \
  script --loptv "lvalue" -v "optv" --lopt -o -- foo
  _
  #define _(MSG)
  Definition Gettext.h:39
- Query parameters:
  - The URLs query options are translated into commandline arguments passed to the script.
  - Note: No option may appear twice, as the (option,value) pairs are stored in a hash.
  - Note: The order in which the query options are passes to the script is arbitrary, except for an option with an empty key, which is translated into '– value' and passed as final option.
  - 'c[=[value]]' ist passed as '-c [value]'
  - 'word[=[value]]' ist passed as '–word [value]'
  - '[=value]' ist passed as last args as '– [value]'
- `script<->libzypp` communication:
  - \TODO to be documented.

Definition at line 453 of file MediaManager.h.

## Constructor & Destructor Documentation

## ◆ MediaManager()

zypp::media::MediaManager::MediaManager | ( |  | ) |

Creates a MediaManager envelope instance.

In the case, that the inner implementation is not already allocated, and the MediaManager constructor was unable to allocate it, a std::bad_alloc exception is thrown.

All further instances increase the use counter only.

Exceptions

  std::bad_alloc |

Definition at line 303 of file MediaManager.cc.

## ◆ ~MediaManager()

zypp::media::MediaManager::~MediaManager | ( |  | ) |

Destroys MediaManager envelope instance.

Decreases the use counter of the inner implementation.

Definition at line 312 of file MediaManager.cc.

## Member Function Documentation

## ◆ open() [1/2]

MediaAccessId zypp::media::MediaManager::open | ( | const Url & | url,
|  | const Pathname & | preferred_attach_point = "" )

Opens the media access for specified with the url.

If the `preferred_attach_point` parameter does not point to a usable attach point directory, the media manager automatically creates a temporary attach point in a default directory. This default directory can be changed using setAttachPrefix() function.

Remember to close() each id you've opened and not need any more. It is like a new and delete!

Parameters

  url | The Media Access Url.
  preferred_attach_point | The preferred, already existing directory, where the media should be attached.

Returns
  a new media access id.

Exceptions

  std::bad_alloc |
  MediaException |

Definition at line 318 of file MediaManager.cc.

## ◆ open() [2/2]

MediaAccessId zypp::media::MediaManager::open | ( | const MirroredOrigin & | origin_r,
|  | const Pathname & | preferred_attach_point = "" )

Opens the media access for specified via the url list.

Each URL in the list is seen as a mirror for the primary Url. The primary URL always is the first one in the list, all mirrors resolving to a different handler than the primary will be ignored.

Not all MediaHandler have to support mirrors, in those cases only the primary Url is used.

Parameters

  origin_r | the mediums OriginEndpoints
  preferred_attach_point | The preferred, already existing directory, where the media should be attached.

Returns
  a new media access id.

Exceptions

  std::bad_alloc |
  MediaException |

Definition at line 323 of file MediaManager.cc.

## ◆ close()

void zypp::media::MediaManager::close | ( | MediaAccessId | accessId | ) |

Close the media access with specified id.

Parameters

  accessId | The media access id to close.

Definition at line 341 of file MediaManager.cc.

## ◆ isOpen()

bool zypp::media::MediaManager::isOpen | ( | MediaAccessId | accessId | ) | const

Query if the media access is open / exists.

Parameters

  accessId | The media access id to query.

Returns
  true, if access id is known and open.

Definition at line 375 of file MediaManager.cc.

## ◆ protocol()

std::string zypp::media::MediaManager::protocol | ( | MediaAccessId | accessId | ) | const

Query the protocol name used by the media access handler.

Similar to url().getScheme().

Parameters

  accessId | The media access id to query.

Returns
  The protocol name used by the media access handler, otherwise 'unknown'.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 383 of file MediaManager.cc.

## ◆ downloads()

bool zypp::media::MediaManager::downloads | ( | MediaAccessId | accessId | ) | const

Hint if files are downloaded or not.

Parameters

  accessId | The media access id to query.

Returns
  True, if provideFile downloads files.

Definition at line 392 of file MediaManager.cc.

## ◆ url()

Url zypp::media::MediaManager::url | ( | MediaAccessId | accessId | ) | const

Returns the primary Media Access Url of the media access id.

Parameters

  accessId | The media access id to query.

Returns
  The Media Access Url used by the media access id.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 401 of file MediaManager.cc.

## ◆ addVerifier()

void zypp::media::MediaManager::addVerifier | ( | MediaAccessId | accessId,
|  | const MediaVerifierRef & | verifier )

Add verifier implementation for the specified media id.

By default, the NoVerifier is used.

Parameters

  accessId | A media access id.
  verifier | The new verifier.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 410 of file MediaManager.cc.

## ◆ delVerifier()

void zypp::media::MediaManager::delVerifier | ( | MediaAccessId | accessId | ) |

Remove verifier for specified media id.

It resets the verifier to NoVerifier.

Parameters

  accessId | A media access id.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 427 of file MediaManager.cc.

## ◆ setAttachPrefix()

bool zypp::media::MediaManager::setAttachPrefix | ( | const Pathname & | attach_prefix | ) |

Set or resets the directory name, where the media manager handlers create their temporary attach points (see open() function).

It has effect to newly created temporary attach points only.

Parameters

  attach_prefix | The new prefix for temporary attach points, or empty pathname to reset to defaults.

Returns
  True on success, false if the `attach_prefix` parameters contains a path name, that does not point to a writable directory.

Definition at line 441 of file MediaManager.cc.

## ◆ attach()

void zypp::media::MediaManager::attach | ( | MediaAccessId | accessId | ) |

Attach the media using the concrete handler (checks all devices).

Remember to release() or close() each id you've attached and not need any more. Attach is like an open of a file!

Parameters

  accessId | A media access id.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 447 of file MediaManager.cc.

## ◆ release()

void zypp::media::MediaManager::release | ( | MediaAccessId | accessId,
|  | const std::string & | ejectDev = "" )

Release the attached media and optionally eject.

If the `ejectDev` parameter is not empty all other access id's are released and the specified drive (CD/DVD drive) is ejected.

Parameters

  accessId | A media access id.
  ejectDev | Device to eject. None if empty.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 516 of file MediaManager.cc.

## ◆ releaseAll()

void zypp::media::MediaManager::releaseAll | ( |  | ) |

Release all attached media.

Definition at line 559 of file MediaManager.cc.

## ◆ disconnect()

void zypp::media::MediaManager::disconnect | ( | MediaAccessId | accessId | ) |

Disconnect a remote media.

This is useful for media which e.g. holds open a connection to a server like FTP. After calling disconnect() the media object (attach point) is still valid and files are present.

But after calling disconnect(), it's not possible to call fetch more data using the provideFile() or provideDir() functions anymore.

Parameters

  accessId | A media access id.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 596 of file MediaManager.cc.

## ◆ isAttached()

bool zypp::media::MediaManager::isAttached | ( | MediaAccessId | accessId | ) | const

Check if media is attached or not.

Parameters

  accessId | A media access id.

Returns
  True if media is attached.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 605 of file MediaManager.cc.

## ◆ isSharedMedia()

bool zypp::media::MediaManager::isSharedMedia | ( | MediaAccessId | accessId | ) | const

Returns information if media is on a shared physical device or not.

Parameters

  accessId | A media access id.

Returns
  True if it is shared, false if not.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 613 of file MediaManager.cc.

## ◆ isDesiredMedia() [1/2]

bool zypp::media::MediaManager::isDesiredMedia | ( | MediaAccessId | accessId | ) | const

Ask the registered verifier if the attached media is the desired one or not.

Parameters

  accessId | A media access id.

Returns
  True if media is attached and desired according to the actual verifier.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 622 of file MediaManager.cc.

## ◆ isDesiredMedia() [2/2]

bool zypp::media::MediaManager::isDesiredMedia | ( | MediaAccessId | accessId,
|  | const MediaVerifierRef & | verifier ) const

Ask the specified verifier if the attached media is the desired one or not.

Parameters

  accessId | A media access id.
  verifier | A verifier to use.

Returns
  True if media is attached and desired according to the specified verifier.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 649 of file MediaManager.cc.

## ◆ isChangeable()

bool zypp::media::MediaManager::isChangeable | ( | MediaAccessId | accessId | ) |

Simple check, based on media's URL scheme, telling whether the it is possible to physically change the media inside its drive, like CDs or DVDs.

Useful to decide whether to request media change from user or not.

Parameters

  accessId | The media access id.

Returns
  false if the media is not changeable, true otherwise.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 678 of file MediaManager.cc.

## ◆ localRoot()

Pathname zypp::media::MediaManager::localRoot | ( | MediaAccessId | accessId | ) | const

Return the local directory that corresponds to medias url, no matter if media isAttached or not.

Files requested will be available at 'localRoot() + filename' or even better 'localPath( filename )'

Parameters

  accessId | A media access id.

Returns
  The directory name pointing to the media root in local filesystem or an empty pathname if the media is not attached.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 685 of file MediaManager.cc.

## ◆ localPath()

Pathname zypp::media::MediaManager::localPath | ( | MediaAccessId | accessId,
|  | const Pathname & | pathname ) const

Shortcut for 'localRoot() + pathname', but returns an empty pathname if media is not attached.

Files provided will be available at 'localPath(filename)'.

Parameters

  accessId | A media access id.
  pathname | A path name relative to the localRoot().

Returns
  The directory name in local filesystem pointing to the desired relative pathname on the media or an empty pathname if the media is not attached.

Exceptions

  MediaNotOpenException | for invalid access id.

Definition at line 696 of file MediaManager.cc.

## ◆ provideFile() [1/3]

void zypp::media::MediaManager::provideFile | ( | MediaAccessId | accessId,
|  | const Pathname & | filename,
|  | const ByteCount & | expectedFileSize ) const

Deprecated
  Deprecated function, please use the provideFile version that takes a OnMediaLocation argument

Definition at line 707 of file MediaManager.cc.

## ◆ provideFile() [2/3]

void zypp::media::MediaManager::provideFile | ( | MediaAccessId | accessId,
|  | const Pathname & | filename ) const

Deprecated
  Deprecated function, please use the provideFile version that takes a OnMediaLocation argument

Definition at line 722 of file MediaManager.cc.

## ◆ provideFile() [3/3]

void zypp::media::MediaManager::provideFile | ( | MediaAccessId | accessId,
|  | const OnMediaLocation & | file ) const

Provide provide file denoted by relative path below of the 'attach point' of the specified media and the path prefix on the media.

Parameters

  accessId | The media access id to use.
  file | The OnMediaLocation specifiying the file to download

Exceptions

  MediaNotOpenException | in case of invalid access id.
  MediaNotAttachedException | in case, that the media is not attached.
  MediaNotDesiredException | in case, that the media verification failed.
  MediaNotAFileException | in case, that the requested filename is not a file.
  MediaFileNotFoundException | in case, that the requested filenamedoes not exists.
  MediaWriteException | in case, that the file can't be copied from from remote source.
  MediaSystemException | in case a system operation fails.
  MediaException | derived exception, depending on the url (handler).

Definition at line 733 of file MediaManager.cc.

## ◆ provideDir()

void zypp::media::MediaManager::provideDir | ( | MediaAccessId | accessId,
|  | const Pathname & | dirname ) const

FIXME: see MediaAccess class.

Definition at line 765 of file MediaManager.cc.

## ◆ provideDirTree()

void zypp::media::MediaManager::provideDirTree | ( | MediaAccessId | accessId,
|  | const Pathname & | dirname ) const

FIXME: see MediaAccess class.

Definition at line 777 of file MediaManager.cc.

## ◆ releaseFile()

void zypp::media::MediaManager::releaseFile | ( | MediaAccessId | accessId,
|  | const Pathname & | filename ) const

FIXME: see MediaAccess class.

Definition at line 789 of file MediaManager.cc.

## ◆ releaseDir()

void zypp::media::MediaManager::releaseDir | ( | MediaAccessId | accessId,
|  | const Pathname & | dirname ) const

FIXME: see MediaAccess class.

Definition at line 801 of file MediaManager.cc.

## ◆ releasePath()

void zypp::media::MediaManager::releasePath | ( | MediaAccessId | accessId,
|  | const Pathname & | pathname ) const

FIXME: see MediaAccess class.

Definition at line 814 of file MediaManager.cc.

## ◆ dirInfo() [1/2]

void zypp::media::MediaManager::dirInfo | ( | MediaAccessId | accessId,
|  | std::list< std::string > & | retlist,
|  | const Pathname & | dirname,
|  | bool | dots = true ) const

FIXME: see MediaAccess class.

Definition at line 826 of file MediaManager.cc.

## ◆ dirInfo() [2/2]

void zypp::media::MediaManager::dirInfo | ( | MediaAccessId | accessId,
|  | filesystem::DirContent & | retlist,
|  | const Pathname & | dirname,
|  | bool | dots = true ) const

FIXME: see MediaAccess class.

Definition at line 841 of file MediaManager.cc.

## ◆ doesFileExist()

bool zypp::media::MediaManager::doesFileExist | ( | MediaAccessId | accessId,
|  | const Pathname & | filename ) const

FIXME: see MediaAccess class.

Definition at line 856 of file MediaManager.cc.

## ◆ getDetectedDevices()

void zypp::media::MediaManager::getDetectedDevices | ( | MediaAccessId | accessId,
|  | std::vector< std::string > & | devices,
|  | unsigned int & | index ) const

Fill in a vector of detected ejectable devices and the index of the currently attached device within the vector.

The contents of the vector are the device names (/dev/cdrom and such).

Parameters

  accessId | Medium id.
  devices | vector to load with the device names
  index | index of the currently used device in the devices vector

Definition at line 868 of file MediaManager.cc.

## ◆ setDeltafile()

void zypp::media::MediaManager::setDeltafile | ( | MediaAccessId | accessId,
|  | const Pathname & | filename ) const

Definition at line 744 of file MediaManager.cc.

## ◆ precacheFiles()

void zypp::media::MediaManager::precacheFiles | ( | MediaAccessId | accessId,
|  | const std::vector< OnMediaLocation > & | files )

Tries to fetch the given files and precaches them.

Those files need to be queried using provideFile and can be read from the cache directly. The implementation is not allowed to block but needs to use seperate means to download the files concurrently. A backend can choose to completely ignore this functionaly, the default implementation does nothing.

Parameters

  accessId | Medium id.
  files | List of files that should be precached

Definition at line 754 of file MediaManager.cc.

## ◆ getMountTableMTime()

time_t zypp::media::MediaManager::getMountTableMTime | ( |  | ) |
| static

Get the modification time of the /etc/mtab file.

Returns
  Modification time of the /etc/mtab file.

Definition at line 879 of file MediaManager.cc.

## ◆ getMountEntries()

MountEntries zypp::media::MediaManager::getMountEntries | ( |  | ) |
| static

Get current mount entries from /etc/mtab file.

Returns
  Current mount entries from /etc/mtab file.

Definition at line 887 of file MediaManager.cc.

## ◆ isUseableAttachPoint()

bool zypp::media::MediaManager::isUseableAttachPoint | ( | const Pathname & | path,
|  | bool | mtab = true ) const

Check if the specified `path` is useable as attach point.

Parameters

  path | The attach point to check.
  mtab | Whether to check against the mtab, too.

Returns
  True, if it is a directory and there are no another attach points bellow of it.

Definition at line 894 of file MediaManager.cc.

## ◆ getAttachedMedia()

AttachedMedia zypp::media::MediaManager::getAttachedMedia | ( | MediaAccessId & | accessId | ) | const
| private

Definition at line 963 of file MediaManager.cc.

## ◆ findAttachedMedia()

AttachedMedia zypp::media::MediaManager::findAttachedMedia | ( | const MediaSourceRef & | media | ) | const
| private

Definition at line 972 of file MediaManager.cc.

## ◆ forceReleaseShared()

void zypp::media::MediaManager::forceReleaseShared | ( | const MediaSourceRef & | media | ) |
| private

Definition at line 992 of file MediaManager.cc.

## Friends And Related Symbol Documentation

## ◆ MediaHandler

friend class MediaHandler
| friend

Definition at line 905 of file MediaManager.h.

## Member Data Documentation

## ◆ m_impl

zypp::RW_pointer< MediaManager_Impl > zypp::media::MediaManager::m_impl
| staticprivate

Static reference to the implementation (singleton).

Definition at line 946 of file MediaManager.h.

The documentation for this class was generated from the following files:

- zypp/media/MediaManager.h
- zypp/media/MediaManager.cc