[GOODIE] Save image with check for corrupt files on restart

David T. Lewis lewis at mail.msen.com
Sat Feb 5 19:14:23 UTC 2000


There has been plenty of discussion about Squeak files which get
corrupted download or archive programs, to the great annoyance and
confusion of new Squeak users.

While we are waiting for an elegant solution, I offer the following
unlovely hack in the interest of protecting newbie Squeakers.

Utilies>>quitWithRestartFilecheck will save the image and do a
check of the changes and sources files when the image is next
restarted. If either file appears to have its line terminators
changed, a notifier is presented to the user explaining the problem.

Tested only on Linux so far.

Dave

-------------- next part --------------
'From Squeak2.7 of 5 January 2000 [latest update: #1762] on 5 February 2000 at 1:25:53 pm'!
"Change Set:		Utilities-FileFormatCheck
Date:			5 February 2000
Author:			David T. Lewis

Save the image in such a way that the changes and sources files are checked
on image restart. Warn the user if files have been accidentally converted
to ''text'' format."!


!Utilities class methodsFor: 'miscellaneous' stamp: 'dtl 2/5/2000 13:25'!
quitWithRestartFilecheck
	"Some new users of Squeak have trouble starting the system after 
	downloading it. Frequently this is due to inadvertently converting 
	the changes file or sources file to a text format with a different line 
	terminator convention. This method attempts to give the new user an 
	informative notifier if the problem is detected. It is intended for use 
	in preparing an image and changes file set for general distribution."

	"Utilities quitWithRestartFilecheck"

	| sourceFileSize sourcePosition sourceSample changeFileSize changePosi!
!
tion
	changeSample newSourceSample newChangeSample sourceOK changeOK |
	Smalltalk snapshot: true andQuit: false.
	sourceFileSize _ (SourceFiles at: 1) size.
	sourcePosition _ (SourceFiles at: 1) position.
	sourceSample _ (SourceFiles at: 1) position: (sourceFileSize - 2000);
			 next: 1000.
	(SourceFiles at: 1) position: sourcePosition.
	changeFileSize _ (SourceFiles at: 2) size.
	changePosition _ (SourceFiles at: 2) position.
	changeSample _ (SourceFiles at: 2) position: (changeFileSize - 2000);
			 next: 1000.
	(SourceFiles at: 2) position: changePosition.
	Smalltalk snapshot: true andQuit: true.
	sourcePosition _ (SourceFiles at: 1) position.
	newSourceSample _ (SourceFiles at: 1) position: (sourceFileSize - 2000);
			 next: 1000.
	(SourceFiles at: 1) position: sourcePosition.
	changePosition _ (SourceFiles at: 2) position.
	newChangeSample _ (SourceFiles at: 2) position: changeFileSize - 2000;
			 next: 1000.
	(SourceFiles at: 2) position: changePosition.
	sourceOK _ newSo!
!
urceSample = sourceSample.
	changeOK _ newChangeSample = changeSample.
	sourceOK & changeOK ifFalse: [nil notify:
		'Warning: The changes and sources files do not seem to match ',
		'this Squeak image. If you are starting Squeak for the first ',
		'time, please ensure that you have downloaded these files as ',
		'binary files. Some file transfer and archive programs will ',
		'incorrectly attempt to convert Squeak files to "text" or "Ascii" ',
		'files. Squeak cannot function with files which have been ',
		'converted in this way.']! !


More information about the Squeak-dev mailing list