6ffd9faae09d2f031c0543c9821594e677b465e8
[platform/upstream/libzypp.git] / tools / cachetools / zypp-cache.cc
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
3 #include <iostream>
4
5 #include "zypp/base/Logger.h"
6 #include "zypp/ZYpp.h"
7 #include "zypp/zypp_detail/ZYppReadOnlyHack.h"
8 #include "zypp/ZYppFactory.h"
9 #include "zypp2/cache/CacheFSCK.h"
10
11 #undef ZYPP_BASE_LOGGER_LOGGROUP
12 #define ZYPP_BASE_LOGGER_LOGGROUP "zypp-cache"
13
14
15 using namespace std;
16 using namespace zypp;
17
18 static void cache_fsck( const Pathname &dir )
19 {
20   cache::CacheFSCK fsck(dir);
21   fsck.start();
22 }
23
24 void usage()
25 {
26   cout << "Commands:" << endl;
27   cout << "fsck dbdir" << endl;
28 }
29
30 //-----------------------------------------------------------------------------
31
32 int
33 main (int argc, char **argv)
34 {
35   MIL << "-------------------------------------" << endl;
36   
37   if (argc > 2)
38   {
39     if ( string(argv[1]) == "fsck" )
40     {
41       cache_fsck(argv[2]);
42     }
43     else
44     {
45       usage();
46     }
47   }
48   else
49   {
50     usage();
51   }
52
53   return 0;
54 }