Browse files

I've noticed that when files become shorter in length, the last bit o…

…f the previous version of the file stays. Deleting the file before we write ensures we never leave trailing junk.
  • Loading branch information...
1 parent dbff962 commit 44da211a5a734cc99c36816e8e14f21c80b4d6e4 @frankshearar frankshearar committed Dec 23, 2012
Showing with 2 additions and 0 deletions.
  1. +2 −0 Core/
2 Core/
@@ -87,6 +87,8 @@ writeSourceCodeFrom: aStream to: aFile
ifTrue: [converter := MacRomanTextConverter new]
ifFalse: [converter := UTF8TextConverter new].
fileName := aFile, (FileDirectory dot, 'st').
+ "If the new version of the file is shorter than the current version, deleting the file means we won't leave trailing rubbish from the old version."
+ FileDirectory deleteFilePath: fileName.
f := MultiByteFileStream new open: fileName forWrite: true.
f ifNil: [^ self error: 'Cannot open file'].
f lineEndConvention: #lf.

0 comments on commit 44da211

Please sign in to comment.