[squeak-dev] Compressed sources

David T. Lewis lewis at mail.msen.com
Thu Jan 14 03:40:15 UTC 2010


On Wed, Jan 13, 2010 at 09:54:34PM -0500, David T. Lewis wrote:
> On Wed, Jan 13, 2010 at 11:59:01PM +0100, Bert Freudenberg wrote:
> > On 13.01.2010, at 23:51, Eliot Miranda wrote:
> > > 
> > > On Wed, Jan 13, 2010 at 2:35 PM, Bert Freudenberg <bert at freudenbergs.de> wrote:
> > > > I seem to remember a hack that allowed the sources file to be compressed on disk.
> > > > It would be uncompressed on-the-fly. Does someone remember that hack? I couldn't find it.
> > > 
> > > CompressedSourceStream & SystemDictionary>>compressSources is in our 3.8 derived Teleplace images.
> > 
> > Ah, great, thanks! Scott also pointed me to this:
> > 
> > http://wiki.squeak.org/squeak/3510
> 
> The necessary support has somehow survived in Squeak trunk as well,
> see also FileDirectory class>>openSources:forImage:
> 
> #compressSources encounters an error in trunk, but a little bit of fiddling
> around would probably get it working.
> 
> It looks like you just need to write a compressed EtoysV3.sources.stc
> file using #compressSources, and it might just work :)

Attached .cs is all that is required to produce a compressed sources
file that seems to work correctly on a 3.8 image. It does *not* produce
a usable compressed sources file on a Squeak trunk image, but that can
be a problem for another day.

I would spend a few minutes browsing source code to make sure nothing
is broken, but at first blush it seems fine.

All I had to do is 'Smalltalk compressSources', quit the image, delete
the normal sources file, restart the image, and viola it was using
the compressed SqueakV3.stc file instead of SqueakV3.sources.

Dave
 
-------------- next part --------------
'From Squeak3.11alpha of 9 January 2010 [latest update: #8835] on 13 January 2010 at 10:08:13 pm'!
"Change Set:		SystemDictionary-compressSources-patch-dtl
Date:			13 January 2010
Author:			David T. Lewis

Make #compressSources work on newer Squeak images"!


!SystemDictionary methodsFor: 'housekeeping' stamp: 'dtl 1/13/2010 22:00'!
compressSources	
	"Copy all the source file to a compressed file. Usually preceded by Smalltalk condenseSources."
	"The new file will be created in the default directory, and the code in openSources
	will try to open it if it is there, otherwise it will look for normal sources."
	"Smalltalk compressSources"

	| f cfName cf sourcesName |
	f := SourceFiles first.
	sourcesName := (SourceFiles at: 1) name.
	(sourcesName endsWith: 'sources')
		ifTrue: [cfName := (sourcesName allButLast: 7) , 'stc']
		ifFalse: [self error: 'Hey, I thought the sources name ended with ''.sources''.'].
	cf := (CompressedSourceStream on: (FileStream newFileNamed: cfName))
				segmentSize: 20000 maxSize: f size.

	"Copy the sources"
'Compressing Sources File...'
	displayProgressAt: Sensor cursorPoint
	from: 0 to: f size
	during:
		[:bar | f position: 0.
		[f atEnd] whileFalse:
			[cf nextPutAll: (f next: 20000).
			bar value: f position]].
	cf close.
	self setMacFileInfoOn: cfName.
	self inform: 'You now have a compressed sources file!!
Squeak will use it the next time you start.'! !



More information about the Squeak-dev mailing list