classFilename handling
authorClaus Gittinger <cg@exept.de>
Fri, 06 Oct 2006 16:11:47 +0200
changeset 10051 1f50fcf774af
parent 10050 ac9d34eeeaaa
child 10052 93502b0dc620
classFilename handling
Smalltalk.st
--- a/Smalltalk.st	Fri Oct 06 15:51:04 2006 +0200
+++ b/Smalltalk.st	Fri Oct 06 16:11:47 2006 +0200
@@ -12,21 +12,21 @@
 "{ Package: 'stx:libbasic' }"
 
 Object subclass:#Smalltalk
-	instanceVariableNames:''
-	classVariableNames:'StartBlocks ImageStartBlocks ExitBlocks CachedClasses
-		NumberOfClassesHint SystemPath StartupClass StartupSelector
-		StartupArguments CommandLine CommandName CommandLineArguments
-		CachedAbbreviations SilentLoading Initializing StandAlone
-		HeadlessOperation IsPlugin IsSharedLibraryComponent
-		DebuggingStandAlone LogDoits LoadBinaries RealSystemPath
-		ResourcePath SourcePath BitmapPath BinaryPath FileInPath
-		PackagePath BinaryDirName ResourceDirName SourceDirName
-		BitmapDirName PackageDirName FileInDirName ChangeFileName
-		ImageStartTime ImageRestartTime DemoMode SaveEmergencyImage
-		SpecialObjectArray CallbackSignal KnownPackages
-		ClassesFailedToInitialize HasNoConsole'
-	poolDictionaries:''
-	category:'System-Support'
+        instanceVariableNames:''
+        classVariableNames:'StartBlocks ImageStartBlocks ExitBlocks CachedClasses
+                NumberOfClassesHint SystemPath StartupClass StartupSelector
+                StartupArguments CommandLine CommandName CommandLineArguments
+                CachedAbbreviations SilentLoading Initializing StandAlone
+                HeadlessOperation IsPlugin IsSharedLibraryComponent
+                DebuggingStandAlone LogDoits LoadBinaries RealSystemPath
+                ResourcePath SourcePath BitmapPath BinaryPath FileInPath
+                PackagePath BinaryDirName ResourceDirName SourceDirName
+                BitmapDirName PackageDirName FileInDirName ChangeFileName
+                ImageStartTime ImageRestartTime DemoMode SaveEmergencyImage
+                SpecialObjectArray CallbackSignal KnownPackages
+                ClassesFailedToInitialize HasNoConsole'
+        poolDictionaries:''
+        category:'System-Support'
 !
 
 Smalltalk comment:'declared from: ..\..\..\stx\libbasic\abbrev.stc'
@@ -4370,7 +4370,7 @@
      nil uses the value from SilentLoading."
 
     |classFileName alternativeClassFileName libName newClass ok wasLazy wasSilent sharedLibExtension inStream mgr 
-     fn packageDir packageFile bos hasSuffix|
+     fn packageDir packageFile bos hasSuffix classFilenameWithSuffix classFilenameWithoutSuffix|
 
     wasLazy := Compiler compileLazy:loadLazy.
     beSilent notNil ifTrue:[
@@ -4386,13 +4386,17 @@
         ].
     ].
 
-    hasSuffix := classFileName asFilename suffix notEmptyOrNil.    
+    hasSuffix := classFileName asFilename suffix notEmptyOrNil.
+    hasSuffix ifTrue:[
+        classFilenameWithoutSuffix := classFileName asFilename withoutSuffix name.
+        classFilenameWithSuffix := classFileName.
+    ] ifFalse:[
+        classFilenameWithoutSuffix := classFileName.
+        classFilenameWithSuffix := classFileName,'.st'.
+    ].
+
     classFileName asFilename isAbsolute ifTrue:[
-        hasSuffix ifTrue:[
-            ok := self fileIn:classFileName lazy:loadLazy silent:beSilent.
-        ] ifFalse:[
-            ok := self fileIn:(classFileName,'.st') lazy:loadLazy silent:beSilent.
-        ]
+        ok := self fileIn:classFilenameWithSuffix lazy:loadLazy silent:beSilent.
     ] ifFalse:[
 
         classFileName := classFileName copyReplaceAll:$: with:$_.
@@ -4435,10 +4439,10 @@
                              then, look for a shared binary in binary/xxx.o
                             "
                             ok ifFalse:[
-                                (ok := self fileInClass:aClassName fromObject:(classFileName, sharedLibExtension))
+                                (ok := self fileInClass:aClassName fromObject:(classFilenameWithoutSuffix, sharedLibExtension))
                                 ifFalse:[
                                     sharedLibExtension ~= '.o' ifTrue:[
-                                        ok := self fileInClass:aClassName fromObject:(classFileName, '.o')
+                                        ok := self fileInClass:aClassName fromObject:(classFilenameWithoutSuffix, '.o')
                                     ].
                                     ok ifFalse:[
                                         alternativeClassFileName notNil ifTrue:[
@@ -4458,7 +4462,7 @@
                          if that did not work, look for a compiled-bytecode file ...
                         "
                         ok ifFalse:[
-                            (ok := self fileIn:(classFileName , '.cls') lazy:loadLazy silent:beSilent)
+                            (ok := self fileIn:(classFilenameWithoutSuffix , '.cls') lazy:loadLazy silent:beSilent)
                             ifFalse:[
                                 alternativeClassFileName notNil ifTrue:[
                                     ok := self fileIn:(alternativeClassFileName , '.cls') lazy:loadLazy silent:beSilent
@@ -4472,9 +4476,9 @@
                         "
                         ok ifFalse:[
                             (packageDir notNil and:[BinaryObjectStorage notNil]) ifTrue:[
-                                packageFile := self getPackageFileName:(packageDir , '/classes/' , classFileName , '.cls').
+                                packageFile := self getPackageFileName:(packageDir , '/classes/' , classFilenameWithoutSuffix , '.cls').
                                 packageFile isNil ifTrue:[
-                                    packageFile := (packageDir , '/classes/' , classFileName , '.cls').
+                                    packageFile := (packageDir , '/classes/' , classFilenameWithoutSuffix , '.cls').
                                 ].
                                 (ok := self fileIn:packageFile lazy:loadLazy silent:beSilent)
                                 ifFalse:[
@@ -4491,7 +4495,7 @@
                                 zarFn notNil ifTrue:[
                                     zar := ZipArchive oldFileNamed:zarFn.
                                     zar notNil ifTrue:[
-                                        entry := zar extract:(classFileName , '.cls').
+                                        entry := zar extract:(classFilenameWithoutSuffix , '.cls').
                                         (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
                                             entry := zar extract:(alternativeClassFileName , '.cls').
                                         ].
@@ -4510,7 +4514,7 @@
                          if that did not work, look for an st-source file ...
                         "
                         ok ifFalse:[                   
-                            fn := classFileName , '.st'.
+                            fn := classFilenameWithoutSuffix , '.st'.
                             (ok := self fileIn:fn lazy:loadLazy silent:beSilent)
                             ifFalse:[
                                 alternativeClassFileName notNil ifTrue:[
@@ -4521,7 +4525,7 @@
                                     "
                                      ... and in the standard source-directory
                                     "
-                                    fn := 'source/' , classFileName , '.st'.
+                                    fn := 'source/' , classFilenameWithoutSuffix , '.st'.
                                     (ok := self fileIn:fn lazy:loadLazy silent:beSilent)
                                     ifFalse:[
                                         alternativeClassFileName notNil ifTrue:[
@@ -4538,9 +4542,9 @@
                             "
                             ok ifFalse:[
                                 packageDir notNil ifTrue:[
-                                    packageFile := self getPackageFileName:(packageDir , '/source/' , classFileName , '.st').
+                                    packageFile := self getPackageFileName:(packageDir , '/source/' , classFilenameWithoutSuffix , '.st').
                                     packageFile isNil ifTrue:[
-                                        packageFile := (packageDir , '/source/' , classFileName , '.st').
+                                        packageFile := (packageDir , '/source/' , classFilenameWithoutSuffix , '.st').
                                     ].
                                     fn := packageFile.
                                     (ok := self fileIn:packageFile lazy:loadLazy silent:beSilent)
@@ -4555,9 +4559,9 @@
                                         ].
                                         ok ifFalse:[
 
-                                            packageFile := self getPackageFileName:(packageDir , '/' , classFileName , '.st').
+                                            packageFile := self getPackageFileName:(packageDir , '/' , classFilenameWithoutSuffix , '.st').
                                             packageFile isNil ifTrue:[
-                                                packageFile := (packageDir , '/' , classFileName , '.st').
+                                                packageFile := (packageDir , '/' , classFilenameWithoutSuffix , '.st').
                                             ].
                                             fn := packageFile.
                                             (ok := self fileIn:packageFile lazy:loadLazy silent:beSilent)
@@ -4574,7 +4578,7 @@
                                                     "
                                                      ... and in the standard source-directory
                                                     "
-                                                    fn := 'source/' , packageDir , '/' , classFileName , '.st'.
+                                                    fn := 'source/' , packageDir , '/' , classFilenameWithoutSuffix , '.st'.
                                                     (ok := self fileIn:fn lazy:loadLazy silent:beSilent)
                                                     ifFalse:[
                                                         alternativeClassFileName notNil ifTrue:[
@@ -4602,7 +4606,7 @@
                                     zarFn notNil ifTrue:[
                                         zar := ZipArchive oldFileNamed:zarFn.
                                         zar notNil ifTrue:[
-                                            entry := zar extract:(classFileName , '.st').
+                                            entry := zar extract:(classFilenameWithoutSuffix , '.st').
                                             (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
                                                 entry := zar extract:(alternativeClassFileName , '.st').
                                             ].
@@ -4629,7 +4633,7 @@
                                 zarFn notNil ifTrue:[
                                     zar := ZipArchive oldFileNamed:zarFn.
                                     zar notNil ifTrue:[
-                                        entry := zar extract:(zarFn := classFileName , '.st').
+                                        entry := zar extract:(zarFn := classFilenameWithoutSuffix , '.st').
                                         (entry isNil and:[alternativeClassFileName notNil]) ifTrue:[
                                             entry := zar extract:(zarFn := alternativeClassFileName , '.st').
                                         ].
@@ -4989,7 +4993,7 @@
 fileNameForClass:aClassOrClassName
     "return a filename for aClassOrClassName"
 
-    |cls nonMetaclass nm1 nm2|
+    |cls nonMetaclass nm nm1 nm2|
 
     aClassOrClassName isBehavior ifTrue:[
         nonMetaclass := aClassOrClassName theNonMetaclass.
@@ -4999,6 +5003,8 @@
         cls := Smalltalk classNamed:aClassOrClassName.
         cls notNil ifTrue:[
             nonMetaclass := cls theNonMetaclass.
+            nm := nonMetaclass getClassFilename.
+            nm notNil ifTrue:[^ nm asFilename baseName].
             nm1 := nonMetaclass name.
             nm2 := nonMetaclass nameWithoutPrefix.
         ] ifFalse:[
@@ -5029,7 +5035,7 @@
      Smalltalk fileNameForClass:'OSI::Foobar' 
     "
 
-    "Modified: / 5.11.2001 / 16:49:17 / cg"
+    "Modified: / 06-10-2006 / 16:03:08 / cg"
 !
 
 filenameAbbreviations
@@ -6887,5 +6893,5 @@
 !Smalltalk class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.759 2006-10-06 13:50:47 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/Smalltalk.st,v 1.760 2006-10-06 14:11:47 cg Exp $'
 ! !