Fix a crash if destination directory doesn't exist.
Filter non-scenery items from install/remove list boxes.
This commit is contained in:
parent
2513d06633
commit
7d6d574a50
1 changed files with 16 additions and 8 deletions
|
@ -137,7 +137,7 @@ void FGAdminUI::update_install_box() {
|
||||||
|
|
||||||
install_box->clear();
|
install_box->clear();
|
||||||
|
|
||||||
if ( source.length() ) {
|
if ( source.length() && fl_filename_isdir(source.c_str()) ) {
|
||||||
ulDir *dir = ulOpenDir( source.c_str() ) ;
|
ulDir *dir = ulOpenDir( source.c_str() ) ;
|
||||||
ulDirEnt *ent;
|
ulDirEnt *ent;
|
||||||
while ( ent = ulReadDir( dir ) ) {
|
while ( ent = ulReadDir( dir ) ) {
|
||||||
|
@ -159,14 +159,22 @@ void FGAdminUI::update_install_box() {
|
||||||
base[offset] = '\0';
|
base[offset] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
// add to list if not installed
|
if ( strlen(ent->d_name) != 14 ) {
|
||||||
SGPath install( dest );
|
// simple heuristic to ingore non-scenery files
|
||||||
install.append( base );
|
} else if ( ent->d_name[0] != 'e' && ent->d_name[0] != 'w' ) {
|
||||||
if ( ! fl_filename_isdir( install.c_str() ) ) {
|
// further sanity checks on name
|
||||||
// cout << install.str() << " install candidate." << endl;
|
} else if ( ent->d_name[4] != 'n' && ent->d_name[4] != 's' ) {
|
||||||
file_list.push_back( ent->d_name );
|
// further sanity checks on name
|
||||||
} else {
|
} 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 );
|
ulCloseDir( dir );
|
||||||
|
|
Loading…
Add table
Reference in a new issue