From 6138956b5ef04c0e681001ae08cbc7a6a7002ae3 Mon Sep 17 00:00:00 2001 From: Andrey Morozov Date: Tue, 4 Oct 2011 22:00:57 +0000 Subject: [PATCH] minor fix --- modules/contrib/src/inputoutput.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/contrib/src/inputoutput.cpp b/modules/contrib/src/inputoutput.cpp index 2337c631b..aac218777 100644 --- a/modules/contrib/src/inputoutput.cpp +++ b/modules/contrib/src/inputoutput.cpp @@ -46,7 +46,7 @@ namespace cv #else DIR *dp; struct dirent *dirp; - if((dp = opendir(path_f.c_str())) == NULL) + if((dp = opendir(path.c_str())) == NULL) { return list; } @@ -54,7 +54,13 @@ namespace cv while ((dirp = readdir(dp)) != NULL) { if (dirp->d_type == DT_REG) - list.push_back(static_cast(dirp->d_name)); + { + if (exten.compare("*") == 0) + list.push_back(static_cast(dirp->d_name)); + else + if (std::string(dirp->d_name).find(exten) != std::string::npos) + list.push_back(static_cast(dirp->d_name)); + } } closedir(dp); #endif @@ -108,7 +114,11 @@ namespace cv strcmp(dirp->d_name, ".") != 0 && strcmp(dirp->d_name, "..") != 0 ) { - list.push_back(static_cast(dirp->d_name)); + if (exten.compare("*") == 0) + list.push_back(static_cast(dirp->d_name)); + else + if (std::string(dirp->d_name).find(exten) != std::string::npos) + list.push_back(static_cast(dirp->d_name)); } } closedir(dp);