#include <MediaHandler.h>
Inheritance diagram for MediaHandler:
Public Types | |
typedef MediaError | Error |
Public Member Functions | |
MediaHandler (const Url &url_r, const Pathname &attach_point_r, const bool attachPoint_is_mediaroot_r, const bool does_download_r) | |
virtual | ~MediaHandler () |
Url::Protocol | protocol () const |
Url | url () const |
PMError | attach (bool next) |
bool | isAttached () const |
const Pathname & | localRoot () const |
Pathname | localPath (const Pathname &pathname) const |
PMError | disconnect () |
PMError | release (bool eject=false) |
PMError | provideFile (Pathname filename) const |
PMError | provideFileCopy (Pathname srcFilename, Pathname targetFilename) const |
PMError | provideDir (Pathname dirname) const |
PMError | releaseFile (const Pathname &filename) const |
PMError | releaseDir (const Pathname &dirname) const |
PMError | releasePath (Pathname pathname) const |
PMError | dirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const |
PMError | dirInfo (PathInfo::dircontent &retlist, const Pathname &dirname, bool dots=true) const |
Protected Member Functions | |
const Pathname & | attachPoint () const |
virtual PMError | attachTo (bool next=false)=0 |
virtual PMError | disconnectFrom () |
virtual PMError | releaseFrom (bool eject)=0 |
virtual void | forceEject () |
virtual PMError | getFile (const Pathname &filename) const=0 |
virtual PMError | getFileCopy (const Pathname &srcFilename, const Pathname &targetFilename) const |
virtual PMError | getDir (const Pathname &dirname) const=0 |
virtual PMError | getDirInfo (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const=0 |
virtual PMError | getDirInfo (PathInfo::dircontent &retlist, const Pathname &dirname, bool dots=true) const=0 |
PMError | getDirectoryYast (std::list< std::string > &retlist, const Pathname &dirname, bool dots=true) const |
PMError | getDirectoryYast (PathInfo::dircontent &retlist, const Pathname &dirname, bool dots=true) const |
Protected Attributes | |
const Url | _url |
Private Attributes | |
Pathname | _attachPoint |
bool | _tmp_attachPoint |
bool | _attachPoint_is_mediaroot |
Pathname | _localRoot |
bool | _does_download |
bool | _isAttached |
Friends | |
std::ostream & | operator<< (std::ostream &str, const MediaHandler &obj) |
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.
|
default error class |
|
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. |
|
Contolling MediaAccess takes care, that attached media is released prior to deleting this. |
|
Use concrete handler to attach the media.
|
|
Attachpoint to use |
|
Call concrete handler to attach the media. Asserted that not already attached, and attachPoint is a directory.
|
|
Basically the same as dirInfo above. The content is returned as PathInfo::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. |
|
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. |
|
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. |
|
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. Reimplemented in MediaCurl. |
|
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 MediaCD. |
|
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. |
|
Retrieve and if available scan dirname/directory.yast. Asserted that media is attached. |
|
Retrieve and if available scan dirname/directory.yast. Asserted that media is attached. |
|
Basically the same as getDirInfo above. The content list is returned as PathInfo::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. |
|
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. |
|
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. |
|
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. Reimplemented in MediaCurl. |
|
True if media is attached. |
|
Files provided will be available at 'localPath(filename)'. Returns empty pathname if E_bad_attachpoint |
|
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 |
|
Protocol hint for MediaAccess. |
|
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. |
|
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. |
|
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.
|
|
Use concrete handler to release the media.
|
|
Remove directory tree below localRoot IFF handler downloads files to the local filesystem. Never remove anything from media. |
|
Remove filename below localRoot IFF handler downloads files to the local filesystem. Never remove anything from media. |
|
Call concrete handler to release the media. If eject is true, physically eject the media (i.e. CD-ROM). Asserted that media is attached. |
|
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. |
|
Url used. |
|
|
|
this is where the media will be actually "mounted" all files are provided 'below' this directory. |
|
True if the medias root dir will be attached to _attachPoint (e.g. CD). If so, filenames are relative to '_attachPoint + _url.getPath()'. If not (e.g. DIR, NFS) filenames are relative to '_attachPoint'. |
|
True if concrete handler downloads files to the local filesystem. If true releaseFile/Dir will delete them. |
|
True, if media is attached. |
|
Dependent on _attachPoint_is_mediaroot either _attachPoint or '_attachPoint + _url.getPath()'. |
|
If a default attach point was created, it has to be removed on destuction. |
|
Url to handle |