6 #include "zypp/base/Exception.h"
7 #include "zypp/base/InputStream.h"
8 #include "zypp/base/Logger.h"
9 #include "zypp/PathInfo.h"
10 #include "zypp/parser/IniDict.h"
12 #include "zypp2/RepoManager.h"
17 using namespace zypp::filesystem;
18 using parser::IniDict;
22 RepoManager::RepoManager()
27 static std::list<RepoInfo> repositories_in_file( const Pathname &file )
31 std::list<RepoInfo> repos;
33 for ( IniDict::section_const_iterator its = dict.sectionsBegin();
34 its != dict.sectionsEnd();
37 MIL << (*its) << endl;
42 for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
43 it != dict.entriesEnd(*its);
47 MIL << (*it).first << endl;
48 if (it->first == "name" )
49 info.setName(it-> second);
50 else if ( it->first == "enabled" )
51 info.setEnabled( it->second == "1" );
52 else if ( it->first == "baseurl" )
53 info.addBaseUrl( Url(it->second) );
56 // add it to the list.
59 // dictionary *d = iniparser_new(file.c_str());
62 // ZYPP_THROW(Exception("Failed creating dictionary"));
64 // int n = iniparser_getnsec(d);
67 // for ( int i = 0; i < n; i++ )
69 // MIL << iniparser_getsecname(d, i) << endl;
72 return std::list<RepoInfo>();
75 static std::list<RepoInfo> repositories_in_path( const Pathname &dir )
77 std::list<RepoInfo> repos;
78 list<Pathname> entries;
79 if ( filesystem::readdir( entries, Pathname(dir), false ) != 0 )
80 ZYPP_THROW(Exception("failed to read directory"));
82 for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
85 std::list<RepoInfo> repos_here = repositories_in_file(file);
86 std::copy( repos_here.begin(), repos_here.end(), std::back_inserter(repos));
91 std::list<RepoInfo> RepoManager::knownRepositories()
95 return std::list<RepoInfo>();