1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/media/MediaHandler.cc
17 #include "zypp/base/Logger.h"
18 #include "zypp/base/String.h"
19 #include "zypp/media/MediaHandler.h"
20 #include "zypp/media/MediaManager.h"
21 #include "zypp/media/Mount.h"
25 // use directory.yast on every media (not just via ftp/http)
26 #define NONREMOTE_DIRECTORY_YAST 1
31 Pathname MediaHandler::_attachPrefix("");
33 ///////////////////////////////////////////////////////////////////
35 // CLASS NAME : MediaHandler
37 ///////////////////////////////////////////////////////////////////
39 ///////////////////////////////////////////////////////////////////
42 // METHOD NAME : MediaHandler::MediaHandler
43 // METHOD TYPE : Constructor
47 MediaHandler::MediaHandler ( const Url & url_r,
48 const Pathname & attach_point_r,
49 const Pathname & urlpath_below_attachpoint_r,
50 const bool does_download_r )
52 , _attachPoint( new AttachPoint())
54 , _relativeRoot( urlpath_below_attachpoint_r)
55 , _does_download( does_download_r )
60 if ( !attach_point_r.empty() ) {
61 ///////////////////////////////////////////////////////////////////
62 // check if provided attachpoint is usable.
63 ///////////////////////////////////////////////////////////////////
65 PathInfo adir( attach_point_r );
66 // FIXME: verify if attach_point_r isn't a mountpoint of other device
67 if ( !adir.isDir() || !attach_point_r.absolute()) {
68 ERR << "Provided attach point is not a absolute directory: "
72 attachPointHint( attach_point_r, false);
73 setAttachPoint( attach_point_r, false);
78 ///////////////////////////////////////////////////////////////////
81 // METHOD NAME : MediaHandler::~MediaHandler
82 // METHOD TYPE : Destructor
86 MediaHandler::~MediaHandler()
96 MediaHandler::resetParentId()
101 ///////////////////////////////////////////////////////////////////
104 // METHOD NAME : MediaHandler::removeAttachPoint
105 // METHOD TYPE : void
110 MediaHandler::removeAttachPoint()
112 if ( _mediaSource ) {
113 INT << "MediaHandler deleted with media attached." << endl;
114 return; // no cleanup if media still mounted!
117 DBG << "MediaHandler - checking if to remove attach point" << endl;
118 if ( _attachPoint.unique() &&
119 _attachPoint->temp &&
120 !_attachPoint->path.empty() &&
121 PathInfo(_attachPoint->path).isDir())
123 Pathname path(_attachPoint->path);
125 setAttachPoint("", true);
127 int res = recursive_rmdir( path );
129 MIL << "Deleted default attach point " << path << endl;
131 ERR << "Failed to Delete default attach point " << path
132 << " errno(" << res << ")" << endl;
137 if( !_attachPoint->temp)
138 DBG << "MediaHandler - attachpoint is not temporary" << endl;
143 ///////////////////////////////////////////////////////////////////
146 // METHOD NAME : MediaHandler::attachPoint
147 // METHOD TYPE : Pathname
152 MediaHandler::attachPoint() const
154 return _attachPoint->path;
158 ///////////////////////////////////////////////////////////////////
161 // METHOD NAME : MediaHandler::attachPoint
167 MediaHandler::setAttachPoint(const Pathname &path, bool temporary)
169 _attachPoint.reset( new AttachPoint(path, temporary));
173 MediaHandler::localRoot() const
175 if( _attachPoint->path.empty())
178 return _attachPoint->path + _relativeRoot;
181 ///////////////////////////////////////////////////////////////////
184 // METHOD NAME : MediaHandler::attachPoint
190 MediaHandler::setAttachPoint(const AttachPointRef &ref)
193 AttachPointRef(ref).swap(_attachPoint);
195 _attachPoint.reset( new AttachPoint());
198 ///////////////////////////////////////////////////////////////////
201 // METHOD NAME : MediaHandler::attachPointHint
202 // METHOD TYPE : void
207 MediaHandler::attachPointHint(const Pathname &path, bool temporary)
209 _AttachPointHint.path = path;
210 _AttachPointHint.temp = temporary;
213 ///////////////////////////////////////////////////////////////////
216 // METHOD NAME : MediaHandler::attachPointHint
217 // METHOD TYPE : AttachPoint
222 MediaHandler::attachPointHint() const
224 return _AttachPointHint;
227 ///////////////////////////////////////////////////////////////////
230 // METHOD NAME : MediaHandler::findAttachedMedia
231 // METHOD TYPE : AttachedMedia
236 MediaHandler::findAttachedMedia(const MediaSourceRef &media) const
238 return MediaManager().findAttachedMedia(media);
241 ///////////////////////////////////////////////////////////////////
244 // METHOD NAME : MediaHandler::setAttachPrefix
245 // METHOD TYPE : void
250 MediaHandler::setAttachPrefix(const Pathname &attach_prefix)
252 if( attach_prefix.empty())
254 MIL << "Reseting to built-in attach point prefixes."
256 MediaHandler::_attachPrefix = attach_prefix;
260 if( MediaHandler::checkAttachPoint(attach_prefix, false, true))
262 MIL << "Setting user defined attach point prefix: "
263 << attach_prefix << std::endl;
264 MediaHandler::_attachPrefix = attach_prefix;
270 ///////////////////////////////////////////////////////////////////
273 // METHOD NAME : MediaHandler::attach
274 // METHOD TYPE : Pathname
279 MediaHandler::createAttachPoint() const
281 /////////////////////////////////////////////////////////////////
282 // provide a default (temporary) attachpoint
283 /////////////////////////////////////////////////////////////////
284 const char * defmounts[] = {
285 "/var/adm/mount", "/var/tmp", /**/NULL/**/
289 Pathname aroot( MediaHandler::_attachPrefix);
293 apoint = createAttachPoint(aroot);
295 for ( const char ** def = defmounts; *def && apoint.empty(); ++def ) {
300 apoint = createAttachPoint(aroot);
303 if ( aroot.empty() ) {
304 ERR << "Create attach point: Can't find a writable directory to create an attach point" << std::endl;
308 if ( !apoint.empty() ) {
309 MIL << "Created default attach point " << apoint << std::endl;
315 MediaHandler::createAttachPoint(const Pathname &attach_root) const
319 if( attach_root.empty() || !attach_root.absolute()) {
320 ERR << "Create attach point: invalid attach root: '"
321 << attach_root << "'" << std::endl;
325 PathInfo adir( attach_root);
326 if( !adir.isDir() || !adir.userMayRWX()) {
327 DBG << "Create attach point: attach root is not a writable directory: '"
328 << attach_root << "'" << std::endl;
332 DBG << "Trying to create attach point in " << attach_root << std::endl;
335 // FIXME: use mkdtemp?
337 Pathname abase( attach_root + "AP_" );
338 // ma and sh need more than 42 for debugging :-)
339 // since the readonly fs are handled now, ...
340 for ( unsigned i = 1; i < 1000; ++i ) {
341 adir( Pathname::extend( abase, str::hexstring( i ) ) );
342 if ( ! adir.isExist() ) {
343 int err = mkdir( adir.path() );
345 apoint = adir.path();
349 if (err != EEXIST) // readonly fs or other, dont try further
354 if ( apoint.empty()) {
355 ERR << "Unable to create an attach point below of "
356 << attach_root << std::endl;
361 ///////////////////////////////////////////////////////////////////
364 // METHOD NAME : MediaHandler::isUseableAttachPoint
365 // METHOD TYPE : bool
370 MediaHandler::isUseableAttachPoint(const Pathname &path) const
372 MediaManager manager;
373 return manager.isUseableAttachPoint(path);
377 ///////////////////////////////////////////////////////////////////
380 // METHOD NAME : MediaHandler::setMediaSource
381 // METHOD TYPE : void
386 MediaHandler::setMediaSource(const MediaSourceRef &ref)
388 _mediaSource.reset();
389 if( ref && !ref->type.empty() && !ref->name.empty())
393 ///////////////////////////////////////////////////////////////////
396 // METHOD NAME : MediaHandler::attachedMedia
397 // METHOD TYPE : AttachedMedia
402 MediaHandler::attachedMedia() const
404 if ( _mediaSource && _attachPoint)
405 return AttachedMedia(_mediaSource, _attachPoint);
407 return AttachedMedia();
410 ///////////////////////////////////////////////////////////////////
413 // METHOD NAME : MediaHandler::isSharedMedia
414 // METHOD TYPE : bool
419 MediaHandler::isSharedMedia() const
421 return !_mediaSource.unique();
424 ///////////////////////////////////////////////////////////////////
427 // METHOD NAME : MediaHandler::checkAttached
428 // METHOD TYPE : bool
433 MediaHandler::checkAttached(bool matchMountFs) const
435 bool _isAttached = false;
437 AttachedMedia ref( attachedMedia());
440 time_t old_mtime = _attach_mtime;
441 _attach_mtime = MediaManager::getMountTableMTime();
442 if( !(old_mtime <= 0 || _attach_mtime != old_mtime))
444 // OK, skip the check (we've seen it at least once)
450 DBG << "Mount table changed - rereading it" << std::endl;
452 DBG << "Forced check of the mount table" << std::endl;
454 MountEntries entries( MediaManager::getMountEntries());
455 MountEntries::const_iterator e;
456 for( e = entries.begin(); e != entries.end(); ++e)
458 bool is_device = false;
459 std::string dev_path(Pathname(e->src).asString());
462 if( dev_path.compare(0, sizeof("/dev/")-1, "/dev/") == 0 &&
463 dev_info(e->src) && dev_info.isBlk())
468 if( is_device && ref.mediaSource->maj_nr)
470 std::string mtype(matchMountFs ? e->type : ref.mediaSource->type);
471 MediaSource media(mtype, e->src, dev_info.major(), dev_info.minor());
473 if( ref.mediaSource->equals( media) &&
474 ref.attachPoint->path == Pathname(e->dir))
476 DBG << "Found media device "
477 << ref.mediaSource->asString()
478 << " in the mount table as " << e->src << std::endl;
485 if(!is_device && !ref.mediaSource->maj_nr)
487 std::string mtype(matchMountFs ? e->type : ref.mediaSource->type);
488 MediaSource media(mtype, e->src);
490 if( ref.mediaSource->equals( media) &&
491 ref.attachPoint->path == Pathname(e->dir))
493 DBG << "Found media name "
494 << ref.mediaSource->asString()
495 << " in the mount table as " << e->src << std::endl;
507 ERR << "Attached media not in mount table any more - forcing reset!"
510 _mediaSource.reset();
514 WAR << "Attached media not in mount table ..." << std::endl;
517 // reset the mtime and force a new check to make sure,
518 // that we've found the media at least once in the mtab.
526 ///////////////////////////////////////////////////////////////////
529 // METHOD NAME : MediaHandler::attach
530 // METHOD TYPE : PMError
534 void MediaHandler::attach( bool next )
539 // reset it in case of overloaded isAttached()
540 // that checks the media against /etc/mtab ...
541 setMediaSource(MediaSourceRef());
543 AttachPoint ap( attachPointHint());
544 setAttachPoint(ap.path, ap.temp);
548 attachTo( next ); // pass to concrete handler
550 catch(const MediaException &e)
555 MIL << "Attached: " << *this << endl;
559 ///////////////////////////////////////////////////////////////////
562 // METHOD NAME : MediaHandler::localPath
563 // METHOD TYPE : Pathname
565 Pathname MediaHandler::localPath( const Pathname & pathname ) const
567 Pathname _localRoot( localRoot());
568 if ( _localRoot.empty() )
571 // we must check maximum file name length
572 // this is important for fetching the suseservers, the
573 // url with all parameters can get too long (bug #42021)
575 return _localRoot + pathname.absolutename();
582 ///////////////////////////////////////////////////////////////////
585 // METHOD NAME : MediaHandler::disconnect
586 // METHOD TYPE : PMError
588 void MediaHandler::disconnect()
593 disconnectFrom(); // pass to concrete handler
594 MIL << "Disconnected: " << *this << endl;
597 ///////////////////////////////////////////////////////////////////
600 // METHOD NAME : MediaHandler::release
601 // METHOD TYPE : PMError
605 void MediaHandler::release( bool eject )
607 if ( !isAttached() ) {
608 DBG << "Request to release media - not attached; eject " << eject << std::endl;
614 DBG << "Request to release attached media "
615 << _mediaSource->asString()
616 << ", use count=" << _mediaSource.use_count()
619 if( _mediaSource.unique())
621 DBG << "Releasing media " << _mediaSource->asString() << std::endl;
622 releaseFrom( eject ); // pass to concrete handler
623 _mediaSource.reset(NULL);
628 // Can't eject a shared media
630 //ZYPP_THROW(MediaIsSharedException(_mediaSource->asString()));
632 MediaSourceRef media( new MediaSource(*_mediaSource));
633 _mediaSource.reset(NULL);
635 MediaManager manager;
636 manager.forceReleaseShared(media);
638 setMediaSource(media);
639 DBG << "Releasing media (forced) " << _mediaSource->asString() << std::endl;
640 releaseFrom( eject ); // pass to concrete handler
641 _mediaSource.reset(NULL);
645 DBG << "Releasing shared media reference only" << std::endl;
646 _mediaSource.reset(NULL);
647 setAttachPoint("", true);
649 MIL << "Released: " << *this << endl;
652 void MediaHandler::forceRelaseAllMedia(bool matchMountFs)
654 forceRelaseAllMedia( attachedMedia().mediaSource, matchMountFs);
657 void MediaHandler::forceRelaseAllMedia(const MediaSourceRef &ref,
663 MountEntries entries( MediaManager::getMountEntries());
664 MountEntries::const_iterator e;
665 for( e = entries.begin(); e != entries.end(); ++e)
667 bool is_device = false;
668 std::string dev_path(Pathname(e->src).asString());
671 if( dev_path.compare(0, sizeof("/dev/")-1, "/dev/") == 0 &&
672 dev_info(e->src) && dev_info.isBlk())
677 if( is_device && ref->maj_nr)
679 std::string mtype(matchMountFs ? e->type : ref->type);
680 MediaSource media(mtype, e->src, dev_info.major(), dev_info.minor());
682 if( ref->equals( media) && e->type != "subfs")
684 DBG << "Forcing release of media device "
686 << " in the mount table as "
687 << e->src << std::endl;
690 mount.umount(e->dir);
692 catch (const Exception &e)
699 if(!is_device && !ref->maj_nr)
701 std::string mtype(matchMountFs ? e->type : ref->type);
702 MediaSource media(mtype, e->src);
703 if( ref->equals( media) && e->type != "subfs")
705 DBG << "Forcing release of media name "
707 << " in the mount table as "
708 << e->src << std::endl;
711 mount.umount(e->dir);
713 catch (const Exception &e)
723 MediaHandler::checkAttachPoint(const Pathname &apoint) const
725 return MediaHandler::checkAttachPoint( apoint, true, false);
730 MediaHandler::checkAttachPoint(const Pathname &apoint,
734 if( apoint.empty() || !apoint.absolute())
736 ERR << "Attach point '" << apoint << "' is not absolute"
742 ERR << "Attach point '" << apoint << "' is not allowed"
747 PathInfo ainfo(apoint);
750 ERR << "Attach point '" << apoint << "' is not a directory"
757 if( 0 != zypp::filesystem::is_empty_dir(apoint))
759 ERR << "Attach point '" << apoint << "' is not a empty directory"
767 Pathname apath(apoint + "XXXXXX");
768 char *atemp = ::strdup( apath.asString().c_str());
770 if( !ainfo.userMayRWX() || atemp == NULL ||
771 (atest=::mkdtemp(atemp)) == NULL)
776 ERR << "Attach point '" << ainfo.path()
777 << "' is not a writeable directory" << std::endl;
780 else if( atest != NULL)
789 ///////////////////////////////////////////////////////////////////
791 // METHOD NAME : MediaHandler::dependsOnParent
792 // METHOD TYPE : bool
797 MediaHandler::dependsOnParent()
799 return _parentId != 0;
803 MediaHandler::dependsOnParent(MediaAccessId parentId, bool exactIdMatch)
807 if(parentId == _parentId)
813 AttachedMedia am1 = mm.getAttachedMedia(_parentId);
814 AttachedMedia am2 = mm.getAttachedMedia(parentId);
815 if( am1.mediaSource && am2.mediaSource)
817 return am1.mediaSource->equals( *(am2.mediaSource));
824 ///////////////////////////////////////////////////////////////////
827 // METHOD NAME : MediaHandler::provideFile
828 // METHOD TYPE : PMError
832 void MediaHandler::provideFileCopy( Pathname srcFilename,
833 Pathname targetFilename ) const
835 if ( !isAttached() ) {
836 INT << "Media not_attached on provideFileCopy(" << srcFilename
837 << "," << targetFilename << ")" << endl;
838 ZYPP_THROW(MediaNotAttachedException(url()));
841 getFileCopy( srcFilename, targetFilename ); // pass to concrete handler
842 DBG << "provideFileCopy(" << srcFilename << "," << targetFilename << ")" << endl;
845 void MediaHandler::provideFile( Pathname filename ) const
847 if ( !isAttached() ) {
848 INT << "Error: Not attached on provideFile(" << filename << ")" << endl;
849 ZYPP_THROW(MediaNotAttachedException(url()));
852 getFile( filename ); // pass to concrete handler
853 DBG << "provideFile(" << filename << ")" << endl;
857 ///////////////////////////////////////////////////////////////////
860 // METHOD NAME : MediaHandler::provideDir
861 // METHOD TYPE : PMError
865 void MediaHandler::provideDir( Pathname dirname ) const
867 if ( !isAttached() ) {
868 INT << "Error: Not attached on provideDir(" << dirname << ")" << endl;
869 ZYPP_THROW(MediaNotAttachedException(url()));
872 getDir( dirname, /*recursive*/false ); // pass to concrete handler
873 MIL << "provideDir(" << dirname << ")" << endl;
876 ///////////////////////////////////////////////////////////////////
879 // METHOD NAME : MediaHandler::provideDirTree
880 // METHOD TYPE : PMError
884 void MediaHandler::provideDirTree( Pathname dirname ) const
886 if ( !isAttached() ) {
887 INT << "Error Not attached on provideDirTree(" << dirname << ")" << endl;
888 ZYPP_THROW(MediaNotAttachedException(url()));
891 getDir( dirname, /*recursive*/true ); // pass to concrete handler
892 MIL << "provideDirTree(" << dirname << ")" << endl;
895 ///////////////////////////////////////////////////////////////////
898 // METHOD NAME : MediaHandler::releasePath
899 // METHOD TYPE : PMError
903 void MediaHandler::releasePath( Pathname pathname ) const
905 if ( ! _does_download || _attachPoint->empty() )
908 PathInfo info( localPath( pathname ) );
910 if ( info.isFile() ) {
911 unlink( info.path() );
912 } else if ( info.isDir() ) {
913 if ( info.path() != localRoot() ) {
914 recursive_rmdir( info.path() );
916 clean_dir( info.path() );
921 ///////////////////////////////////////////////////////////////////
924 // METHOD NAME : MediaHandler::dirInfo
925 // METHOD TYPE : PMError
929 void MediaHandler::dirInfo( list<string> & retlist,
930 const Pathname & dirname, bool dots ) const
934 if ( !isAttached() ) {
935 INT << "Error: Not attached on dirInfo(" << dirname << ")" << endl;
936 ZYPP_THROW(MediaNotAttachedException(url()));
939 getDirInfo( retlist, dirname, dots ); // pass to concrete handler
940 MIL << "dirInfo(" << dirname << ")" << endl;
943 ///////////////////////////////////////////////////////////////////
946 // METHOD NAME : MediaHandler::dirInfo
947 // METHOD TYPE : PMError
951 void MediaHandler::dirInfo( filesystem::DirContent & retlist,
952 const Pathname & dirname, bool dots ) const
956 if ( !isAttached() ) {
957 INT << "Error: Not attached on dirInfo(" << dirname << ")" << endl;
958 ZYPP_THROW(MediaNotAttachedException(url()));
961 getDirInfo( retlist, dirname, dots ); // pass to concrete handler
962 MIL << "dirInfo(" << dirname << ")" << endl;
965 ///////////////////////////////////////////////////////////////////
968 // METHOD NAME : MediaHandler::getDirectoryYast
969 // METHOD TYPE : PMError
971 void MediaHandler::getDirectoryYast( std::list<std::string> & retlist,
972 const Pathname & dirname, bool dots ) const
976 filesystem::DirContent content;
977 getDirectoryYast( content, dirname, dots );
979 // convert to std::list<std::string>
980 for ( filesystem::DirContent::const_iterator it = content.begin(); it != content.end(); ++it ) {
981 retlist.push_back( it->name );
985 ///////////////////////////////////////////////////////////////////
988 // METHOD NAME : MediaHandler::getDirectoryYast
989 // METHOD TYPE : PMError
991 void MediaHandler::getDirectoryYast( filesystem::DirContent & retlist,
992 const Pathname & dirname, bool dots ) const
996 // look for directory.yast
997 Pathname dirFile = dirname + "directory.yast";
999 DBG << "provideFile(" << dirFile << "): " << "OK" << endl;
1001 // using directory.yast
1002 ifstream dir( localPath( dirFile ).asString().c_str() );
1004 ERR << "Unable to load '" << localPath( dirFile ) << "'" << endl;
1005 ZYPP_THROW(MediaSystemException(url(),
1006 "Unable to load '" + localPath( dirFile ).asString() + "'"));
1010 while( getline( dir, line ) ) {
1011 if ( line.empty() ) continue;
1012 if ( line == "directory.yast" ) continue;
1014 // Newer directory.yast append '/' to directory names
1015 // Remaining entries are unspecified, although most probabely files.
1016 filesystem::FileType type = filesystem::FT_NOT_AVAIL;
1017 if ( *line.rbegin() == '/' ) {
1018 line.erase( line.end()-1 );
1019 type = filesystem::FT_DIR;
1023 if ( line == "." || line == ".." ) continue;
1025 if ( *line.begin() == '.' ) continue;
1028 retlist.push_back( filesystem::DirEntry( line, type ) );
1032 /******************************************************************
1035 ** FUNCTION NAME : operator<<
1036 ** FUNCTION TYPE : ostream &
1038 ostream & operator<<( ostream & str, const MediaHandler & obj )
1040 str << obj.url() << ( obj.isAttached() ? "" : " not" )
1041 << " attached; localRoot \"" << obj.localRoot() << "\"";
1045 ///////////////////////////////////////////////////////////////////
1048 // METHOD NAME : MediaHandler::getFile
1049 // METHOD TYPE : PMError
1051 // DESCRIPTION : Asserted that media is attached.
1052 // Default implementation of pure virtual.
1054 void MediaHandler::getFile( const Pathname & filename ) const
1056 PathInfo info( localPath( filename ) );
1057 if( info.isFile() ) {
1062 ZYPP_THROW(MediaNotAFileException(url(), localPath(filename)));
1064 ZYPP_THROW(MediaFileNotFoundException(url(), filename));
1068 void MediaHandler::getFileCopy ( const Pathname & srcFilename, const Pathname & targetFilename ) const
1070 getFile(srcFilename);
1072 if ( copy( localPath( srcFilename ), targetFilename ) != 0 ) {
1073 ZYPP_THROW(MediaWriteException(targetFilename));
1079 ///////////////////////////////////////////////////////////////////
1082 // METHOD NAME : MediaHandler::getDir
1083 // METHOD TYPE : PMError
1085 // DESCRIPTION : Asserted that media is attached.
1086 // Default implementation of pure virtual.
1088 void MediaHandler::getDir( const Pathname & dirname, bool recurse_r ) const
1090 PathInfo info( localPath( dirname ) );
1091 if( info.isDir() ) {
1096 ZYPP_THROW(MediaNotADirException(url(), localPath(dirname)));
1098 ZYPP_THROW(MediaFileNotFoundException(url(), dirname));
1101 ///////////////////////////////////////////////////////////////////
1104 // METHOD NAME : MediaHandler::getDirInfo
1105 // METHOD TYPE : PMError
1107 // DESCRIPTION : Asserted that media is attached and retlist is empty.
1108 // Default implementation of pure virtual.
1110 void MediaHandler::getDirInfo( std::list<std::string> & retlist,
1111 const Pathname & dirname, bool dots ) const
1113 PathInfo info( localPath( dirname ) );
1114 if( ! info.isDir() ) {
1115 ZYPP_THROW(MediaNotADirException(url(), localPath(dirname)));
1118 #if NONREMOTE_DIRECTORY_YAST
1119 // use directory.yast if available
1121 getDirectoryYast( retlist, dirname, dots );
1123 catch (const MediaException & excpt_r)
1128 int res = readdir( retlist, info.path(), dots );
1130 ZYPP_THROW(MediaSystemException(url(), "readdir failed"));
1132 #if NONREMOTE_DIRECTORY_YAST
1139 ///////////////////////////////////////////////////////////////////
1142 // METHOD NAME : MediaHandler::getDirInfo
1143 // METHOD TYPE : PMError
1145 // DESCRIPTION : Asserted that media is attached and retlist is empty.
1146 // Default implementation of pure virtual.
1148 void MediaHandler::getDirInfo( filesystem::DirContent & retlist,
1149 const Pathname & dirname, bool dots ) const
1151 PathInfo info( localPath( dirname ) );
1152 if( ! info.isDir() ) {
1153 ZYPP_THROW(MediaNotADirException(url(), localPath(dirname)));
1156 #if NONREMOTE_DIRECTORY_YAST
1157 // use directory.yast if available
1159 getDirectoryYast( retlist, dirname, dots );
1161 catch (const MediaException & excpt_r)
1166 int res = readdir( retlist, info.path(), dots );
1168 ZYPP_THROW(MediaSystemException(url(), "readdir failed"));
1169 #if NONREMOTE_DIRECTORY_YAST
1174 } // namespace media
1176 // vim: set ts=8 sts=2 sw=2 ai noet: