26 lines
886 B
Smalltalk
26 lines
886 B
Smalltalk
accessing
|
|
storeContents
|
|
|
|
| objectString directory tempFile oldFile dehidratated |
|
|
|
|
dehidratated := self copy.
|
|
dehidratated messages: nil.
|
|
objectString := STON toStringPretty: dehidratated.
|
|
directory := self folder ensureCreateDirectory.
|
|
oldFile := directory / 'profile', 'ston'.
|
|
|
|
oldFile exists ifFalse: [
|
|
^ MarkupFile exportAsFileOn: oldFile containing: objectString ].
|
|
|
|
tempFile := MarkupFile
|
|
exportAsFileOn: FileLocator temp / self userName, 'ston'
|
|
containing: objectString.
|
|
|
|
(tempFile contents hash hex = oldFile contents hash hex) ifFalse: [
|
|
oldFile copyTo: directory /
|
|
(oldFile basenameWithoutExtension , '-',
|
|
('-' join:((oldFile creationTime asLocalStringYMDHM) splitOn: ' ')),
|
|
'.ston').
|
|
oldFile ensureDelete.
|
|
^ { 'Profile changed' -> (tempFile moveTo: oldFile)} asDictionary ].
|
|
^ { 'Same Profile' -> oldFile } asDictionary. |