clean more class names
[platform/upstream/libzypp.git] / zypp2 / RepoManager.cc
1
2
3 #include <iostream>
4 #include <list>
5 #include <algorithm>
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"
11
12 #include "zypp2/RepoManager.h"
13
14
15 using namespace std;
16 using namespace zypp;
17 using namespace zypp::filesystem;
18 using parser::IniDict;
19
20 namespace zypp {
21
22 RepoManager::RepoManager()
23 {
24
25 }
26
27 static std::list<RepoInfo> repositories_in_file( const Pathname &file )
28 {
29   InputStream is(file);
30   IniDict dict(is);
31   std::list<RepoInfo> repos;
32   
33   for ( IniDict::section_const_iterator its = dict.sectionsBegin();
34         its != dict.sectionsEnd();
35         ++its )
36   {
37     MIL << (*its) << endl;
38     
39     RepoInfo info;
40     info.setAlias(*its);
41                   
42     for ( IniDict::entry_const_iterator it = dict.entriesBegin(*its);
43           it != dict.entriesEnd(*its);
44           ++it )
45     {
46       
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) );
54     }
55     
56     // add it to the list.
57   }
58   
59 //   dictionary *d = iniparser_new(file.c_str());
60 //   
61 //   if ( d == NULL )
62 //     ZYPP_THROW(Exception("Failed creating dictionary"));
63 //   
64 //   int n = iniparser_getnsec(d);
65 //   MIL << n << endl;
66 //   
67 //   for ( int i = 0; i < n; i++ )
68 //   {
69 //     MIL << iniparser_getsecname(d, i) << endl;
70 //     
71 //   }
72   return std::list<RepoInfo>();
73 }
74
75 static std::list<RepoInfo> repositories_in_path( const Pathname &dir )
76 {
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"));
81   
82   for ( list<Pathname>::const_iterator it = entries.begin(); it != entries.end(); ++it )
83   {
84     Pathname file = *it;
85     std::list<RepoInfo> repos_here = repositories_in_file(file);
86     std::copy( repos_here.begin(), repos_here.end(), std::back_inserter(repos));
87   }
88   return repos;
89 }
90
91 std::list<RepoInfo> RepoManager::knownRepositories()
92 {
93   
94
95   return std::list<RepoInfo>();
96 }
97
98 } // ns zypp
99