1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
11 #include "zypp/base/Logger.h"
12 #include "zypp/base/Gettext.h"
13 #include "zypp/base/String.h"
14 #include "zypp/base/InputStream.h"
15 #include "zypp/base/UserRequestException.h"
17 #include "zypp/repo/PluginServices.h"
18 #include "zypp/ServiceInfo.h"
19 #include "zypp/RepoInfo.h"
20 #include "zypp/PathInfo.h"
23 using std::stringstream;
25 ///////////////////////////////////////////////////////////////////
27 { /////////////////////////////////////////////////////////////////
28 ///////////////////////////////////////////////////////////////////
30 { /////////////////////////////////////////////////////////////////
32 class PluginServices::Impl
35 static void loadServices( const Pathname &path,
36 const PluginServices::ProcessService &callback );
39 void PluginServices::Impl::loadServices( const Pathname &path,
40 const PluginServices::ProcessService & callback/*,
41 const ProgressData::ReceiverFnc &progress*/ )
43 std::list<Pathname> entries;
44 if (PathInfo(path).isExist())
46 if ( filesystem::readdir( entries, path, false ) != 0 )
48 // TranslatorExplanation '%s' is a pathname
49 ZYPP_THROW(Exception(str::form(_("Failed to read directory '%s'"), path.c_str())));
52 //str::regex allowedServiceExt("^\\.service(_[0-9]+)?$");
53 for_(it, entries.begin(), entries.end() )
55 ServiceInfo service_info;
56 service_info.setAlias((*it).basename());
58 url.setPathName((*it).asString());
59 url.setScheme("file");
60 service_info.setUrl(url);
61 service_info.setType(ServiceType::PLUGIN);
62 callback(service_info);
68 PluginServices::PluginServices( const Pathname &path,
69 const ProcessService & callback/*,
70 const ProgressData::ReceiverFnc &progress */)
72 Impl::loadServices(path, callback/*, progress*/);
75 PluginServices::~PluginServices()
78 std::ostream & operator<<( std::ostream & str, const PluginServices & obj )
83 /////////////////////////////////////////////////////////////////
85 ///////////////////////////////////////////////////////////////////
86 /////////////////////////////////////////////////////////////////
88 ///////////////////////////////////////////////////////////////////