Alex Romosan <romo...@sycorax.lbl.gov> writes:

> James Turner <ja...@bugless.co.uk> writes:
>
>> Can you email me what you get for --show-aircraft? (off list, is best)
>
> fgfs --show-aircraft
>
> Available aircraft:
>
>
> (that is nothing). this on linux.

on non ext* file systems readdir doesn't return the file type in d_type
so this explains why i kept getting an empty list for show-aircraft (my
flightgear directory is on reiserfs). i've already sent the patch to
james, but maybe somebody else also wants to give it a try (works for
me).

diff --git a/simgear/misc/sg_dir.cxx b/simgear/misc/sg_dir.cxx
index 9c5aa78..64232c3 100644
--- a/simgear/misc/sg_dir.cxx
+++ b/simgear/misc/sg_dir.cxx
@@ -119,25 +119,11 @@ PathList Dir::children(int types, const std::string& nameFilter) const
       continue;
     }
     
-    int type = entry->d_type;
-    if (type == DT_LNK) {
-      // find symlink target type using stat()
-      struct stat s;
-      if (stat(file(entry->d_name).c_str(), &s)) {
-        continue; // stat() failed
-      }
-      
-      if (S_ISDIR(s.st_mode)) {
-        type = DT_DIR;
-      } else if (S_ISREG(s.st_mode)) {
-        type = DT_REG;
-      } else {
-        // symlink to block/fifo/char file, ignore
-        continue;
-      }
-    } // of symlink look-through
-    
-    if (type == DT_DIR) {
+    struct stat st;
+    if(stat(file(entry->d_name).c_str(), &st))
+      continue; // stat() failed
+
+    if (S_ISDIR(st.st_mode)) {
       if (!(types & TYPE_DIR)) {
         continue;
       }
@@ -147,7 +133,7 @@ PathList Dir::children(int types, const std::string& nameFilter) const
           continue;
         }
       }
-    } else if (type == DT_REG) {
+    } else if (S_ISREG(st.st_mode)) {
       if (!(types & TYPE_FILE)) {
         continue;
       }
--alex--

-- 
| I believe the moment is at hand when, by a paranoiac and active |
|  advance of the mind, it will be possible (simultaneously with  |
|  automatism and other passive states) to systematize confusion  |
|  and thus to help to discredit completely the world of reality. |
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to