#FEATURE
authorClaus Gittinger <cg@exept.de>
Wed, 28 Oct 2015 18:49:09 +0100
changeset 18870 cae2dba046a1
parent 18869 6e750f31f326
child 18871 8ba61705c02e
#FEATURE class: ObjectMemory added: #nameForSnapshotLocal changed: #nameForChanges #nameForSnapshot also consult the userPrefs for a workspace directory
ObjectMemory.st
--- a/ObjectMemory.st	Wed Oct 28 18:31:21 2015 +0100
+++ b/ObjectMemory.st	Wed Oct 28 18:49:09 2015 +0100
@@ -5565,13 +5565,23 @@
      by '.chg', or, if not running from an image, the default name 'st.chg'.
      However, it can be overwritten via the nameForChanges: setter"
 
-    |nm|
-
-    (nm := UserPreferences current changeFileName) notNil ifTrue:[
-	^ nm
+    |userPrefs localName nm wd|
+
+    localName := self nameForChangesLocal.
+    userPrefs := UserPreferences current.
+    
+    "/ if the prefs provide a full, explicit name
+    (nm := userPrefs changeFileName) notNil ifTrue:[ ^ nm ].
+
+    "/ if there is a workspace, create it there
+    ((wd := userPrefs workspaceDirectory) notNil and:[wd exists]) ifTrue:[
+        ^ wd / (localName asFilename baseName)
     ].
+
+    "/ if it was set by a startup file
     ChangeFileName notNil ifTrue:[^ ChangeFileName].
-    ^ self nameForChangesLocal
+    "/ finally, fall back to a default.
+    ^ localName
 
     "
      ObjectMemory nameForChanges
@@ -5617,6 +5627,26 @@
      This is the filename of the current image or,
      if not running from an image, the default name 'st.img'"
 
+    |localName wd|
+
+    localName := self nameForSnapshotLocal.
+    
+    "/ if there is a workspace, create it there
+    ((wd := UserPreferences current workspaceDirectory) notNil and:[wd exists]) ifTrue:[
+        ^ wd / (localName asFilename baseName)
+    ].
+    ^ localName
+
+    "
+     ObjectMemory nameForSnapshot
+    "
+!
+
+nameForSnapshotLocal
+    "return a reasonable filename to store the snapshot image into.
+     This is the filename of the current image or,
+     if not running from an image, the default name 'st.img'"
+
     ^ self imageBaseName , '.', self suffixForSnapshot
 
     "