#FEATURE by cg
authorClaus Gittinger <cg@exept.de>
Sat, 13 Oct 2018 13:45:06 +0200
changeset 23433 247788b989f6
parent 23432 2aa324c941dd
child 23434 5e97f84cfb40
#FEATURE by cg class: Smalltalk class preparation for deployed resources to be in '.resources' instead of resources Needed as there is a conflict with local resources of an app, where de.rs/fr.rs etc. are placed. changed: #getBitmapFileName:forPackage: #getResourceFileName:forPackage: #initSystemPath #resourceDirectoryForPackage:
Smalltalk.st
--- a/Smalltalk.st	Fri Oct 12 20:00:15 2018 +0200
+++ b/Smalltalk.st	Sat Oct 13 13:45:06 2018 +0200
@@ -463,66 +463,67 @@
 initSystemPath
     "setup path where system files are searched for.
      the default path is set to:
-	    .
-	    <directory of exe>       (WIN32 only)
-	    $HOME                    (if defined)
-	    $HOME/.smalltalk         (if defined & existing)
-	    $SMALLTALK_LIBDIR        (if defined & existing)
-	    $STX_LIBDIR              (if defined & existing)
-	    $STX_TOPDIR              (if defined & existing)
-	    REGISTRY('HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\<CurrentVersion>\LibDir') (WIN32 only)
-	    REGISTRY('HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\LibDir')                  (WIN32 only)
-	    <standard places>
+            .
+            <directory of exe>       (WIN32 only)
+            $HOME                    (if defined)
+            $HOME/.smalltalk         (if defined & existing)
+            $SMALLTALK_LIBDIR        (if defined & existing)
+            $STX_LIBDIR              (if defined & existing)
+            $STX_TOPDIR              (if defined & existing)
+            REGISTRY('HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\<CurrentVersion>\LibDir') (WIN32 only)
+            REGISTRY('HKEY_LOCAL_MACHINE\Software\eXept\Smalltalk/X\LibDir')                  (WIN32 only)
+            <standard places>
 
      standard places (unix):
-	    /opt/smalltalk/<release> (if existing)
-	    /opt/smalltalk           (if existing)
-	    /usr/local/lib/smalltalk (if existing)
-	    /usr/lib/smalltalk       (if existing)
-	    /lib/smalltalk           (if existing)
+            /opt/smalltalk/<release> (if existing)
+            /opt/smalltalk           (if existing)
+            /usr/local/lib/smalltalk (if existing)
+            /usr/lib/smalltalk       (if existing)
+            /lib/smalltalk           (if existing)
 
      win32:
-	    \programs\exept\smalltalk (if existing)
-	    \programs\smalltalk       (if existing)
-	    \smalltalk                (if existing)
+            \programs\exept\smalltalk (if existing)
+            \programs\smalltalk       (if existing)
+            \smalltalk                (if existing)
 
      vms:
-	    $stx:lib                 (if existing)
-	    $stx:root                (if existing)
+            $stx:lib                 (if existing)
+            $stx:root                (if existing)
 
      of course, it is possible to add entries from the 'smalltalk.rc'
      startup file; add expressions such as:
-	    Smalltalk systemPath addFirst:'/foo/bar/baz'.
-	or:
-	    Smalltalk systemPath addLast:'/fee/foe/foo'.
+            Smalltalk systemPath addFirst:'/foo/bar/baz'.
+        or:
+            Smalltalk systemPath addLast:'/fee/foe/foo'.
 
      However, smalltalk.rc itself must be found along the above path.
     "
 
     ChangeFileName := 'changes'.
     OperatingSystem isVMSlike ifTrue:[
-	BitmapDirName := 'bitmaps.dir'.
-	BinaryDirName := 'binary.dir'.
-	SourceDirName := 'source.dir'.
-	ResourceDirName := 'resources.dir'.
-	FileInDirName := 'filein.dir'.
-	PackageDirName := 'packages.dir'.
+        BitmapDirName := 'bitmaps.dir'.
+        BinaryDirName := 'binary.dir'.
+        SourceDirName := 'source.dir'.
+        ResourceDirName := 'resources.dir'.
+        FileInDirName := 'filein.dir'.
+        PackageDirName := 'packages.dir'.
     ] ifFalse:[
-	BitmapDirName := 'bitmaps'.
-	BinaryDirName := 'binary'.
-	SourceDirName := 'source'.
-	ResourceDirName := 'resources'.
-	FileInDirName := 'fileIn'.
-	PackageDirName := 'packages'.
+        BitmapDirName := 'bitmaps'.
+        BinaryDirName := 'binary'.
+        SourceDirName := 'source'.
+        ResourceDirName := 'resources'.
+        ResourceDirName := '.resources'.
+        FileInDirName := 'fileIn'.
+        PackageDirName := 'packages'.
     ].
 
     SystemPath isEmptyOrNil ifTrue:[
-	SystemPath := OperatingSystem defaultSystemPath.
-	self flushPathCaches
+        SystemPath := OperatingSystem defaultSystemPath.
+        self flushPathCaches
     ].
 
     PackagePath isEmptyOrNil ifTrue:[
-	PackagePath := OperatingSystem defaultPackagePath.
+        PackagePath := OperatingSystem defaultPackagePath.
     ].
     self addWorkspaceDirectoryToPackagePath.
     self addIdeTopDirectoryToPackagePath.
@@ -7516,9 +7517,9 @@
      then in the package directory if existing.
      Return a path or nil.
      Search order is:
-	bitmaps/<pkg>/file
-	resources/<pkg>/bitmaps/file
-	<pkg>/bitmaps/file
+        bitmaps/<pkg>/file
+        resources/<pkg>/bitmaps/file
+        <pkg>/bitmaps/file
     "
 
     |f dir packageDir pF|
@@ -7526,44 +7527,48 @@
     f := aFileName asString withoutPrefix:'bitmaps/'.
 
     aPackageIDOrNil isNil ifTrue:[
-	"/ this will be an error in the future
+        "/ this will be an error in the future
 "/        'Smalltalk [warning]: bitmap file access without package: ' infoPrint. aFileName infoPrintCR.
 "/        self halt.
 
-	pF := self searchPath:(self realSystemPath) for:aFileName in:('bitmaps').
-	pF notNil ifTrue:[
-	    ^ pF.
-	].
-	f ~= aFileName ifTrue:[
-	    pF := self searchPath:(self realSystemPath) for:f in:('bitmaps').
-	    pF notNil ifTrue:[
-		^ pF.
-	    ].
-	].
-	^ nil
+        pF := self searchPath:(self realSystemPath) for:aFileName in:('bitmaps').
+        pF notNil ifTrue:[
+            ^ pF.
+        ].
+        f ~= aFileName ifTrue:[
+            pF := self searchPath:(self realSystemPath) for:f in:('bitmaps').
+            pF notNil ifTrue:[
+                ^ pF.
+            ].
+        ].
+        ^ nil
     ].
 
     dir := self projectDirectoryForPackage:aPackageIDOrNil.
     dir notNil ifTrue:[
-	pF := dir asFilename / f.
-	pF exists ifTrue:[
-	    ^ pF.
-	].
-	pF := dir asFilename / 'bitmaps' /f.
-	pF exists ifTrue:[
-	    ^ pF.
-	].
+        pF := dir asFilename / f.
+        pF exists ifTrue:[
+            ^ pF.
+        ].
+        pF := dir asFilename / 'bitmaps' /f.
+        pF exists ifTrue:[
+            ^ pF.
+        ].
     ].
 
     packageDir := aPackageIDOrNil copyReplaceAll:$: with:$/.
 
     pF := self searchPath:(self realSystemPath) for:aFileName in:('bitmaps/',packageDir).
     pF notNil ifTrue:[
-	^ pF.
+        ^ pF.
+    ].
+    pF := self searchPath:(self realSystemPath) for:aFileName in:('.resources/',packageDir,'/bitmaps').
+    pF notNil ifTrue:[
+        ^ pF.
     ].
     pF := self searchPath:(self realSystemPath) for:aFileName in:('resources/',packageDir,'/bitmaps').
     pF notNil ifTrue:[
-	^ pF.
+        ^ pF.
     ].
 
     ^ nil
@@ -7726,8 +7731,8 @@
      and in a packages directory.
      Return the absolute filename or nil if none is found.
      Search order is:
-	resources/<pkg>/file
-	<pkg>/resources/file
+        resources/<pkg>/file
+        <pkg>/resources/file
     "
 
     |pF f dir packageDir|
@@ -7735,48 +7740,60 @@
     f := aFileName asString withoutPrefix:'resources/'.
 
     aPackageIDOrNil isNil ifTrue:[
-	"/ this will be an error in the future
+        "/ this will be an error in the future
 "/        'Smalltalk [warning]: resource file access without package: ' infoPrint. aFileName infoPrintCR.
 "/        self halt.
 
-	pF := self searchPath:(self realSystemPath) for:aFileName in:('resources').
-	pF notNil ifTrue:[
-	    ^ pF.
-	].
+        pF := self searchPath:(self realSystemPath) for:aFileName in:('.resources').
+        pF notNil ifTrue:[
+            ^ pF.
+        ].
+        pF := self searchPath:(self realSystemPath) for:aFileName in:('resources').
+        pF notNil ifTrue:[
+            ^ pF.
+        ].
 "/        pF := self searchPath:(self realSystemPath) for:aFileName in:('resources/styles').
 "/        pF notNil ifTrue:[
 "/            ^ pF.
 "/        ].
-	f ~= aFileName ifTrue:[
-	    pF := self searchPath:(self realSystemPath) for:f in:('resources').
-	    pF notNil ifTrue:[
-		^ pF.
-	    ].
+        f ~= aFileName ifTrue:[
+            pF := self searchPath:(self realSystemPath) for:f in:('.resources').
+            pF notNil ifTrue:[
+                ^ pF.
+            ].
+            pF := self searchPath:(self realSystemPath) for:f in:('resources').
+            pF notNil ifTrue:[
+                ^ pF.
+            ].
 "/            pF := self searchPath:(self realSystemPath) for:f in:('resources/styles').
 "/            pF notNil ifTrue:[
 "/                ^ pF.
 "/            ].
-	].
-	^ nil
+        ].
+        ^ nil
     ].
 
     packageDir := aPackageIDOrNil copyReplaceAll:$: with:$/.
 
+    pF := self searchPath:(self realSystemPath) for:aFileName in:('.resources/',packageDir).
+    pF notNil ifTrue:[
+        ^ pF.
+    ].
     pF := self searchPath:(self realSystemPath) for:aFileName in:('resources/',packageDir).
     pF notNil ifTrue:[
-	^ pF.
+        ^ pF.
     ].
 
     "/ the following code finds the file within the IDE's own hierarchy
     dir := self projectDirectoryForPackage:aPackageIDOrNil.
     dir notNil ifTrue:[
-	dir := dir asFilename.
-
-	(pF := dir / 'resources' / f) exists ifTrue:[ ^ pF name ].
+        dir := dir asFilename.
+
+        (pF := dir / 'resources' / f) exists ifTrue:[ ^ pF name ].
 "/        (pF := dir / 'styles' / f) exists ifTrue:[ ^ pF name ].
 
-	"resolve something like: 'ASN/definition.asn1'"
-	(pF := dir / f) exists ifTrue:[ ^ pF name ].
+        "resolve something like: 'ASN/definition.asn1'"
+        (pF := dir / f) exists ifTrue:[ ^ pF name ].
     ].
 
     ^ nil
@@ -8214,17 +8231,21 @@
     |prjDir rsrcDir|
 
     aPackage notNil ifTrue:[
-	prjDir := self projectDirectoryForPackage:aPackage.
-
-	(prjDir notNil
-	and:[(prjDir := prjDir asFilename) exists
-	and:[(rsrcDir := prjDir / 'resources') exists]]) ifTrue:[
-	    ^ rsrcDir
-	].
-	rsrcDir := self getSystemFileName:('resources/' , (aPackage copyReplaceAll:$: with:$/)).
-	rsrcDir notNil ifTrue:[
-	    ^ rsrcDir asFilename
-	].
+        prjDir := self projectDirectoryForPackage:aPackage.
+
+        (prjDir notNil
+        and:[(prjDir := prjDir asFilename) exists
+        and:[(rsrcDir := prjDir / 'resources') exists]]) ifTrue:[
+            ^ rsrcDir
+        ].
+        rsrcDir := self getSystemFileName:('.resources/' , (aPackage copyReplaceAll:$: with:$/)).
+        rsrcDir notNil ifTrue:[
+            ^ rsrcDir asFilename
+        ].
+        rsrcDir := self getSystemFileName:('resources/' , (aPackage copyReplaceAll:$: with:$/)).
+        rsrcDir notNil ifTrue:[
+            ^ rsrcDir asFilename
+        ].
     ].
     ^ nil