*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Mon, 15 Sep 1997 22:51:53 +0200
changeset 2928 39c23e287c81
parent 2927 1434c3d7f78a
child 2929 ca74fdc386cc
*** empty log message ***
Smalltalk.st
--- a/Smalltalk.st	Mon Sep 15 22:50:35 1997 +0200
+++ b/Smalltalk.st	Mon Sep 15 22:51:53 1997 +0200
@@ -18,7 +18,9 @@
 		StartupClass StartupSelector StartupArguments CommandLine
 		CommandLineArguments CachedAbbreviations SilentLoading
 		Initializing StandAlone LogDoits LoadBinaries RealSystemPath
-		ResourcePath SourcePath BitmapPath BinaryPath FileInPath
+		ResourcePath SourcePath BitmapPath BinaryPath FileInPath 
+		BinaryDirName ResourceDirName SourceDirName BitmapDirName
+		FileInDirName ChangeFileName
 		ImageStartTime ImageRestartTime DemoMode SyntaxHilighting'
 	poolDictionaries:''
 	category:'System-Support'
@@ -240,6 +242,21 @@
 
     |p homePath userPrivateSTXDir|
 
+    ChangeFileName := 'changes'.
+    OperatingSystem isVMSlike ifTrue:[
+	BitmapDirName := 'bitmaps.dir'.
+	BinaryDirName := 'binary.dir'.
+	SourceDirName := 'source.dir'.
+	ResourceDirName := 'resources.dir'.
+	FileInDirName := 'filein.dir'.
+    ] ifFalse:[
+	BitmapDirName := 'bitmaps'.
+	BinaryDirName := 'binary'.
+	SourceDirName := 'source'.
+	ResourceDirName := 'resources'.
+	FileInDirName := 'fileIn'.
+    ].
+
     SystemPath isNil ifTrue:[
         homePath := OperatingSystem getHomeDirectory.
         homePath isNil ifTrue:[
@@ -251,15 +268,31 @@
          - this allows private stuff to override global stuff
         "
         SystemPath := OrderedCollection new.
+	"/
+	"/ the current (default) directory
+	"/
         SystemPath add:(Filename currentDirectory name).
 	OperatingSystem isVMSlike ifFalse:[
             SystemPath add:'..'.
 	].
+	"/
+	"/ the users home (login) directory
+	"/
         SystemPath add:homePath.
-	userPrivateSTXDir := homePath asFilename constructString:'.smalltalk'.
-        (OperatingSystem isDirectory:userPrivateSTXDir) ifTrue:[
+	"/
+	"/ a users private smalltalk directory in its home (login) directory
+	"/
+	OperatingSystem isUNIXlike ifTrue:[
+	    userPrivateSTXDir := homePath asFilename constructString:'.smalltalk'.
+	] ifFalse:[
+	    userPrivateSTXDir := homePath asFilename constructString:'smalltalk'.
+	].
+        (userPrivateSTXDir asFilename isDirectory) ifTrue:[
             SystemPath add:userPrivateSTXDir
         ].
+	"/
+	"/ SMALLTALK_LIBDIR and/or STX_LIBDIR from the environment
+	"/
         p := OperatingSystem getEnvironment:'SMALLTALK_LIBDIR'.
         p notNil ifTrue:[
             SystemPath add:p
@@ -268,16 +301,34 @@
         p notNil ifTrue:[
             SystemPath add:p
         ].
+	"/
+	"/ standard locations:
+	"/ UNIX: 
+	"/     /usr/local/lib/smalltalk
+	"/     /usr/lib/smalltalk
+	"/ VMS:
+	"/     stx$root:[lib]
+	"/     stx$lib:
+	"/ MSDOS:
+	"/     \smalltalk (this will change to ...Programs\Smalltalk)
+	"/
 	OperatingSystem isVMSlike ifTrue:[
+            SystemPath add:'stx$lib:'.
+            SystemPath add:'stx$root:[lib]'.
             SystemPath add:'stx$root:'.
-            SystemPath add:'sys$stx:'.
 	] ifFalse:[
-            (OperatingSystem isDirectory:'/usr/local/lib/smalltalk') ifTrue:[
-                SystemPath add:'/usr/local/lib/smalltalk'
-            ].
-            (OperatingSystem isDirectory:'/usr/lib/smalltalk') ifTrue:[
-                SystemPath add:'/usr/lib/smalltalk'
-	    ].
+	    OperatingSystem isUNIXlike ifTrue:[
+                ('/usr/local/lib/smalltalk' asFilename isDirectory) ifTrue:[
+                    SystemPath add:'/usr/local/lib/smalltalk'
+                ].
+                ('/usr/lib/smalltalk' asFilename isDirectory) ifTrue:[
+                    SystemPath add:'/usr/lib/smalltalk'
+	        ].
+	    ] ifFalse:[
+		('\smalltalk' asFilename isDirectory) ifTrue:[
+		    SystemPath add:'\smalltalk'
+		]
+	    ]
         ].
         self flushPathCaches
     ]
@@ -2166,7 +2217,7 @@
 
     aString := self getBitmapFileName:aFileName.
     aString notNil ifTrue:[
-        ^ FileStream readonlyFileNamed:aString
+	^ aString asFilename readStream
     ].
     ^ nil
 !
@@ -2269,10 +2320,15 @@
 !
 
 constructPathFor:aDirectoryName
-    "search for aDirectory in SystemPath"
+    "search for aDirectory in SystemPath; 
+     return a collection of pathes which include that directory."
 
     ^ self realSystemPath select:[:dirName |
-        OperatingSystem isDirectory:(dirName , '/' , aDirectoryName)
+	|fullPath|
+
+	fullPath := dirName asFilename construct:aDirectoryName.
+        "/ fullPath exists and:[fullPath isDirectory and:[fullPath isReadable]]
+        fullPath isDirectory and:[fullPath isReadable]
     ].
 !
 
@@ -2286,7 +2342,7 @@
     "
      do NOT update the changes file now ...
     "
-    self fileIn:'changes' logged:false
+    self fileIn:ChangeFileName logged:false
 
     "
      Smalltalk fileInChanges 
@@ -2302,7 +2358,7 @@
 
     aString := self getFileInFileName:aFileName.
     aString notNil ifTrue:[
-        ^ FileStream readonlyFileNamed:aString
+	^ aString asFilename readStream
     ].
     ^ nil
 !
@@ -2453,10 +2509,10 @@
      return the absolute filename or nil if none is found."
 
     BinaryPath isNil ifTrue:[
-        BinaryPath := self constructPathFor:'binary'
+        BinaryPath := self constructPathFor:BinaryDirName
     ].
 
-    ^ self searchPath:BinaryPath for:aFileName in:'binary'
+    ^ self searchPath:BinaryPath for:aFileName in:BinaryDirName
 
     "Modified: 18.7.1996 / 15:53:49 / cg"
 !
@@ -2467,10 +2523,10 @@
      return the absolute filename or nil if none is found."
 
     BitmapPath isNil ifTrue:[
-        BitmapPath := self constructPathFor:'bitmaps'
+        BitmapPath := self constructPathFor:BitmapDirName
     ].
 
-    ^ self searchPath:BitmapPath for:aFileName in:'bitmaps' 
+    ^ self searchPath:BitmapPath for:aFileName in:BitmapDirName
 
     "
      Smalltalk getBitmapFileName:'SBrowser.xbm'
@@ -2485,10 +2541,10 @@
      return the absolute filename or nil if none is found."
 
     FileInPath isNil ifTrue:[
-        FileInPath := self constructPathFor:'fileIn'
+        FileInPath := self constructPathFor:FileInDirName
     ].
 
-    ^ self searchPath:FileInPath for:aFileName in:'fileIn'
+    ^ self searchPath:FileInPath for:aFileName in:FileInDirName
 
     "Modified: 18.7.1996 / 15:53:59 / cg"
 !
@@ -2499,10 +2555,10 @@
      return the absolute filename or nil if none is found."
 
     ResourcePath isNil ifTrue:[
-        ResourcePath := self constructPathFor:'resources'
+        ResourcePath := self constructPathFor:ResourceDirName
     ].
 
-    ^ self searchPath:ResourcePath for:aFileName in:'resources' 
+    ^ self searchPath:ResourcePath for:aFileName in:ResourceDirName
 
     "
      Smalltalk getResourceFileName:'SBrowser.rs'
@@ -2519,10 +2575,10 @@
      if no sourceCodeManager is available."
 
     SourcePath isNil ifTrue:[
-        SourcePath := self constructPathFor:'source'
+        SourcePath := self constructPathFor:SourceDirName
     ].
 
-    ^ self searchPath:SourcePath for:aFileName in:'source' 
+    ^ self searchPath:SourcePath for:aFileName in:SourceDirName 
 
     "
      Smalltalk getSourceFileName:'Smalltalk.st'  
@@ -2545,14 +2601,19 @@
     fn isAbsolute ifTrue:[
         "dont use path for absolute file names"
 
-        ^ aFileNameOrString
+        ^ fn name
     ].
 
     self realSystemPath do:[:dirName |
         |realName|
 
         realName := dirName asFilename construct:(fn name).
-        realName isReadable ifTrue: [
+	"/
+	"/ here, we also return true if its a directory
+	"/ (Even if unreadable). 
+	"/ It could be that the file itself is still readable.
+	"/
+        (realName isDirectory or:[realName isReadable]) ifTrue: [
             ^ realName name
         ]
     ].
@@ -2856,9 +2917,27 @@
      SystemPath which exist and are readable"
 
     RealSystemPath isNil ifTrue:[
-        RealSystemPath := SystemPath select:[:dirName |
-            (OperatingSystem isDirectory:dirName)
-            and:[OperatingSystem isReadable:dirName]
+	OperatingSystem isVMSlike ifTrue:[
+	    "/ temporary kludge: since we cannot currently
+	    "/ check for existance of a name like 'volume:',
+	    "/ leave those in the Path without a check.
+            RealSystemPath := SystemPath select:[:dirName |
+	        |f|
+
+	        f := dirName asFilename.
+		f isVolumeOnly ifTrue:[
+		    true
+	 	] ifFalse:[
+                    (f isDirectory) and:[f isReadable]
+		]
+	    ]
+	] ifFalse:[
+            RealSystemPath := SystemPath select:[:dirName |
+	        |f|
+
+	        f := dirName asFilename.
+                (f isDirectory) and:[f isReadable]
+	    ]
         ].
     ].
     ^ RealSystemPath
@@ -2873,7 +2952,7 @@
 
     aString := self getResourceFileName:aFileName.
     aString notNil ifTrue:[
-        ^ FileStream readonlyFileNamed:aString
+	^ aString asFilename readStream
     ].
     ^ nil
 !
@@ -2882,9 +2961,10 @@
     "search aPath for a subdirectory named aDirectory with a file
      named aFileName"
 
-    ((aFileName startsWith:'/') 
-    or:[(aFileName startsWith:'./')
-    or:[(aFileName startsWith:'../')]]) ifTrue:[
+    |f|
+
+    ((f := aFileName asFilename) isAbsolute 
+    or:[f isExplicitRelative]) ifTrue:[
         "/
         "/ dont use path for absolute or explicit .-relative file names
         "/
@@ -2894,7 +2974,8 @@
     aPath do:[:dirName |
         |realName|
 
-        (OperatingSystem isReadable:(realName := dirName , '/' , aDirName , '/' , aFileName)) ifTrue: [
+	realName := (dirName asFilename construct:aDirName) constructString:aFileName.
+	realName asFilename isReadable ifTrue:[
             ^ realName
         ]
     ].
@@ -3000,7 +3081,7 @@
 
     aString := self getSourceFileName:aFileName.
     aString notNil ifTrue:[
-        ^ FileStream readonlyFileNamed:aString
+	^ aString asFilename readStream
     ].
     ^ nil
 !
@@ -3014,7 +3095,7 @@
 
     aString := self getSystemFileName:aFileName.
     aString notNil ifTrue:[
-        ^ FileStream readonlyFileNamed:aString
+	^ aString asFilename readStream
     ].
     ^ nil
 !
@@ -3640,7 +3721,7 @@
      and represent a stable workable version which got published
      to the outside world."
 
-    ^ 9
+    ^ 10
 
     " 
      Smalltalk revisionNr
@@ -3695,5 +3776,5 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.251 1997-09-09 17:56:07 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.252 1997-09-15 20:51:53 cg Exp $'
 ! !