|
|
|
|
@ -92,23 +92,56 @@ std::vector<std::string> get_search_paths(const std::string& strFileName, int nB
|
|
|
|
|
return vs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string cvt_filename_to_datetime(const std::string& strFileName)
|
|
|
|
|
std::vector<std::string> cvt_filename_to_datetime(const std::string& strFileName, int nBeginTime, int nEndTime)
|
|
|
|
|
{
|
|
|
|
|
std::string str;
|
|
|
|
|
if (strFileName.empty())
|
|
|
|
|
std::vector<std::string> vs;
|
|
|
|
|
if (strFileName.empty() || nBeginTime > nEndTime)
|
|
|
|
|
{
|
|
|
|
|
return str;
|
|
|
|
|
return vs;
|
|
|
|
|
}
|
|
|
|
|
std::string strDate = strFileName.substr(0,13);
|
|
|
|
|
int date[6] = {0};
|
|
|
|
|
sscanf(strDate.c_str(),"%02d%02d%02d_%02d%02d%02d",&date[0],&date[1],&date[2],&date[3],&date[4],&date[5]);
|
|
|
|
|
char szText[255];
|
|
|
|
|
snprintf(szText, sizeof (szText), "%d%02d%02d_%02d%02d%02d_",
|
|
|
|
|
date[0] + 2000, date[1], date[2], date[3], date[4], date[5]);
|
|
|
|
|
str = szText;
|
|
|
|
|
return str;
|
|
|
|
|
struct tm input_time = {0};
|
|
|
|
|
input_time.tm_year = date[0] + 2000 - 1900;
|
|
|
|
|
input_time.tm_mon = date[1] - 1;
|
|
|
|
|
input_time.tm_mday = date[2];
|
|
|
|
|
input_time.tm_hour = date[3];
|
|
|
|
|
input_time.tm_min = date[4];
|
|
|
|
|
input_time.tm_sec = date[5];
|
|
|
|
|
time_t tt[3] = {0};
|
|
|
|
|
tt[0] = mktime(&input_time);
|
|
|
|
|
tt[1] = tt[0] + nBeginTime;
|
|
|
|
|
tt[2] = tt[0] + nEndTime;
|
|
|
|
|
tm* tm_begin = localtime(&tt[1]);
|
|
|
|
|
char szBegin[255];
|
|
|
|
|
snprintf(szBegin, sizeof(szBegin),"%d%02d%02d_%02d%02d%02d",
|
|
|
|
|
tm_begin->tm_year + 1900, tm_begin->tm_mon + 1, tm_begin->tm_mday, tm_begin->tm_hour, tm_begin->tm_min, tm_begin->tm_sec);
|
|
|
|
|
tm* tm_end = localtime(&tt[2]);
|
|
|
|
|
char szEnd[255];
|
|
|
|
|
snprintf(szEnd, sizeof(szEnd),"%d%02d%02d_%02d%02d%02d",
|
|
|
|
|
tm_end->tm_year + 1900, tm_end->tm_mon + 1, tm_end->tm_mday, tm_end->tm_hour, tm_end->tm_min, tm_end->tm_sec);
|
|
|
|
|
vs.push_back(szBegin);
|
|
|
|
|
vs.push_back(szEnd);
|
|
|
|
|
return vs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string get_file_timestamp_str(const std::string& strPath)
|
|
|
|
|
{
|
|
|
|
|
std::string str;
|
|
|
|
|
if (strPath.empty())
|
|
|
|
|
{
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
fs::path path(strPath);
|
|
|
|
|
if (!fs::exists(path))
|
|
|
|
|
{
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
str = path.filename().string();
|
|
|
|
|
str = str.substr(0, 15);
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
|
int nParam[2] = {0};
|
|
|
|
|
@ -143,14 +176,19 @@ int main(int argc, char* argv[]) {
|
|
|
|
|
for (auto it:vec_file_name)
|
|
|
|
|
{
|
|
|
|
|
++j;
|
|
|
|
|
auto datetime = cvt_filename_to_datetime(it);
|
|
|
|
|
auto vec_datetime = cvt_filename_to_datetime(it, nParam[0], nParam[1]);
|
|
|
|
|
if (vec_datetime.empty())
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
auto vec_search_path = get_search_paths(it, nParam[0], nParam[1]);
|
|
|
|
|
for (auto dir:vec_search_path)
|
|
|
|
|
{
|
|
|
|
|
auto vec_file_path = get_file_paths(dir);
|
|
|
|
|
for (auto path:vec_file_path)
|
|
|
|
|
{
|
|
|
|
|
if (path.find(datetime) != std::string::npos)
|
|
|
|
|
auto strTime = get_file_timestamp_str(path);
|
|
|
|
|
if (strTime >= vec_datetime.front() && strTime <= vec_datetime.back())
|
|
|
|
|
{
|
|
|
|
|
vec_matched_path.push_back(path);
|
|
|
|
|
}
|
|
|
|
|
|