RepoParser.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <iostream>
00011 #include "zypp/base/Logger.h"
00012 #include "zypp/base/String.h"
00013
00014 #include "zypp/PathInfo.h"
00015
00016 #include "zypp/parser/plaindir/RepoParser.h"
00017
00018 using std::endl;
00019
00021 namespace zypp
00022 {
00023
00024 namespace parser
00025 {
00026
00027 namespace plaindir
00028 {
00029
00030 static void recursive_timestamp( const Pathname &dir, time_t & max )
00031 {
00032 std::list<std::string> dircontent;
00033 if ( filesystem::readdir( dircontent, dir, false ) != 0 )
00034 return;
00035
00036 for_( it, dircontent.begin(), dircontent.end() )
00037 {
00038 PathInfo pi( dir + *it, PathInfo::LSTAT );
00039 if ( pi.isDir() )
00040 {
00041 recursive_timestamp( pi.path(), max );
00042 if ( pi.mtime() > max )
00043 max = pi.mtime();
00044 }
00045 }
00046 }
00047
00048 RepoStatus dirStatus( const Pathname &dir )
00049 {
00050 time_t t = 0;
00051 PathInfo pi(dir);
00052 if ( pi.isDir() )
00053 {
00054 t = pi.mtime();
00055 recursive_timestamp(dir,t);
00056 }
00057 RepoStatus status;
00058 status.setTimestamp(Date(t));
00059 status.setChecksum(str::numstring(t));
00060 return status;
00061 }
00062
00064 }
00067 }
00070 }