ObjectMemory.st
changeset 16650 92b1c33b39f8
parent 16649 5e7d84ca6923
child 16680 0d13e1173228
--- a/ObjectMemory.st	Sun Jun 29 14:36:00 2014 +0200
+++ b/ObjectMemory.st	Sun Jun 29 14:46:23 2014 +0200
@@ -5132,6 +5132,30 @@
 
 !ObjectMemory class methodsFor:'system management'!
 
+directoryForImageAndChangeFile
+    |dir exeDir|
+
+    dir := Filename currentDirectory.
+
+    "/ the current directory is not a good idea, if stx is started via a desktop manager
+    "/ or in osx, by clicking on stx.app.
+    dir isRootDirectory ifTrue:[
+        exeDir := OperatingSystem nameOfSTXExecutable asFilename directory.
+        dir ~= exeDir ifTrue:[
+            "/ Change it to ~/.smalltalk or is executable directory better?
+
+            "/ use executable dir, as otherwise I'd have to change the VM to include an image path...
+            "/ dir := Filename usersPrivateSmalltalkDirectory.
+            dir := exeDir.
+        ].
+    ].
+    ^ dir
+
+    "
+     self directoryForImageAndChangeFile
+    "
+!
+
 imageBaseName
     "return a reasonable filename to use as baseName (i.e. without extension).
      This is the filename of the current image (without '.img') or,
@@ -5178,24 +5202,8 @@
 initChangeFilename
     "/ make the changeFilePath an absolute one,
     "/ in case some stupid windows fileDialog changes the current directory...
-    |dir exeDir|
-
-    dir := Filename currentDirectory.
-
-    "/ the current directory is not a good idea, if stx is started via a desktop manager
-    "/ or in osx, by clicking on stx.app.
-    exeDir := OperatingSystem nameOfSTXExecutable asFilename directory.
-    dir ~= exeDir ifTrue:[
-        "/ So, change it to ~/.smalltalk
-        "/ or is executable directory better ???
-
-        "/ use executable dir, as otherwise I'd have to change the VM to include an image path...
-        "/ dir := Filename usersPrivateSmalltalkDirectory.
-        dir := exeDir.
-    ].
-
     self
-        nameForChanges:(dir / ObjectMemory nameForChangesLocal)
+        nameForChanges:(self directoryForImageAndChangeFile / ObjectMemory nameForChangesLocal)
                             asAbsoluteFilename pathName
 
     "
@@ -5372,7 +5380,7 @@
      ST-80 compatibility; send #preSnapshot to all classes
     "
     Smalltalk allClassesDo:[:aClass |
-	aClass preSnapshot
+        aClass preSnapshot
     ].
 
     "
@@ -5381,54 +5389,59 @@
      (could be ST/X error or file-system errors etc.)
     "
     snapshotFilename := aFileName asFilename.
+    snapshotFilename isAbsolute ifFalse:[
+        snapshotFilename := self directoryForImageAndChangeFile
+                            / aFileName name.
+    ].
+
     tempFilename := (FileStream newTemporaryIn:snapshotFilename directory)
-			close;
-			fileName.
+                        close;
+                        fileName.
     ok := self primSnapShotOn:tempFilename.
 
     ok ifTrue:[
-	"keep history of one snapshot file"
-	snapshotFilename exists ifTrue:[
-	    tempFilename symbolicAccessRights:snapshotFilename symbolicAccessRights.
-	    snapshotFilename renameTo:(snapshotFilename withSuffix:'sav').
-	] ifFalse:[
-	    "image file hat stx as interpreter and can be executed"
-	    tempFilename makeExecutable.
-	].
-	tempFilename renameTo:snapshotFilename.
-
-	Class addChangeRecordForSnapshot:aFileName.
-
-	setImageName ifTrue:[
-	    oldChangeFile := self nameForChanges.
-	    ImageName := snapshotFilename asAbsoluteFilename asString.
-	    self refreshChangesFrom:oldChangeFile.
-	].
+        "keep history of one snapshot file"
+        snapshotFilename exists ifTrue:[
+            tempFilename symbolicAccessRights:snapshotFilename symbolicAccessRights.
+            snapshotFilename renameTo:(snapshotFilename withSuffix:'sav').
+        ] ifFalse:[
+            "image file hat stx as interpreter and can be executed"
+            tempFilename makeExecutable.
+        ].
+        tempFilename renameTo:snapshotFilename.
+
+        Class addChangeRecordForSnapshot:aFileName.
+
+        setImageName ifTrue:[
+            oldChangeFile := self nameForChanges.
+            ImageName := snapshotFilename asAbsoluteFilename asString.
+            self refreshChangesFrom:oldChangeFile.
+        ].
     ] ifFalse:[
-	tempFilename remove.
+        tempFilename remove.
     ].
 
     "
      ST-80 compatibility; send #postSnapshot to all classes
     "
     Smalltalk allClassesDo:[:aClass |
-	aClass postSnapshot
+        aClass postSnapshot
     ].
     self changed:#finishedSnapshot.  "/ ST-80 compatibility
 
     ok ifFalse:[
-	SnapshotError raise.
-	"not reached"
+        SnapshotError raise.
+        "not reached"
     ].
 
     Transcript
-	show:'Snapshot ';
-	show:snapshotFilename baseName allBold;
-	show:' saved ';
-	show:Timestamp now;
-	show:' in ';
-	show:snapshotFilename asAbsoluteFilename directoryName;
-	showCR:'.'.
+        show:'Snapshot ';
+        show:snapshotFilename baseName allBold;
+        show:' saved ';
+        show:Timestamp now;
+        show:' in ';
+        show:snapshotFilename asAbsoluteFilename directoryName;
+        showCR:'.'.
 
     ^ ok
 
@@ -5591,11 +5604,11 @@
 !ObjectMemory class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.280 2014-06-29 12:36:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.281 2014-06-29 12:46:23 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.280 2014-06-29 12:36:00 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic/ObjectMemory.st,v 1.281 2014-06-29 12:46:23 cg Exp $'
 !
 
 version_SVN