#REFACTORING by stefan
authorStefan Vogel <sv@exept.de>
Wed, 10 Oct 2018 21:00:15 +0200
changeset 4187 6e1d90c18dc9
parent 4186 728710f3356f
child 4188 f9e164682d74
#REFACTORING by stefan class: DropObject::File added: #isRegularFile changed: #isDirectory #isHtmlFile #isImageFile #isPrintable
DropObject.st
--- a/DropObject.st	Wed Oct 10 00:45:50 2018 +0200
+++ b/DropObject.st	Wed Oct 10 21:00:15 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1997 by eXept Software AG
               All Rights Reserved
@@ -447,8 +449,8 @@
 isDirectory
     "checks whether file is a directory"
 
-    ^ self exists 
-        and:[ self fetchFileInfo type == #directory ]
+    info := self fetchFileInfo.
+    ^ info notNil and:[info isDirectory]
 !
 
 isHtmlFile
@@ -457,10 +459,9 @@
     |mimeType|
 
     isHtmlFile isNil ifTrue:[
-        isHtmlFile := self exists 
-                        and:[ self isDirectory not
+        isHtmlFile := self isRegularFile
                         and:[ (mimeType := MIMETypes mimeTypeForFilename:(self asFilename)) notNil
-                        and:[ mimeType isHtmlType ]]].
+                        and:[ mimeType isHtmlType]].
 
 "/        isHtmlFile := self exists 
 "/                        and:[ self isDirectory not
@@ -473,9 +474,8 @@
     "returns true if file is an image file"
 
     isImageFile isNil ifTrue:[
-        isImageFile := self exists 
-                        and:[self isDirectory not
-                        and:[ Image isImageFileSuffix:(self asFilename suffix) ]].
+        isImageFile := self isRegularFile
+                        and:[Image isImageFileSuffix:(self asFilename suffix)].
     ].
     ^ isImageFile
 
@@ -492,7 +492,7 @@
     isPrintable isNil ifTrue:[
         isPrintable := false.
 
-        (self exists and:[ self isDirectory not ]) ifTrue:[
+        self isRegularFile ifTrue:[
             stream := self asFilename readStreamOrNil.
             stream notNil ifTrue:[
                 buff := String new:nChars.
@@ -507,6 +507,13 @@
         ]
     ].
     ^ isPrintable
+!
+
+isRegularFile
+    "checks whether file is a directory"
+
+    info := self fetchFileInfo.
+    ^ info notNil and:[info isRegular]
 ! !
 
 !DropObject::File methodsFor:'testing'!
@@ -623,10 +630,10 @@
 !DropObject class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.24 2015-02-04 23:15:25 cg Exp $'
+    ^ '$Header$'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.24 2015-02-04 23:15:25 cg Exp $'
+    ^ '$Header$'
 ! !