From 97e24c31f2528e7b3fdc63eabf61eb00e420c67a Mon Sep 17 00:00:00 2001 From: Jamie Allen Date: Mon, 9 Apr 2012 13:42:40 +0200 Subject: [PATCH] added file name sorting code to abrastract analysis --- src/AbstractAnalysis.cpp | 41 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/src/AbstractAnalysis.cpp b/src/AbstractAnalysis.cpp index 8ceb2c6..1dab2d2 100644 --- a/src/AbstractAnalysis.cpp +++ b/src/AbstractAnalysis.cpp @@ -157,20 +157,57 @@ void AbstractAnalysis::create_dir_allocate_images() } -void AbstractAnalysis::read_dir_create_list(string folder_path) + + + +bool cmp_file(string f0, string f1) + { + + int v0 = atoi(f0.substr(0, f0.find("_")).c_str()); + + int v1 = atoi(f1.substr(0, f1.find("_")).c_str()); + + return v0 < v1; + +} + + + +void AbstractAnalysis::read_dir_create_list(string folder_path) + +{ + File dir(folder_path); + + if(dir.exists() && dir.isDirectory()) { + vector list; - dir.list(list); + + dir.list(list); + + + + std::sort(list.begin(), list.end(), cmp_file); + + + for(int i = 0; i < list.size(); i++) { + string filepath = folder_path + "/" + list[i]; + _saved_filenames_analysis.push_back(filepath); + } + } } + + + void AbstractAnalysis::saveImageAnalysis(string filename) {