fixes for WIN32 (network drives and drive-volumes)
authorClaus Gittinger <cg@exept.de>
Thu, 24 Sep 1998 16:50:41 +0200
changeset 1139 465a6c941877
parent 1138 14dc9f6791d2
child 1140 58e8ac12750a
fixes for WIN32 (network drives and drive-volumes)
FileSelectionItem.st
--- a/FileSelectionItem.st	Fri Sep 18 20:03:37 1998 +0200
+++ b/FileSelectionItem.st	Thu Sep 24 16:50:41 1998 +0200
@@ -108,9 +108,11 @@
     path := aPathname asString.
 
     (path size > 1 and:[path endsWith:(Filename separator)]) ifTrue:[
-        ^ (path copyWithout:1) asFilename.
+        ^ (path copyWithoutLast:1) asFilename.
     ].
   ^ aPathname asFilename
+
+    "Modified: / 24.9.1998 / 15:33:50 / cg"
 ! !
 
 !FileSelectionItem class methodsFor:'default icons'!
@@ -213,8 +215,15 @@
     "
     |file|
 
-    file := self class asFilename:aPathname.
-    self fileName:file baseName:(file baseName) parent:nil isDirectory:(file isDirectory)
+"/    file := self class asFilename:aPathname.
+    file := aPathname asFilename pathName asFilename.
+    self 
+        fileName:file 
+        baseName:(file baseName) 
+        parent:nil 
+        isDirectory:(file isDirectory)
+
+    "Modified: / 24.9.1998 / 16:02:53 / cg"
 ! !
 
 !FileSelectionItem methodsFor:'accessing hierarchy'!
@@ -260,11 +269,51 @@
 
 !FileSelectionItem methodsFor:'private'!
 
-fileName:aFilenname baseName:aBaseName parent:aParent isDirectory:aBool
+childFileName:aFilename baseName:aBaseName parent:aParent isDirectory:aBool matchAction:mA
+    "initialze attributes associated with the full pathname, aPathname.
+     Same as #fileName:baseName:parent:isDirectory:,
+     but used only for children (i.e. no need to check for
+     being a rootDirectory).
+    "
+    |f|
+
+    contents    := aFilename.
+    name        := aBaseName.
+    parent      := aParent.
+    isDirectory := readChildren := aBool.
+
+    isDirectory ifFalse:[
+        showIndicator := false
+    ] ifTrue:[
+        showIndicator := nil
+    ].
+
+    matchAction := mA
+
+    "Modified: / 24.9.1998 / 14:10:38 / cg"
+    "Created: / 24.9.1998 / 15:51:58 / cg"
+!
+
+directoryIsLocked
+    ^ self imageType == #directoryLocked
+
+    "Created: / 24.9.1998 / 14:22:08 / cg"
+!
+
+fileName:aFilename baseName:aBaseName parent:aParent isDirectory:aBool
     "initialze attributes associated with the full pathname, aPathname
     "
-    contents    := aFilenname.
-    name        := aBaseName.
+    |f|
+
+    contents    := aFilename.
+    (f := aFilename asFilename) isRootDirectory ifTrue:[
+        name := f name.
+        (name endsWith:Filename separator) ifTrue:[
+            name := name copyWithoutLast:1.
+        ]
+    ] ifFalse:[
+        name        := aBaseName.
+    ].
     parent      := aParent.
     isDirectory := readChildren := aBool.
 
@@ -280,6 +329,7 @@
         self match:nil                          "/ setup matchAction new
     ]
 
+    "Modified: / 24.9.1998 / 16:05:13 / cg"
 !
 
 matchAction
@@ -413,7 +463,7 @@
     |model|
 
     showIndicator isNil ifTrue:[
-        (self imageType == #directoryLocked) ifTrue:[
+        self directoryIsLocked ifTrue:[
             showIndicator := readChildren := false.
         ] ifFalse:[
             (model := self model) notNil ifTrue:[
@@ -424,7 +474,7 @@
     ].
     ^ showIndicator
 
-
+    "Modified: / 24.9.1998 / 14:22:34 / cg"
 !
 
 showIndicator:aBool
@@ -498,6 +548,7 @@
 !FileSelectionItem methodsFor:'update'!
 
 imageType
+    "return my icon-image type - a symbol"
 
     |readable|
 
@@ -506,8 +557,9 @@
 
         isDirectory ifTrue:[
             (readable and:[contents isExecutable]) ifTrue:[
-                contents isSymbolicLink ifFalse:[imageType := #directory]
-                                         ifTrue:[imageType := #directoryLink]
+                contents isSymbolicLink 
+                    ifFalse:[imageType := #directory]
+                    ifTrue:[imageType := #directoryLink]
             ] ifFalse:[
                 imageType := #directoryLocked
             ]
@@ -529,6 +581,7 @@
     ].
     ^ imageType
 
+    "Modified: / 24.9.1998 / 15:47:38 / cg"
 !
 
 readInChildren
@@ -540,7 +593,7 @@
     readChildren  := false.
     showIndicator := false.
 
-    self imageType == #directoryLocked ifFalse:[
+    self directoryIsLocked ifFalse:[
         Cursor wait showWhile:[
             directory := DirectoryContents directoryNamed:contents.
 
@@ -553,7 +606,12 @@
 
                 directory contentsAndBaseNamesDo:[:file :bname :isDir|
                     (self isVisibleFile:file isDirectory:isDir baseName:bname) ifTrue:[
-                        list add:(self class new fileName:file baseName:bname parent:self isDirectory:isDir)
+                        list add:(self class new 
+                                    childFileName:file 
+                                    baseName:bname 
+                                    parent:self 
+                                    isDirectory:isDir
+                                     matchAction:matchAction)
                     ]
                 ].
                 showIndicator := list size ~~ 0.
@@ -562,6 +620,7 @@
     ].
   ^ list
 
+    "Modified: / 24.9.1998 / 15:52:53 / cg"
 ! !
 
 !FileSelectionItem::Directory class methodsFor:'documentation'!
@@ -614,5 +673,5 @@
 !FileSelectionItem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/FileSelectionItem.st,v 1.11 1998-05-29 11:01:26 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/FileSelectionItem.st,v 1.12 1998-09-24 14:50:41 cg Exp $'
 ! !