// local directory that corresponds to medias url
// If media is not open an empty pathname.
-const Pathname &
+Pathname
MediaAccess::localRoot() const
{
if ( !_handler )
*
* If media is not open an empty pathname is returned.
**/
- const Pathname & localRoot() const;
+ Pathname localRoot() const;
/**
* Short for 'localRoot() + pathname', but returns an empty
void
MediaHandler::setAttachPoint(const Pathname &path, bool temporary)
{
- _localRoot = Pathname();
-
_attachPoint.reset( new AttachPoint(path, temporary));
-
- if( !_attachPoint->path.empty())
- _localRoot = _attachPoint->path + _relativeRoot;
}
+Pathname
+MediaHandler::localRoot() const
+{
+ if( _attachPoint->path.empty())
+ return Pathname();
+ else
+ return _attachPoint->path + _relativeRoot;
+}
///////////////////////////////////////////////////////////////////
//
void
MediaHandler::setAttachPoint(const AttachPointRef &ref)
{
- _localRoot = Pathname();
-
if( ref)
AttachPointRef(ref).swap(_attachPoint);
else
_attachPoint.reset( new AttachPoint());
-
- if( !_attachPoint->path.empty())
- _localRoot = _attachPoint->path + _relativeRoot;
}
///////////////////////////////////////////////////////////////////
// METHOD NAME : MediaHandler::localPath
// METHOD TYPE : Pathname
//
-Pathname MediaHandler::localPath( const Pathname & pathname ) const {
+Pathname MediaHandler::localPath( const Pathname & pathname ) const
+{
+ Pathname _localRoot( localRoot());
if ( _localRoot.empty() )
return _localRoot;
if ( info.isFile() ) {
unlink( info.path() );
} else if ( info.isDir() ) {
- if ( info.path() != _localRoot ) {
+ if ( info.path() != localRoot() ) {
recursive_rmdir( info.path() );
} else {
clean_dir( info.path() );
/**
* The relative root directory of the data on the media.
- * See also _localRoot and urlpath_below_attachpoint_r
+ * See also localRoot() and urlpath_below_attachpoint_r
* constructor argument.
*/
Pathname _relativeRoot;
/**
- * The local directory that corresponds to the media url.
- * With NFS it's the '_attachPoint', as the directory on the
- * server is mounted. With CD/DVD it's 'attach point+_relativeRoot'
- * because the CDs root directory is mounted. And with CIFS
- * it's '_url.path() without the shares name'.
- **/
- Pathname _localRoot;
-
- /**
* True if concrete handler downloads files to the local
* filesystem. If true releaseFile/Dir will delete them.
**/
* Call concrete handler to provide file below attach point.
*
* Default implementation provided, that returns whether a file
- * is located at '_localRoot + filename'.
+ * is located at 'localRoot + filename'.
*
* Asserted that media is attached.
*
* directory content.
*
* Default implementation provided, that returns whether a directory
- * is located at '_localRoot + dirname'.
+ * is located at 'localRoot + dirname'.
*
* Asserted that media is attached.
*
* directory content.
*
* Default implementation provided, that returns the content of a
- * directory at '_localRoot + dirnname' retrieved via 'readdir'.
+ * directory at 'localRoot + dirnname' retrieved via 'readdir'.
*
* Asserted that media is attached and retlist is empty.
*
*
* Returns empty pathname if E_bad_attachpoint
**/
- const Pathname & localRoot() const { return _localRoot; }
+ Pathname localRoot() const;
/**
* Files provided will be available at 'localPath(filename)'.