libzypp: zypp::media::MediaHandler Class Reference

libzypp 17.25.10

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | Friends | List of all members
zypp::media::MediaHandler Class Referenceabstract

Abstract base class for 'physical' MediaHandler like MediaCD, etc. More...

`#include <MediaHandler.h>`

Inheritance diagram for zypp::media::MediaHandler:
[legend]

## Public Types
typedef shared_ptr< MediaHandler > | Ptr
typedef shared_ptr< const MediaHandler > | constPtr

## Public Member Functions
| MediaHandler (const Url &url_r, const Pathname &attach_point_r, const Pathname &urlpath_below_attachpoint_r, const bool does_download_r)
| If the concrete media handler provides a nonempty attach_point, it must be an existing directory. More...
virtual | ~MediaHandler ()
| Contolling MediaAccess takes care, that attached media is released prior to deleting this. More...
bool | downloads () const
| Hint if files are downloaded or not. More...
std::string | protocol () const
| Protocol hint for MediaAccess. More...
Url | url () const
| Url used. More...
void | attach (bool next)
| Use concrete handler to attach the media. More...
virtual bool | isAttached () const
| True if media is attached. More...
Pathname | localRoot () const
| Return the local directory that corresponds to medias url, no matter if media isAttached or not. More...
Pathname | localPath (const Pathname &pathname) const
| Files provided will be available at 'localPath(filename)'. More...
void | disconnect ()
| Use concrete handler to isconnect media. More...
void | release (const std::string &ejectDev="")
| Use concrete handler to release the media. More...
void | provideFile (Pathname filename, const ByteCount &expectedFileSize_r) const
| Use concrete handler to provide file denoted by path below 'localRoot'. More...
void | provideFileCopy (Pathname srcFilename, Pathname targetFilename, const ByteCount &expectedFileSize_r) const
| Call concrete handler to provide a copy of a file under a different place in the file system (usually not under attach point) as a copy. More...
void | provideDir (Pathname dirname) const
| Use concrete handler to provide directory denoted by path below 'localRoot' (not recursive!). More...
void | provideDirTree (Pathname dirname) const
| Use concrete handler to provide directory tree denoted by path below 'localRoot' (recursive!!). More...
void | releaseFile (const Pathname &filename) const
| Remove filename below localRoot IFF handler downloads files to the local filesystem. More...
void | releaseDir (const Pathname &dirname) const
| Remove directory tree below localRoot IFF handler downloads files to the local filesystem. More...
void | releasePath (Pathname pathname) const
| Remove pathname below localRoot IFF handler downloads files to the local filesystem. More...
void | setDeltafile (const Pathname &filename=Pathname()) const
Pathname | deltafile () const
void | dirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
| Return content of directory on media via retlist. More...
void | dirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
| Basically the same as dirInfo above. More...
bool | doesFileExist (const Pathname &filename) const
| check if a file exists More...
virtual bool | hasMoreDevices ()
| Check if the media has one more device available for attach(true). More...
virtual void | getDetectedDevices (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. More...

## Static Public Member Functions
static bool | setAttachPrefix (const Pathname &attach_prefix)
static std::string | getRealPath (const std::string &path)
static Pathname | getRealPath (const Pathname &path)

## Protected Member Functions
bool | dependsOnParent (MediaAccessId parentId, bool exactIdMatch)
| Check if the current media handler depends on an another handler specified by media access id. More...
bool | dependsOnParent ()
void | resetParentId ()
| Called in case, where the media manager takes over the destruction of the parent id (e.g. More...
Pathname | attachPoint () const
| Return the currently used attach point. More...
void | setAttachPoint (const Pathname &path, bool temp)
| Set a new attach point. More...
void | setAttachPoint (const AttachPointRef &ref)
| Set a (shared) attach point. More...
AttachPoint | attachPointHint () const
| Get the actual attach point hint. More...
void | attachPointHint (const Pathname &path, bool temp)
| Set the attach point hint as specified by the user. More...
Pathname | createAttachPoint () const
| Try to create a default / temporary attach point. More...
Pathname | createAttachPoint (const Pathname &attach_root) const
| Try to create a temporary attach point in specified root. More...
void | removeAttachPoint ()
| Remove unused attach point. More...
virtual bool | checkAttachPoint (const Pathname &apoint) const
| Verify if the specified directory as attach point (root) as requires by the particular media handler implementation. More...
bool | isUseableAttachPoint (const Pathname &path, bool mtab=true) const
| Ask media manager, if the specified path is already used as attach point or if there are another attach points bellow of it. More...
std::string | mediaSourceName () const
| Get the media source name or an empty string. More...
void | setMediaSource (const MediaSourceRef &ref)
| Set new media source reference. More...
AttachedMedia | findAttachedMedia (const MediaSourceRef &media) const
| Ask the media manager if specified media source is already attached. More...
AttachedMedia | attachedMedia () const
| Returns the attached media. More...
bool | isSharedMedia () const
| Returns a hint if the media is shared or not. More...
bool | checkAttached (bool matchMountFs) const
| Check actual mediaSource attachment against the current mount table of the system. More...
void | forceRelaseAllMedia (bool matchMountFs)
| Call to this function will try to release all media matching the currenlty attached media source, that it is able to find in the mount table. More...
void | forceRelaseAllMedia (const MediaSourceRef &ref, bool matchMountFs)
virtual void | attachTo (bool next=false)=0
| Call concrete handler to attach the media. More...
virtual void | disconnectFrom ()
| Call concrete handler to disconnect media. More...
virtual void | releaseFrom (const std::string &ejectDev="")=0
| Call concrete handler to release the media. More...
virtual void | forceEject (const std::string &device)
| Call concrete handler to physically eject the media (i.e. More...
virtual void | getFile (const Pathname &filename, const ByteCount &expectedFileSize_r) const
| Call concrete handler to provide file below attach point. More...
virtual void | getFileCopy (const Pathname &srcFilename, const Pathname &targetFilename, const ByteCount &expectedFileSize_r) const
| Call concrete handler to provide a file under a different place in the file system (usually not under attach point) as a copy. More...
virtual void | getDir (const Pathname &dirname, bool recurse_r) const =0
| Call concrete handler to provide directory content (not recursive!) below attach point. More...
virtual void | getDirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const =0
| Call concrete handler to provide a content list of directory on media via retlist. More...
virtual void | getDirInfo (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const =0
| Basically the same as getDirInfo above. More...
virtual bool | getDoesFileExist (const Pathname &filename) const =0
| check if a file exists More...
void | getDirectoryYast (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const
| Retrieve and if available scan dirname/directory.yast. More...
void | getDirectoryYast (filesystem::DirContent &retlist, const Pathname &dirname, bool dots=true) const
| Retrieve and if available scan dirname/directory.yast. More...

## Static Protected Member Functions
static bool | checkAttachPoint (const Pathname &apoint, bool empty_dir, bool writeable)
| Verify if the specified directory as attach point (root) using requested checks. More...

## Protected Attributes
const Url | _url
| Url to handle. More...
MediaAccessId | _parentId
| Access Id of media handler we depend on. More...

## Private Attributes
MediaSourceRef | _mediaSource
| The attached media source description reference. More...
AttachPointRef | _attachPoint
| This is where the media will be actually attached ("mounted"). More...
AttachPoint | _attachPointHint
| The user provided attach preferred point. More...
Pathname | _relativeRoot
| The relative root directory of the data on the media. More...
bool | _does_download
| True if concrete handler downloads files to the local filesystem. More...
time_t | _attach_mtime
| timestamp of the the last attach verification More...
Pathname | _deltafile
| file usable for delta downloads More...

## Static Private Attributes
static Pathname | _attachPrefix
| User defined default attach point prefix. More...

## Friends
class | MediaAccess
| MediaAccess (MediaManager) needs access to the attachedMedia() function to deliver a shared media source and its attach point to the media manager and then to other media handler instances. More...
std::ostream & | operator<< (std::ostream &str, const MediaHandler &obj)

## Detailed Description

Abstract base class for 'physical' MediaHandler like MediaCD, etc.

Handles the requests forwarded by MediaAccess. The public interface contains nonvirtual methods, which should do common sanitychecks and logging. For the real action they call virtual methods overloaded by the concrete handler.

Definition at line 45 of file MediaHandler.h.

## Member Typedef Documentation

## ◆ Ptr

typedef shared_ptr<MediaHandler> zypp::media::MediaHandler::Ptr

Definition at line 49 of file MediaHandler.h.

## ◆ constPtr

typedef shared_ptr<const MediaHandler> zypp::media::MediaHandler::constPtr

Definition at line 50 of file MediaHandler.h.

## Constructor & Destructor Documentation

## ◆ MediaHandler()

zypp::media::MediaHandler::MediaHandler | ( | const Url & | url_r,
|  | const Pathname & | attach_point_r,
|  | const Pathname & | urlpath_below_attachpoint_r,
|  | const bool | does_download_r
| ) |  |

If the concrete media handler provides a nonempty attach_point, it must be an existing directory.

On an empty attach_point, MediaHandler will create a temporay directory, which will be erased from destructor.

On any error, the attach_point is set to an empty Pathname, which should lead to E_bad_attachpoint.

Definition at line 54 of file MediaHandler.cc.

## ◆ ~MediaHandler()

zypp::media::MediaHandler::~MediaHandler | ( |  | ) |
| virtual

Contolling MediaAccess takes care, that attached media is released prior to deleting this.

Definition at line 105 of file MediaHandler.cc.

## Member Function Documentation

## ◆ setAttachPrefix()

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

Definition at line 313 of file MediaHandler.cc.

## ◆ getRealPath() [1/2]

std::string zypp::media::MediaHandler::getRealPath | ( | const std::string & | path | ) |
| static

Definition at line 121 of file MediaHandler.cc.

## ◆ getRealPath() [2/2]

zypp::Pathname zypp::media::MediaHandler::getRealPath | ( | const Pathname & | path | ) |
| static

Definition at line 158 of file MediaHandler.cc.

## ◆ dependsOnParent() [1/2]

bool zypp::media::MediaHandler::dependsOnParent | ( | MediaAccessId | parentId,
|  | bool | exactIdMatch
| ) |  |
| protected

Check if the current media handler depends on an another handler specified by media access id.

Parameters

  parentId | The id of the parent handler to check against.

Returns
  true if it depends, false if not.

Definition at line 964 of file MediaHandler.cc.

## ◆ dependsOnParent() [2/2]

bool zypp::media::MediaHandler::dependsOnParent | ( |  | ) |
| protected

Definition at line 958 of file MediaHandler.cc.

## ◆ resetParentId()

void zypp::media::MediaHandler::resetParentId | ( |  | ) |
| protected

Called in case, where the media manager takes over the destruction of the parent id (e.g.

while destruction of the media manager).

Definition at line 115 of file MediaHandler.cc.

## ◆ attachPoint()

Pathname zypp::media::MediaHandler::attachPoint | ( |  | ) | const
| protected

Return the currently used attach point.

Definition at line 215 of file MediaHandler.cc.

## ◆ setAttachPoint() [1/2]

void zypp::media::MediaHandler::setAttachPoint | ( | const Pathname & | path,
|  | bool | temp
| ) |  |
| protected

Set a new attach point.

Parameters

  path | The attach point directory path.
  temp | If to remove the attach point while cleanup.

Definition at line 230 of file MediaHandler.cc.

## ◆ setAttachPoint() [2/2]

void zypp::media::MediaHandler::setAttachPoint | ( | const AttachPointRef & | ref | ) |
| protected

Set a (shared) attach point.

Parameters

  ref | New attach point reference.

Definition at line 253 of file MediaHandler.cc.

## ◆ attachPointHint() [1/2]

AttachPoint zypp::media::MediaHandler::attachPointHint | ( |  | ) | const
| protected

Get the actual attach point hint.

Definition at line 285 of file MediaHandler.cc.

## ◆ attachPointHint() [2/2]

void zypp::media::MediaHandler::attachPointHint | ( | const Pathname & | path,
|  | bool | temp
| ) |  |
| protected

Set the attach point hint as specified by the user.

Parameters

  path | The attach point directory path.
  temp | If to remove the attach point while cleanup.

Definition at line 270 of file MediaHandler.cc.

## ◆ createAttachPoint() [1/2]

Pathname zypp::media::MediaHandler::createAttachPoint | ( |  | ) | const
| protected

Try to create a default / temporary attach point.

It tries to create it in attachPrefix if avaliable, then in built-in directories.

Exceptions

  MediaBadAttachPointException | if no attach point can be created

Returns
  The name of the new attach point

Definition at line 342 of file MediaHandler.cc.

## ◆ createAttachPoint() [2/2]

Pathname zypp::media::MediaHandler::createAttachPoint | ( | const Pathname & | attach_root | ) | const
| protected

Try to create a temporary attach point in specified root.

Parameters

  attach_root | The attach root dir where to create the attach point in.

Returns
  The name of the new attach point or empty path name.

Definition at line 378 of file MediaHandler.cc.

## ◆ removeAttachPoint()

void zypp::media::MediaHandler::removeAttachPoint | ( |  | ) |
| protected

Remove unused attach point.

If the attach point is temporary, the attach point directory and all it content will be removed.

Definition at line 173 of file MediaHandler.cc.

## ◆ checkAttachPoint() [1/2]

bool zypp::media::MediaHandler::checkAttachPoint | ( | const Pathname & | apoint | ) | const
| protectedvirtual

Verify if the specified directory as attach point (root) as requires by the particular media handler implementation.

Parameters

  apoint | The directory to check.

Returns
  True, if the directory checks succeeded.

Reimplemented in zypp::media::MediaCurl.

Definition at line 884 of file MediaHandler.cc.

## ◆ checkAttachPoint() [2/2]

bool zypp::media::MediaHandler::checkAttachPoint | ( | const Pathname & | apoint,
|  | bool | empty_dir,
|  | bool | writeable
| ) |  |
| staticprotected

Verify if the specified directory as attach point (root) using requested checks.

Parameters

  apoint | The directory to check.
  empty_dir | Check if the directory is empty.
  writeable | Check if the directory is writeable.

Returns
  True, if the directory checks succeeded.

Definition at line 891 of file MediaHandler.cc.

## ◆ isUseableAttachPoint()

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

Ask media manager, if the specified path is already used as attach point or if there are another attach points bellow of it.

Parameters

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

Returns
  True, if the path can be used as attach point.

Definition at line 446 of file MediaHandler.cc.

## ◆ mediaSourceName()

std::string zypp::media::MediaHandler::mediaSourceName | ( |  | ) | const
| inlineprotected

Get the media source name or an empty string.

Returns
  media source name or empty string.

Definition at line 230 of file MediaHandler.h.

## ◆ setMediaSource()

void zypp::media::MediaHandler::setMediaSource | ( | const MediaSourceRef & | ref | ) |
| protected

Set new media source reference.

Parameters

  ref | The new reference.

Definition at line 462 of file MediaHandler.cc.

## ◆ findAttachedMedia()

AttachedMedia zypp::media::MediaHandler::findAttachedMedia | ( | const MediaSourceRef & | media | ) | const
| protected

Ask the media manager if specified media source is already attached.

Definition at line 299 of file MediaHandler.cc.

## ◆ attachedMedia()

AttachedMedia zypp::media::MediaHandler::attachedMedia | ( |  | ) | const
| protected

Returns the attached media.

Used by MediaManager to find other handlers using the same source.

Note
  This function increments reference counters on the mediaSource and attachPoint references it contains, for the life time of the returned object. That is, it enables a (temporary) sharing of them.

Returns
  The AttachedMedia struct containing (shared) references to media source and attach point.

Definition at line 478 of file MediaHandler.cc.

## ◆ isSharedMedia()

bool zypp::media::MediaHandler::isSharedMedia | ( |  | ) | const
| protected

Returns a hint if the media is shared or not.

Returns
  true, if media is shared.

Definition at line 495 of file MediaHandler.cc.

## ◆ checkAttached()

bool zypp::media::MediaHandler::checkAttached | ( | bool | matchMountFs | ) | const
| protected

Check actual mediaSource attachment against the current mount table of the system.

Used to implement isAttached().

Parameters

  matchMountFs | If to use the filesystem type from the mount table (nfs, smb and cifs) or from mediaSource while compare of a mount entry with mediaSource.

Returns
  true, if the media appears in the mount table.

Definition at line 509 of file MediaHandler.cc.

## ◆ forceRelaseAllMedia() [1/2]

void zypp::media::MediaHandler::forceRelaseAllMedia | ( | bool | matchMountFs | ) |
| protected

Call to this function will try to release all media matching the currenlty attached media source, that it is able to find in the mount table.

This means also foreign (user) mounts!

Parameters

  matchMountFs | If to use the filesystem type from the mount table (nfs, smb and cifs) or from mediaSource while compare of a mount entry with mediaSource.

Definition at line 814 of file MediaHandler.cc.

## ◆ forceRelaseAllMedia() [2/2]

void zypp::media::MediaHandler::forceRelaseAllMedia | ( | const MediaSourceRef & | ref,
|  | bool | matchMountFs
| ) |  |
| protected

Definition at line 819 of file MediaHandler.cc.

## ◆ attachTo()

virtual void zypp::media::MediaHandler::attachTo | ( | bool | next = `false` | ) |
| protectedpure virtual

Call concrete handler to attach the media.

Asserted that not already attached, and attachPoint is a directory.

Parameters

  next | try next available device in turn until end of device list is reached (for media which are accessible through multiple devices like cdroms).

Exceptions

  MediaException |

Implemented in zypp::media::MediaCD, zypp::media::MediaCIFS, zypp::media::MediaCurl, zypp::media::MediaDIR, zypp::media::MediaDISK, zypp::media::MediaISO, zypp::media::MediaNFS, and zypp::media::MediaPlugin.

## ◆ disconnectFrom()

virtual void zypp::media::MediaHandler::disconnectFrom | ( |  | ) |
| inlineprotectedvirtual

Call concrete handler to disconnect media.

Asserted that media is attached.

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

After calling disconnect() it's not possible to call provideFile() or provideDir() anymore.

Exceptions

  MediaException |

Reimplemented in zypp::media::MediaCurl.

Definition at line 326 of file MediaHandler.h.

## ◆ releaseFrom()

virtual void zypp::media::MediaHandler::releaseFrom | ( | const std::string & | ejectDev = `""` | ) |
| protectedpure virtual

Call concrete handler to release the media.

If eject is true, and the media is used in one handler instance only, physically eject the media (i.e. CD-ROM).

Asserted that media is attached.

Parameters

  ejectDev | Device to eject. None if empty.

Exceptions

  MediaException |

Implemented in zypp::media::MediaCD, zypp::media::MediaCIFS, zypp::media::MediaCurl, zypp::media::MediaDIR, zypp::media::MediaDISK, zypp::media::MediaNFS, zypp::media::MediaISO, and zypp::media::MediaPlugin.

## ◆ forceEject()

virtual void zypp::media::MediaHandler::forceEject | ( | const std::string & | device | ) |
| inlineprotectedvirtual

Call concrete handler to physically eject the media (i.e.

CD-ROM) in case the media is not attached..

Asserted that media is not attached.

Reimplemented in zypp::media::MediaCD.

Definition at line 348 of file MediaHandler.h.

## ◆ getFile()

void zypp::media::MediaHandler::getFile | ( | const Pathname & | filename,
|  | const ByteCount & | expectedFileSize_r
| ) |  | const
| protectedvirtual

Call concrete handler to provide file below attach point.

Default implementation provided, that returns whether a file is located at 'localRoot + filename'.

Asserted that media is attached.

Exceptions

  MediaException |

Reimplemented in zypp::media::MediaCD, zypp::media::MediaCIFS, zypp::media::MediaCurl, zypp::media::MediaDIR, zypp::media::MediaDISK, zypp::media::MediaISO, zypp::media::MediaNFS, and zypp::media::MediaPlugin.

Definition at line 1234 of file MediaHandler.cc.

## ◆ getFileCopy()

void zypp::media::MediaHandler::getFileCopy | ( | const Pathname & | srcFilename,
|  | const Pathname & | targetFilename,
|  | const ByteCount & | expectedFileSize_r
| ) |  | const
| protectedvirtual

Call concrete handler to provide a file under a different place in the file system (usually not under attach point) as a copy.

Media must be attached before by callee.

Default implementation provided that calls getFile(srcFilename) and copies the result around.

Exceptions

  MediaException |

Reimplemented in zypp::media::MediaCurl.

Definition at line 1248 of file MediaHandler.cc.

## ◆ getDir()

void zypp::media::MediaHandler::getDir | ( | const Pathname & | dirname,
|  | bool | recurse_r
| ) |  | const
| protectedpure virtual

Call concrete handler to provide directory content (not recursive!) below attach point.

Return E_not_supported_by_media if media does not support retrieval of directory content.

Default implementation provided, that returns whether a directory is located at 'localRoot + dirname'.

Asserted that media is attached.

Exceptions

  MediaException |

Implemented in zypp::media::MediaCD, zypp::media::MediaCIFS, zypp::media::MediaCurl, zypp::media::MediaDIR, zypp::media::MediaDISK, zypp::media::MediaISO, zypp::media::MediaNFS, and zypp::media::MediaPlugin.

Definition at line 1268 of file MediaHandler.cc.

## ◆ getDirInfo() [1/2]

void zypp::media::MediaHandler::getDirInfo | ( | std::list< std::string > & | retlist,
|  | const Pathname & | dirname,
|  | bool | dots = `true`
| ) |  | const
| protectedpure virtual

Call concrete handler to provide a content list of directory on media via retlist.

If dots is false entries starting with '.' are not reported.

Return E_not_supported_by_media if media does not support retrieval of directory content.

Default implementation provided, that returns the content of a directory at 'localRoot + dirnname' retrieved via 'readdir'.

Asserted that media is attached and retlist is empty.

Exceptions

  MediaException |

Implemented in zypp::media::MediaCD, zypp::media::MediaCIFS, zypp::media::MediaCurl, zypp::media::MediaDIR, zypp::media::MediaDISK, zypp::media::MediaISO, zypp::media::MediaNFS, and zypp::media::MediaPlugin.

Definition at line 1290 of file MediaHandler.cc.

## ◆ getDirInfo() [2/2]

void zypp::media::MediaHandler::getDirInfo | ( | filesystem::DirContent & | retlist,
|  | const Pathname & | dirname,
|  | bool | dots = `true`
| ) |  | const
| protectedpure virtual

Basically the same as getDirInfo above.

The content list is returned as filesystem::DirContent, which includes name and filetype of each directory entry. Retrieving the filetype usg. requires an additional ::stat call for each entry, thus it's more expensive than a simple readdir.

Asserted that media is attached and retlist is empty.

Exceptions

  MediaException |

Implemented in zypp::media::MediaCD, zypp::media::MediaCIFS, zypp::media::MediaCurl, zypp::media::MediaDIR, zypp::media::MediaDISK, zypp::media::MediaISO, zypp::media::MediaNFS, and zypp::media::MediaPlugin.

Definition at line 1334 of file MediaHandler.cc.

## ◆ getDoesFileExist()

bool zypp::media::MediaHandler::getDoesFileExist | ( | const Pathname & | filename | ) | const
| protectedpure virtual

check if a file exists

Asserted that url is a file and not a dir.

Exceptions

  MediaException |

Implemented in zypp::media::MediaCD, zypp::media::MediaCIFS, zypp::media::MediaCurl, zypp::media::MediaDIR, zypp::media::MediaDISK, zypp::media::MediaISO, zypp::media::MediaNFS, and zypp::media::MediaPlugin.

Definition at line 1375 of file MediaHandler.cc.

## ◆ getDirectoryYast() [1/2]

void zypp::media::MediaHandler::getDirectoryYast | ( | std::list< std::string > & | retlist,
|  | const Pathname & | dirname,
|  | bool | dots = `true`
| ) |  | const
| protected

Retrieve and if available scan dirname/directory.yast.

Asserted that media is attached.

Exceptions

  MediaException |

Definition at line 1151 of file MediaHandler.cc.

## ◆ getDirectoryYast() [2/2]

void zypp::media::MediaHandler::getDirectoryYast | ( | filesystem::DirContent & | retlist,
|  | const Pathname & | dirname,
|  | bool | dots = `true`
| ) |  | const
| protected

Retrieve and if available scan dirname/directory.yast.

Asserted that media is attached.

Exceptions

  MediaException |

Definition at line 1171 of file MediaHandler.cc.

## ◆ downloads()

bool zypp::media::MediaHandler::downloads | ( |  | ) | const
| inline

Hint if files are downloaded or not.

Definition at line 497 of file MediaHandler.h.

## ◆ protocol()

std::string zypp::media::MediaHandler::protocol | ( |  | ) | const
| inline

Protocol hint for MediaAccess.

Definition at line 502 of file MediaHandler.h.

## ◆ url()

Url zypp::media::MediaHandler::url | ( |  | ) | const
| inline

Url used.

Definition at line 507 of file MediaHandler.h.

## ◆ attach()

void zypp::media::MediaHandler::attach | ( | bool | next | ) |

Use concrete handler to attach the media.

Parameters

  next | try next available device in turn until end of device list is reached (for media which are accessible through multiple devices like cdroms).

Exceptions

  MediaException |

Definition at line 669 of file MediaHandler.cc.

## ◆ isAttached()

virtual bool zypp::media::MediaHandler::isAttached | ( |  | ) | const
| inlinevirtual

True if media is attached.

Reimplemented in zypp::media::MediaCD, zypp::media::MediaCIFS, zypp::media::MediaDISK, zypp::media::MediaISO, and zypp::media::MediaNFS.

Definition at line 524 of file MediaHandler.h.

## ◆ localRoot()

Pathname zypp::media::MediaHandler::localRoot | ( |  | ) | 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 better 'localPath( filename )'.

Returns empty pathname if E_bad_attachpoint

Definition at line 236 of file MediaHandler.cc.

## ◆ localPath()

Pathname zypp::media::MediaHandler::localPath | ( | const Pathname & | pathname | ) | const

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

Returns empty pathname if E_bad_attachpoint

Definition at line 700 of file MediaHandler.cc.

## ◆ disconnect()

void zypp::media::MediaHandler::disconnect | ( |  | ) |

Use concrete handler to isconnect media.

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

After calling disconnect() it's not possible to call provideFile() or provideDir() anymore.

Exceptions

  MediaException |

Definition at line 723 of file MediaHandler.cc.

## ◆ release()

void zypp::media::MediaHandler::release | ( | const std::string & | ejectDev = `""` | ) |

Use concrete handler to release the media.

Parameters

  eject | Device to physically eject. None if empty.

Exceptions

  MediaException |

Definition at line 740 of file MediaHandler.cc.

## ◆ provideFile()

void zypp::media::MediaHandler::provideFile | ( | Pathname | filename,
|  | const ByteCount & | expectedFileSize_r
| ) |  | const

Use concrete handler to provide file denoted by path below 'localRoot'.

Filename is interpreted relative to the attached url and a path prefix is preserved.

Exceptions

  MediaException |

Definition at line 1006 of file MediaHandler.cc.

## ◆ provideFileCopy()

void zypp::media::MediaHandler::provideFileCopy | ( | Pathname | srcFilename,
|  | Pathname | targetFilename,
|  | const ByteCount & | expectedFileSize_r
| ) |  | const

Call concrete handler to provide a copy of a file under a different place in the file system (usually not under attach point) as a copy.

Media must be attached before by callee.

Parameters

  srcFilename | Filename of source file on the media
  targetFilename | Filename for the target in the file system

Exceptions

  MediaException |

Definition at line 993 of file MediaHandler.cc.

## ◆ provideDir()

void zypp::media::MediaHandler::provideDir | ( | Pathname | dirname | ) | const

Use concrete handler to provide directory denoted by path below 'localRoot' (not recursive!).

dirname is interpreted relative to the attached url and a path prefix is preserved.

Exceptions

  MediaException |

Definition at line 1026 of file MediaHandler.cc.

## ◆ provideDirTree()

void zypp::media::MediaHandler::provideDirTree | ( | Pathname | dirname | ) | const

Use concrete handler to provide directory tree denoted by path below 'localRoot' (recursive!!).

dirname is interpreted relative to the attached url and a path prefix is preserved.

Exceptions

  MediaException |

Definition at line 1045 of file MediaHandler.cc.

## ◆ releaseFile()

void zypp::media::MediaHandler::releaseFile | ( | const Pathname & | filename | ) | const
| inline

Remove filename below localRoot IFF handler downloads files to the local filesystem.

Never remove anything from media.

Exceptions

  MediaException |

Definition at line 618 of file MediaHandler.h.

## ◆ releaseDir()

void zypp::media::MediaHandler::releaseDir | ( | const Pathname & | dirname | ) | const
| inline

Remove directory tree below localRoot IFF handler downloads files to the local filesystem.

Never remove anything from media.

Exceptions

  MediaException |

Definition at line 627 of file MediaHandler.h.

## ◆ releasePath()

void zypp::media::MediaHandler::releasePath | ( | Pathname | pathname | ) | const

Remove pathname below localRoot IFF handler downloads files to the local filesystem.

Never remove anything from media.

If pathname denotes a directory it is recursively removed. If pathname is empty or '/' everything below the localRoot is recursively removed. If pathname denotes a file it is unlinked.

Exceptions

  MediaException |

Definition at line 1064 of file MediaHandler.cc.

## ◆ setDeltafile()

void zypp::media::MediaHandler::setDeltafile | ( | const Pathname & | filename = `Pathname()` | ) | const

Definition at line 1400 of file MediaHandler.cc.

## ◆ deltafile()

Pathname zypp::media::MediaHandler::deltafile | ( |  | ) | const

Definition at line 1405 of file MediaHandler.cc.

## ◆ dirInfo() [1/2]

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

Return content of directory on media via retlist.

If dots is false entries starting with '.' are not reported.

The request is forwarded to the concrete handler, which may atempt to retieve the content e.g. via 'readdir'

Caution: This is not supported by all media types. Be prepared to handle E_not_supported_by_media.

Exceptions

  MediaException |

Definition at line 1090 of file MediaHandler.cc.

## ◆ dirInfo() [2/2]

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

Basically the same as dirInfo above.

The content is returned as filesystem::DirContent, which includes name and filetype of each directory entry. Retrieving the filetype usg. requires an additional ::stat call for each entry, thus it's more expensive than a simple readdir.

Caution: This is not supported by all media types. Be prepared to handle E_not_supported_by_media.

Exceptions

  MediaException |

Definition at line 1112 of file MediaHandler.cc.

## ◆ doesFileExist()

bool zypp::media::MediaHandler::doesFileExist | ( | const Pathname & | filename | ) | const

check if a file exists

Asserted that url is a file and not a dir.

Exceptions

  MediaException |

Definition at line 1134 of file MediaHandler.cc.

## ◆ hasMoreDevices()

bool zypp::media::MediaHandler::hasMoreDevices | ( |  | ) |
| virtual

Check if the media has one more device available for attach(true).

Reimplemented in zypp::media::MediaCD.

Definition at line 1384 of file MediaHandler.cc.

## ◆ getDetectedDevices()

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

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

  devices | vector to load with the device names
  index | index of the currently used device in the devices vector

Reimplemented in zypp::media::MediaCD.

Definition at line 1389 of file MediaHandler.cc.

## Friends And Related Function Documentation

## ◆ MediaAccess

friend class MediaAccess
| friend

MediaAccess (MediaManager) needs access to the attachedMedia() function to deliver a shared media source and its attach point to the media manager and then to other media handler instances.

Further, is needs to be able to forward the dependsOnParent() and resetParentId() functions to the media manager.

Definition at line 124 of file MediaHandler.h.

## ◆ operator<<

std::ostream& operator<< | ( | std::ostream & | str,
|  | const MediaHandler & | obj
| ) |  |
| friend

Definition at line 1218 of file MediaHandler.cc.

## Member Data Documentation

## ◆ _attachPrefix

Pathname zypp::media::MediaHandler::_attachPrefix
| staticprivate

User defined default attach point prefix.

Definition at line 61 of file MediaHandler.h.

## ◆ _mediaSource

MediaSourceRef zypp::media::MediaHandler::_mediaSource
| mutableprivate

The attached media source description reference.

Definition at line 67 of file MediaHandler.h.

## ◆ _attachPoint

AttachPointRef zypp::media::MediaHandler::_attachPoint
| private

This is where the media will be actually attached ("mounted").

All files are provided bellow this + _relativeRoot directory.

Definition at line 73 of file MediaHandler.h.

## ◆ _attachPointHint

AttachPoint zypp::media::MediaHandler::_attachPointHint
| private

The user provided attach preferred point.

It may contain following values:

     "",  true  => create temporary attach point bellow of
                   _attachPrefix or a built-in default and
                   remove it if not needed any more.

     dir, false => user specified attach point (not removed)

Definition at line 85 of file MediaHandler.h.

## ◆ _relativeRoot

Pathname zypp::media::MediaHandler::_relativeRoot
| private

The relative root directory of the data on the media.

See also localRoot() and urlpath_below_attachpoint_r constructor argument.

Definition at line 92 of file MediaHandler.h.

## ◆ _does_download

bool zypp::media::MediaHandler::_does_download
| private

True if concrete handler downloads files to the local filesystem.

If true releaseFile/Dir will delete them.

Definition at line 98 of file MediaHandler.h.

## ◆ _attach_mtime

time_t zypp::media::MediaHandler::_attach_mtime
| mutableprivate

timestamp of the the last attach verification

Definition at line 101 of file MediaHandler.h.

## ◆ _deltafile

Pathname zypp::media::MediaHandler::_deltafile
| mutableprivate

file usable for delta downloads

Definition at line 104 of file MediaHandler.h.

## ◆ _url

const Url zypp::media::MediaHandler::_url
| protected

Url to handle.

Definition at line 110 of file MediaHandler.h.

## ◆ _parentId

MediaAccessId zypp::media::MediaHandler::_parentId
| protected

Access Id of media handler we depend on.

Definition at line 115 of file MediaHandler.h.

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

- zypp/media/MediaHandler.h
- zypp/media/MediaHandler.cc