MediaDIR.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00013 #include <iostream>
00014 
00015 #include "zypp/base/Logger.h"
00016 #include "zypp/media/MediaDIR.h"
00017 
00018 #include <sys/mount.h>
00019 #include <errno.h>
00020 
00021 using namespace std;
00022 
00023 namespace zypp {
00024   namespace media {
00025 
00027     //
00028     //  CLASS NAME : MediaDIR
00029     //
00031     
00033     //
00034     //
00035     //  METHOD NAME : MediaDIR::MediaDIR
00036     //  METHOD TYPE : Constructor
00037     //
00038     //  DESCRIPTION : Attach point is always url_r.getPathName(),
00039     //                as files are not copied.
00040     //                Thus attach_point_hint_r is ignored.
00041     //
00042     MediaDIR::MediaDIR( const Url &      url_r,
00043                         const Pathname & /*attach_point_hint_r*/ )
00044         : MediaHandler( url_r, url_r.getPathName(),
00045                     "/",    // urlpath below attachpoint
00046                     false ) // does_download
00047     {
00048         MIL << "MediaDIR::MediaDIR(" << url_r << ")" << endl;
00049         if( !url_r.getHost().empty())
00050         {
00051           ZYPP_THROW(MediaBadUrlException(url_r,
00052             "Hostname not allowed in the Url"
00053           ));
00054         }
00055     }
00056 
00058     //
00059     //
00060     //  METHOD NAME : MediaDIR::attachTo
00061     //  METHOD TYPE : PMError
00062     //
00063     //  DESCRIPTION : Asserted that not already attached, and attachPoint is a directory.
00064     //
00065     void MediaDIR::attachTo(bool next)
00066     {
00067       if(next)
00068         ZYPP_THROW(MediaNotSupportedException(url()));
00069 
00070       // attach point is same as source path... we do not mount here
00071       if(attachPoint().empty() || !PathInfo(attachPoint()).isDir())
00072       {
00073         ZYPP_THROW(MediaBadUrlException(url(),
00074           "Specified path '" + attachPoint().asString() + "' is not allowed as media source"
00075         ));
00076       }
00077 
00078       MediaSourceRef media(new MediaSource("dir", attachPoint().asString()));
00079       setMediaSource(media);
00080     }
00081 
00082 
00084     //
00085     //
00086     //  METHOD NAME : MediaDIR::releaseFrom
00087     //  METHOD TYPE : PMError
00088     //
00089     //  DESCRIPTION : Asserted that media is attached.
00090     //
00091     void MediaDIR::releaseFrom( bool eject )
00092     {
00093       return;
00094     }
00095 
00097     //
00098     //
00099     //  METHOD NAME : MediaDIR::getFile
00100     //  METHOD TYPE : PMError
00101     //
00102     //  DESCRIPTION : Asserted that media is attached.
00103     //
00104     void MediaDIR::getFile( const Pathname & filename ) const
00105     {
00106       MediaHandler::getFile( filename );
00107     }
00108 
00110     //
00111     //  METHOD NAME : MediaDIR::getDir
00112     //  METHOD TYPE : PMError
00113     //
00114     //  DESCRIPTION : Asserted that media is attached.
00115     //
00116     void MediaDIR::getDir( const Pathname & dirname, bool recurse_r ) const
00117     {
00118       MediaHandler::getDir( dirname, recurse_r );
00119     }
00120 
00122     //
00123     //
00124     //  METHOD NAME : MediaDIR::getDirInfo
00125     //  METHOD TYPE : PMError
00126     //
00127     //  DESCRIPTION : Asserted that media is attached and retlist is empty.
00128     //
00129     void MediaDIR::getDirInfo( std::list<std::string> & retlist,
00130                                const Pathname & dirname, bool dots ) const
00131     {
00132       MediaHandler::getDirInfo( retlist, dirname, dots );
00133     }
00134 
00136     //
00137     //
00138     //  METHOD NAME : MediaDIR::getDirInfo
00139     //  METHOD TYPE : PMError
00140     //
00141     //  DESCRIPTION : Asserted that media is attached and retlist is empty.
00142     //
00143     void MediaDIR::getDirInfo( filesystem::DirContent & retlist,
00144                                const Pathname & dirname, bool dots ) const
00145     {
00146       MediaHandler::getDirInfo( retlist, dirname, dots );
00147     }
00148 
00149   } // namespace media
00150 } // namespace zypp

Generated on Thu Jul 6 00:07:21 2006 for zypp by  doxygen 1.4.6