Skip to content

Commit

Permalink
Per #1508, simplify the file list parsing logic. After 10 missing fil…
Browse files Browse the repository at this point in the history
…enames, abort, assuming that this is not actually a file list!
  • Loading branch information
JohnHalleyGotway committed Oct 14, 2020
1 parent 1c7540f commit 548501a
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions met/src/libcode/vx_data2d_factory/parse_file_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ if ( !f_in ) {
// Read and store the file names
//

int n_exist = 0;
int n_missing = 0;

const int max_missing = 10;

Expand All @@ -157,33 +157,34 @@ while(f_in >> file_name) {
continue;
}

//
// Add current string to the list of files
//

a.add(file_name.c_str());

//
// Count how many files actually exist and
// abort after too many missing files
// Keep track of the number of missing files.
// After too many missing files, assume this is not a file list
// and return an empty list.
//

if ( check_files_exist && n_exist == 0 ) {
if ( check_files_exist ) {

if ( a.n() >= max_missing ) break;
if ( !is_regular_file(file_name.c_str()) ) n_missing++;

if ( is_regular_file(file_name.c_str()) ) n_exist++;
if ( n_missing >= max_missing ) {

}
mlog << Debug(5) << "parse_ascii_file_list() -> "
<< "File \"" << path << "\" is not an ASCII file list "
<< "since there are too many missing files.\n";

}
a.clear();

//
// When checking file existence and none exist,
// return an empty list
//

if ( check_files_exist && n_exist == 0 ) a.clear();

//
// done
//
break;
}
}
}

f_in.close();

Expand Down

0 comments on commit 548501a

Please sign in to comment.