44 void list_files(
const char* pattern, std::vector<std::string>& out_list)
47 const char dirsep =
'\\';
49 const char dirsep =
'/';
52 std::string base_input_name(pattern);
53 size_t last_slash = base_input_name.rfind(dirsep);
54 std::string base_path = base_input_name.substr( 0, last_slash+1 );
55 log_info(stderr,
"directory : \"%s\"\n", base_path.c_str());
57 typedef std::pair<nvbio::uint32, std::string> sortkey;
58 std::vector<sortkey> files;
63 _finddata_t file_info;
64 intptr_t find_handle = _findfirst( base_input_name.c_str(), &file_info );
65 if (find_handle == -1)
67 log_error(stderr,
"unable to locate \"%s\"", base_input_name.c_str());
72 temp.second = base_path + std::string( file_info.name );
73 files.push_back(temp);
74 }
while (_findnext( find_handle, &file_info) != -1);
79 int stat = glob( base_input_name.c_str(), 0, 0, &info );
82 fprintf(stderr,
"unable to locate \"%s\"", base_input_name.c_str());
86 temp.second = std::string( info.gl_pathv[i] );
87 files.push_back(temp);
95 std::vector<sortkey>::iterator iter;
96 for(iter=files.begin(); iter!=files.end(); ++iter) {
98 std::string numstring;
99 end = iter->second.find_last_of(
".");
100 end = iter->second.find_last_of(
"0123456789", end);
101 if( end == std::string::npos ) {
105 begin = 1 + iter->second.find_last_not_of(
"0123456789", end);
106 numstring = iter->second.substr(begin, end-begin+1);
107 iter->first = atoi( numstring.c_str() );
112 for(iter=files.begin(); iter!=files.end(); ++iter) {
113 out_list.push_back(iter->second);