From 7d6d574a507e54760bd7e389e660c4db20665160 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 16 Feb 2004 19:14:46 +0000 Subject: [PATCH] Fix a crash if destination directory doesn't exist. Filter non-scenery items from install/remove list boxes. --- utils/fgadmin/src/fgadmin_funcs.cxx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/utils/fgadmin/src/fgadmin_funcs.cxx b/utils/fgadmin/src/fgadmin_funcs.cxx index 735a86f32..cc04f0c97 100644 --- a/utils/fgadmin/src/fgadmin_funcs.cxx +++ b/utils/fgadmin/src/fgadmin_funcs.cxx @@ -137,7 +137,7 @@ void FGAdminUI::update_install_box() { install_box->clear(); - if ( source.length() ) { + if ( source.length() && fl_filename_isdir(source.c_str()) ) { ulDir *dir = ulOpenDir( source.c_str() ) ; ulDirEnt *ent; while ( ent = ulReadDir( dir ) ) { @@ -159,14 +159,22 @@ void FGAdminUI::update_install_box() { base[offset] = '\0'; } - // add to list if not installed - SGPath install( dest ); - install.append( base ); - if ( ! fl_filename_isdir( install.c_str() ) ) { - // cout << install.str() << " install candidate." << endl; - file_list.push_back( ent->d_name ); + if ( strlen(ent->d_name) != 14 ) { + // simple heuristic to ingore non-scenery files + } else if ( ent->d_name[0] != 'e' && ent->d_name[0] != 'w' ) { + // further sanity checks on name + } else if ( ent->d_name[4] != 'n' && ent->d_name[4] != 's' ) { + // further sanity checks on name } else { - // cout << install.str() << " exists." << endl; + // add to list if not installed + SGPath install( dest ); + install.append( base ); + if ( ! fl_filename_isdir( install.c_str() ) ) { + // cout << install.str() << " install candidate." << endl; + file_list.push_back( ent->d_name ); + } else { + // cout << install.str() << " exists." << endl; + } } } ulCloseDir( dir );