MediaDIR.cc
Go to the documentation of this file.00001
00002
00003
00004
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
00029
00031
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 MediaDIR::MediaDIR( const Url & url_r,
00043 const Pathname & )
00044 : MediaHandler( url_r, url_r.getPathName(),
00045 "/",
00046 false )
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
00061
00062
00063
00064
00065 void MediaDIR::attachTo(bool next)
00066 {
00067 if(next)
00068 ZYPP_THROW(MediaNotSupportedException(url()));
00069
00070
00071
00072
00073
00074 if( attachPoint().empty() && !url().getPathName().empty())
00075 {
00076 Pathname real( getRealPath(url().getPathName()));
00077
00078 PathInfo adir( real);
00079 if( adir.isDir())
00080 {
00081
00082 setAttachPoint( real, false);
00083 }
00084 else
00085 {
00086 ZYPP_THROW(MediaBadUrlException(url(),
00087 "Specified path '" + url().getPathName() + "' is not a directory"
00088 ));
00089 }
00090 }
00091
00092
00093 if(attachPoint().empty())
00094 {
00095 ZYPP_THROW(MediaBadUrlException(url(),
00096 "The media URL does not provide any useable directory path"
00097 ));
00098 }
00099 else
00100 if(!PathInfo(attachPoint()).isDir())
00101 {
00102 ZYPP_THROW(MediaBadUrlException(url(),
00103 "Specified path '" + attachPoint().asString() + "' is not a directory"
00104 ));
00105 }
00106
00107 MediaSourceRef media(new MediaSource("dir", attachPoint().asString()));
00108 setMediaSource(media);
00109 }
00110
00111
00113
00114
00115
00116
00117
00118
00119
00120 void MediaDIR::releaseFrom( const std::string & ejectDev )
00121 {
00122 return;
00123 }
00124
00126
00127
00128
00129
00130
00131
00132
00133 void MediaDIR::getFile( const Pathname & filename ) const
00134 {
00135 MediaHandler::getFile( filename );
00136 }
00137
00139
00140
00141
00142
00143
00144
00145 void MediaDIR::getDir( const Pathname & dirname, bool recurse_r ) const
00146 {
00147 MediaHandler::getDir( dirname, recurse_r );
00148 }
00149
00151
00152
00153
00154
00155
00156
00157
00158 void MediaDIR::getDirInfo( std::list<std::string> & retlist,
00159 const Pathname & dirname, bool dots ) const
00160 {
00161 MediaHandler::getDirInfo( retlist, dirname, dots );
00162 }
00163
00165
00166
00167
00168
00169
00170
00171
00172 void MediaDIR::getDirInfo( filesystem::DirContent & retlist,
00173 const Pathname & dirname, bool dots ) const
00174 {
00175 MediaHandler::getDirInfo( retlist, dirname, dots );
00176 }
00177
00178 bool MediaDIR::getDoesFileExist( const Pathname & filename ) const
00179 {
00180 return MediaHandler::getDoesFileExist( filename );
00181 }
00182
00183 }
00184 }