+
/*---------------------------------------------------------------------\
| ____ _ __ __ ___ |
| |__ / \ / / . \ . \ |
#include "zypp/media/MediaSource.h"
#include "zypp/media/MediaException.h"
+#include "zypp/APIConfig.h"
namespace zypp {
namespace media {
static bool setAttachPrefix(const Pathname &attach_prefix);
+ static std::string getRealPath(const std::string &path);
+ static Pathname getRealPath(const Pathname &path);
+
private:
/**
* User defined default attach point prefix.
*
* dir, false => user specified attach point (not removed)
*/
- AttachPoint _AttachPointHint;
+ AttachPoint _attachPointHint;
/**
* The relative root directory of the data on the media.
/** timestamp of the the last attach verification */
mutable time_t _attach_mtime;
+ /** file usable for delta downloads */
+ mutable Pathname _deltafile;
+
protected:
/**
* Url to handle
/**
* Try to create a default / temporary attach point.
- * It trys to create it in attachPrefix if avaliable,
+ * It tries to create it in attachPrefix if avaliable,
* then in built-in directories.
- * \return The name of the new attach point or empty path name.
+ * \throws MediaBadAttachPointException if no attach point can be created
+ * \return The name of the new attach point
*/
Pathname createAttachPoint() const;
/**
* as attach point or if there are another attach points
* bellow of it.
* \param path The attach point path to check.
+ * \param mtab Whether to check against the mtab, too.
* \return True, if the path can be used as attach point.
*/
- bool isUseableAttachPoint(const Pathname &path) const;
+ bool isUseableAttachPoint(const Pathname &path,
+ bool mtab=true) const;
/**
* Get the media source name or an empty string.
* while compare of a mount entry with mediaSource.
*/
void forceRelaseAllMedia(bool matchMountFs);
+ void forceRelaseAllMedia(const MediaSourceRef &ref,
+ bool matchMountFs);
protected:
* instance only, physically eject the media (i.e. CD-ROM).
*
* Asserted that media is attached.
+ * \param ejectDev Device to eject. None if empty.
*
* \throws MediaException
*
**/
- virtual void releaseFrom( bool eject ) = 0;
+ virtual void releaseFrom( const std::string & ejectDev = "" ) = 0;
/**
* Call concrete handler to physically eject the media (i.e. CD-ROM)
*
* Asserted that media is not attached.
**/
- virtual void forceEject() {}
+ virtual void forceEject( const std::string & device ) {}
/**
* Call concrete handler to provide file below attach point.
virtual void getDirInfo( filesystem::DirContent & retlist,
const Pathname & dirname, bool dots = true ) const = 0;
+ /**
+ * check if a file exists
+ *
+ * Asserted that url is a file and not a dir.
+ *
+ * \throws MediaException
+ *
+ **/
+ virtual bool getDoesFileExist( const Pathname & filename ) const = 0;
+
protected:
/**
/**
* True if media is attached.
**/
- virtual bool isAttached() const { return _mediaSource; }
+ virtual bool isAttached() const { return _mediaSource != nullptr; }
/**
* Return the local directory that corresponds to medias url,
/**
* Use concrete handler to release the media.
- * @param eject if true, physically eject the media * (i.e. CD-ROM)
+ * @param eject Device to physically eject. None if empty.
*
* \throws MediaException
- *
**/
- void release( bool eject = false );
+ void release( const std::string & ejectDev = "" );
/**
* Use concrete handler to provide file denoted by path below
**/
void releasePath( Pathname pathname ) const;
+ /*
+ * set a deltafile to be used in the next download
+ */
+ void setDeltafile( const Pathname &filename = Pathname()) const;
+
+ /*
+ * return the deltafile set with setDeltafile()
+ */
+ Pathname deltafile () const;
+
public:
/**
**/
void dirInfo( filesystem::DirContent & retlist,
const Pathname & dirname, bool dots = true ) const;
+
+ /**
+ * check if a file exists
+ *
+ * Asserted that url is a file and not a dir.
+ *
+ * \throws MediaException
+ *
+ **/
+ bool doesFileExist( const Pathname & filename ) const;
+
+ /**
+ * Check if the media has one more device available for attach(true).
+ */
+ virtual bool hasMoreDevices();
+
+ /**
+ * 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).
+ *
+ * \param devices vector to load with the device names
+ * \param index index of the currently used device in the devices vector
+ */
+ virtual void
+ getDetectedDevices(std::vector<std::string> & devices,
+ unsigned int & index) const;
};
///////////////////////////////////////////////////////////////////
-#define MEDIA_HANDLER_API \
- protected: \
- virtual void attachTo (bool next = false); \
- virtual void releaseFrom( bool eject ); \
- virtual void getFile( const Pathname & filename ) const; \
- virtual void getDir( const Pathname & dirname, bool recurse_r ) const; \
- virtual void getDirInfo( std::list<std::string> & retlist, \
- const Pathname & dirname, bool dots = true ) const; \
- virtual void getDirInfo( filesystem::DirContent & retlist, \
- const Pathname & dirname, bool dots = true ) const;
-
} // namespace media
} // namespace zypp