]> git.mxchange.org Git - flightgear.git/commitdiff
Fix a crash if destination directory doesn't exist.
authorcurt <curt>
Mon, 16 Feb 2004 19:14:46 +0000 (19:14 +0000)
committercurt <curt>
Mon, 16 Feb 2004 19:14:46 +0000 (19:14 +0000)
Filter non-scenery items from install/remove list boxes.

utils/fgadmin/src/fgadmin_funcs.cxx

index 735a86f324c059de166cbfa12b485683d67bcaf4..cc04f0c976969df4780b9156a15c4c670bc84894 100644 (file)
@@ -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 );