31 #include <ibrcommon/ibrcommon.h>
32 #include <ibrcommon/Logger.h>
33 #ifdef IBRCOMMON_SUPPORT_SSL
34 #include <ibrcommon/ssl/MD5Stream.h>
43 const std::string ObservedFile::TAG =
"ObservedFile";
62 return _stable_counter;
65 ibrcommon::File* ObservedFile::__copy(
const ibrcommon::File &file)
72 }
catch (
const std::bad_cast&) { };
75 return new ibrcommon::File(file);
85 if (!
getFile().isDirectory())
return;
94 for (std::list<io::FATFile>::const_iterator it = filelist.begin(); it != filelist.end(); ++it)
98 if (of.
getFile().isSystem())
continue;
101 else files.insert(of);
105 IBRCOMMON_LOGGER_TAG(TAG,notice) <<
"findFiles returning " << files.size() <<
" files" << IBRCOMMON_LOGGER_ENDL;
107 }
catch (
const std::bad_cast&) { };
110 const ibrcommon::File &f =
dynamic_cast<const ibrcommon::File&
>(*_file);
112 std::list<ibrcommon::File>
filelist;
113 if (f.getFiles(filelist) == 0)
115 for (std::list<ibrcommon::File>::const_iterator it = filelist.begin(); it != filelist.end(); ++it)
119 if (of.
getFile().isSystem())
continue;
122 else files.insert(of);
125 IBRCOMMON_LOGGER_TAG(TAG,notice) <<
"findFiles returning " << files.size() <<
" files" << IBRCOMMON_LOGGER_ENDL;
132 if (_last_hash != latest) {
137 if (_stable_counter < std::numeric_limits<size_t>::max()) _stable_counter++;
153 #ifdef IBRCOMMON_SUPPORT_SSL
154 IBRCOMMON_LOGGER_TAG(TAG,notice) <<
"using MD5-algorithm from SSL, inputs:" <<
"\n"
155 <<
"\t" <<
"timestamp: " << _file->lastmodify() <<
"\n"
156 <<
"\t" <<
"filesize : " << _file->size() <<
"\n"
157 <<
"\t" <<
"filepath : " << _file->getPath() <<
"\n"
158 << IBRCOMMON_LOGGER_ENDL;
160 ibrcommon::MD5Stream md5;
161 md5 << _file->lastmodify() <<
"|" << _file->size() <<
"|" << _file->getPath() << std::flush;
163 const std::string hash = ibrcommon::HashStream::extract(md5);
165 return FileHash(_file->getPath(), hash);
167 std::stringstream ss;
168 ss << _file->lastmodify() <<
"|" << _file->size() <<
"|" << _file->getPath();
169 IBRCOMMON_LOGGER_TAG(TAG,notice) <<
"not using MD5-algorithm from SSL, inputs:" <<
"\n"
170 <<
"\t" <<
"timestamp: " << _file->lastmodify() <<
"\n"
171 <<
"\t" <<
"filesize : " << _file->size() <<
"\n"
172 <<
"\t" <<
"filepath : " << _file->getPath() <<
"\n"
173 << IBRCOMMON_LOGGER_ENDL;
174 return FileHash(_file->getPath(), ss.str());
void findFiles(std::set< ObservedFile > &files) const
size_t getStableCounter() const
int getFiles(std::list< FATFile > &files) const
std::list< io::ObservedFile > filelist
bool operator==(const ObservedFile &other) const
ObservedFile(const ibrcommon::File &file)
const io::FileHash & getHash() const
bool operator<(const ObservedFile &other) const
const ibrcommon::File & getFile() const