Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

MediaAccess Class Reference

Handle access to a medium. More...

#include <MediaAccess.h>

Inheritance diagram for MediaAccess:

CountedRep Rep List of all members.

Public Types

typedef MediaError Error

Public Member Functions

 MediaAccess ()
PMError open (const Url &url, const Pathname &preferred_attach_point="")
bool isOpen () const
Url::Protocol protocol () const
Url url () const
PMError close ()
PMError attach (bool next=false)
bool isAttached () const
const PathnamelocalRoot () const
Pathname localPath (const Pathname &pathname) const
PMError disconnect ()
PMError release (bool eject=false)
PMError provideFile (const Pathname &filename, bool cached=false) const
PMError releaseFile (const Pathname &filename) const
PMError provideDir (const Pathname &dirname) const
PMError releaseDir (const Pathname &dirname) const
PMError releasePath (const 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
virtual ~MediaAccess ()
virtual std::ostream & dumpOn (std::ostream &str) const

Static Public Member Functions

PMError getFile (const Url &from, const Pathname &to)

Private Member Functions

 REP_BODY (MediaAccess)

Private Attributes

MediaHandler_handler

Static Private Attributes

const Pathname _noPath

Detailed Description

Handle access to a medium.

The concrete MediaHandler for a certain url is created on open and deleted on .

The inteface here basically checks whether the handler exists, then forwards the request to MediaHandler.


Member Typedef Documentation

typedef MediaError MediaAccess::Error
 

default error class


Constructor & Destructor Documentation

MediaAccess::MediaAccess  ) 
 

constructor

MediaAccess::~MediaAccess  )  [virtual]
 

Destructor


Member Function Documentation

PMError MediaAccess::attach bool  next = false  ) 
 

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).

PMError MediaAccess::close  ) 
 

close url

PMError MediaAccess::dirInfo PathInfo::dircontent retlist,
const Pathname dirname,
bool  dots = true
const
 

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.

PMError MediaAccess::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.

PMError MediaAccess::disconnect  ) 
 

Use concrete handler to disconnect the 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.

std::ostream & MediaAccess::dumpOn std::ostream &  str  )  const [virtual]
 

Reimplemented from CountedRep.

PMError MediaAccess::getFile const Url from,
const Pathname to
[static]
 

Get file from location at specified by URL and copy it to destination.

Parameters:
from Source URL
to Destination file name

bool MediaAccess::isAttached  )  const
 

True if media is attached.

bool MediaAccess::isOpen  )  const [inline]
 

True if media is open.

Pathname MediaAccess::localPath const Pathname pathname  )  const
 

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

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

const Pathname & MediaAccess::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 )'.

If media is not open an empty pathname is returned.

PMError MediaAccess::open const Url url,
const Pathname preferred_attach_point = ""
 

open url. If preferred_attach_point is given, try to use it as attach point.

Caution: The medium can choose a different attach point. Only getAttachPoint() knows the real attach point.

Url::Protocol MediaAccess::protocol  )  const
 

Used Protocol if media is opened, otherwise 'unknown'.

PMError MediaAccess::provideDir const Pathname dirname  )  const
 

Use concrete handler to provide directory denoted by path below 'attach point' (not recursive!). 'dirname' is interpreted relative to the attached url and a path prefix is preserved.

PMError MediaAccess::provideFile const Pathname filename,
bool  cached = false
const
 

Use concrete handler to provide file denoted by path below 'attach point'. Filename is interpreted relative to the attached url and a path prefix is preserved.

Parameters:
cached If cached is set to true, the function checks, if the file already exists and doesn't download it again if it does. Currently only the existence is checked, no other file attributes.

PMError MediaAccess::release bool  eject = false  ) 
 

Use concrete handler to release the media.

Parameters:
eject if true, physically eject the media * (i.e. CD-ROM)

PMError MediaAccess::releaseDir const Pathname dirname  )  const
 

Remove directory tree below attach point IFF handler downloads files to the local filesystem. Never remove anything from media.

PMError MediaAccess::releaseFile const Pathname filename  )  const
 

Remove filename below attach point IFF handler downloads files to the local filesystem. Never remove anything from media.

PMError MediaAccess::releasePath const Pathname pathname  )  const
 

Remove pathname below attach point 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 attachpoint is recursively removed.

MediaAccess::REP_BODY MediaAccess   )  [private]
 

Url MediaAccess::url  )  const
 

Url if media is opened, otherwise empty.


Member Data Documentation

MediaHandler* MediaAccess::_handler [private]
 

handler for 'physical' media == 0 if not open

const Pathname MediaAccess::_noPath [static, private]
 


The documentation for this class was generated from the following files:
Generated on Fri Nov 9 14:30:32 2007 for yast2-packagemanager by doxygen 1.3.6