diff jface/FileTreeViewer.d @ 73:9ff9b8f7284b

FileTreeViewer now work on windows without error dialog.
author Frank Benoit <benoit@tionex.de>
date Sun, 13 Apr 2008 20:55:55 +0200
parents e7e5002eabcf
children 5fe95b1ccf68
line wrap: on
line diff
--- a/jface/FileTreeViewer.d	Sun Apr 13 17:19:38 2008 +0200
+++ b/jface/FileTreeViewer.d	Sun Apr 13 20:55:55 2008 +0200
@@ -41,7 +41,7 @@
 
 import tango.util.collection.model.Seq;
 import tango.util.collection.ArraySeq;
-
+import tango.text.convert.Utf;
 
 void main(){
     auto hw = new FileTree;
@@ -129,6 +129,10 @@
         Object[] res;
 
         foreach( root; FileRoots.list()){
+            // ignore floppy drives, they bring up strange error messages
+            if( root == `A:\`|| root == `B:\` ){
+                continue;
+            }
             res ~= new FilePath( root );
         }
 
@@ -169,14 +173,20 @@
     }
 
     public override Image getImage(Object arg0){
-        return (cast(FilePath)arg0).isFolder() ? dir : file;
+        auto fp = cast(FilePath)arg0;
+        // is a root
+        if( fp.name.length is 0 ){
+            return dir;
+        }
+        return fp.isFolder() ? dir : file;
     }
 
     public override char[] getText(Object arg0){
-        auto text = (cast(FilePath)arg0).name();
+        auto fp = cast(FilePath)arg0;
+        auto text = fp.name();
         if( text.length is 0 ){
             // now take all info, it will be drive or the root folder
-            text = (cast(FilePath)arg0).toString();
+            text = fp.toString();
         }
         return preserveCase ? text : text.toUpperCase();
     }