libzypp  13.10.6
zypp::media::MediaCD Class Reference

Implementation class for CD/DVD MediaHandler. More...

#include <MediaCD.h>

Inheritance diagram for zypp::media::MediaCD:
zypp::media::MediaHandler

Public Member Functions

 MediaCD (const Url &url_r, const Pathname &attach_point_hint_r)
 
virtual ~MediaCD ()
 
virtual bool isAttached () const
 True if media is attached. More...
 
- Public Member Functions inherited from 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. 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...
 
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
 Use concrete handler to provide file denoted by path below 'localRoot'. More...
 
void provideFileCopy (Pathname srcFilename, Pathname targetFilename) 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...
 

Protected Member Functions

virtual void attachTo (bool next=false)
 Call concrete handler to attach the media. More...
 
virtual void releaseFrom (const std::string &ejectDev)
 Call concrete handler to release the media. More...
 
virtual void getFile (const Pathname &filename) const
 Call concrete handler to provide file below attach point. More...
 
virtual void getDir (const Pathname &dirname, bool recurse_r) const
 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
 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
 Basically the same as getDirInfo above. More...
 
virtual bool getDoesFileExist (const Pathname &filename) const
 check if a file exists More...
 
virtual void forceEject (const std::string &ejectDev)
 Call concrete handler to physically eject the media (i.e. 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...
 
- Protected Member Functions inherited from zypp::media::MediaHandler
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 disconnectFrom ()
 Call concrete handler to disconnect media. More...
 
virtual void getFileCopy (const Pathname &srcFilename, const Pathname &targetFilename) 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...
 
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...
 

Private Types

typedef std::list< MediaSourceDeviceList
 

Private Member Functions

DeviceList detectDevices (bool supportingDVD) const
 

Static Private Member Functions

static bool openTray (const std::string &device_r)
 
static bool closeTray (const std::string &device_r)
 

Private Attributes

DeviceList _devices
 list of devices to try to mount More...
 
int _lastdev
 number of last successful mounted device in list More...
 
int _lastdev_tried
 

Additional Inherited Members

- Public Types inherited from zypp::media::MediaHandler
typedef shared_ptr< MediaHandlerPtr
 
typedef shared_ptr< const
MediaHandler
constPtr
 
- Static Public Member Functions inherited from zypp::media::MediaHandler
static bool setAttachPrefix (const Pathname &attach_prefix)
 
static std::string getRealPath (const std::string &path)
 
static Pathname getRealPath (const Pathname &path)
 
- Static Protected Member Functions inherited from zypp::media::MediaHandler
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 inherited from zypp::media::MediaHandler
const Url _url
 Url to handle. More...
 
MediaAccessId _parentId
 Access Id of media handler we depend on. More...
 

Detailed Description

Implementation class for CD/DVD MediaHandler.

See Also
MediaHandler

Definition at line 28 of file MediaCD.h.

Member Typedef Documentation

typedef std::list<MediaSource> zypp::media::MediaCD::DeviceList
private

Definition at line 31 of file MediaCD.h.

Constructor & Destructor Documentation

zypp::media::MediaCD::MediaCD ( const Url url_r,
const Pathname &  attach_point_hint_r 
)

Definition at line 203 of file MediaCD.cc.

virtual zypp::media::MediaCD::~MediaCD ( )
inlinevirtual

Definition at line 69 of file MediaCD.h.

Member Function Documentation

bool zypp::media::MediaCD::openTray ( const std::string &  device_r)
staticprivate

Definition at line 250 of file MediaCD.cc.

bool zypp::media::MediaCD::closeTray ( const std::string &  device_r)
staticprivate

Definition at line 309 of file MediaCD.cc.

MediaCD::DeviceList zypp::media::MediaCD::detectDevices ( bool  supportingDVD) const
private

Definition at line 327 of file MediaCD.cc.

void zypp::media::MediaCD::attachTo ( bool  next = false)
protectedvirtual

Call concrete handler to attach the media.

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

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

Implements zypp::media::MediaHandler.

Definition at line 403 of file MediaCD.cc.

void zypp::media::MediaCD::releaseFrom ( const std::string &  ejectDev)
protectedvirtual

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
ejectDevDevice to eject. None if empty.
Exceptions
MediaException

Implements zypp::media::MediaHandler.

Definition at line 616 of file MediaCD.cc.

void zypp::media::MediaCD::getFile ( const Pathname &  filename) 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

Implements zypp::media::MediaHandler.

Definition at line 723 of file MediaCD.cc.

void zypp::media::MediaCD::getDir ( const Pathname &  dirname,
bool  recurse_r 
) const
protectedvirtual

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

Implements zypp::media::MediaHandler.

Definition at line 735 of file MediaCD.cc.

void zypp::media::MediaCD::getDirInfo ( std::list< std::string > &  retlist,
const Pathname &  dirname,
bool  dots = true 
) const
protectedvirtual

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

Implements zypp::media::MediaHandler.

Definition at line 748 of file MediaCD.cc.

void zypp::media::MediaCD::getDirInfo ( filesystem::DirContent retlist,
const Pathname &  dirname,
bool  dots = true 
) const
protectedvirtual

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

Implements zypp::media::MediaHandler.

Definition at line 762 of file MediaCD.cc.

bool zypp::media::MediaCD::getDoesFileExist ( const Pathname &  filename) const
protectedvirtual

check if a file exists

Asserted that url is a file and not a dir.

Exceptions
MediaException

Implements zypp::media::MediaHandler.

Definition at line 768 of file MediaCD.cc.

void zypp::media::MediaCD::forceEject ( const std::string &  device)
protectedvirtual

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 from zypp::media::MediaHandler.

Definition at line 658 of file MediaCD.cc.

bool zypp::media::MediaCD::hasMoreDevices ( )
protectedvirtual

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

Reimplemented from zypp::media::MediaHandler.

Definition at line 774 of file MediaCD.cc.

void zypp::media::MediaCD::getDetectedDevices ( std::vector< std::string > &  devices,
unsigned int &  index 
) const
protectedvirtual

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
devicesvector to load with the device names
indexindex of the currently used device in the devices vector

Reimplemented from zypp::media::MediaHandler.

Definition at line 785 of file MediaCD.cc.

bool zypp::media::MediaCD::isAttached ( ) const
virtual

True if media is attached.

Reimplemented from zypp::media::MediaHandler.

Definition at line 711 of file MediaCD.cc.

Member Data Documentation

DeviceList zypp::media::MediaCD::_devices
mutableprivate

list of devices to try to mount

Definition at line 33 of file MediaCD.h.

int zypp::media::MediaCD::_lastdev
private

number of last successful mounted device in list

Definition at line 36 of file MediaCD.h.

int zypp::media::MediaCD::_lastdev_tried
private

Definition at line 37 of file MediaCD.h.


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