[UNIX][VM][CSOTD] config file (was: Re: SerialPort cross-platform question...)

David T. Lewis lewis at mail.msen.com
Wed Feb 27 13:12:14 UTC 2002


On Wed, Feb 27, 2002 at 07:19:34AM -0500, David T. Lewis wrote:
> On Wed, Feb 27, 2002 at 12:35:52PM +0100, Bert Freudenberg wrote:
> > 
> > OTOH, a config file would be nice, indeed. How about "/etc/squeakrc", 
> > overridable by a "$(HOME)/.squeakrc"? Or, do we want to have a 
> > "$(HOME)/.squeak/" directory?
> 
> For consistency, it would be "/etc/squeak.conf", overridable
> by "$(HOME)/.squeakrc". Unfortunately, a small amount of VM support
> would be needed, as Squeak does not currently know the location of
> the $(HOME) directory. This could be added in the form of one new
> primitive (primitiveUserHomePath). If the primitive was not there,
> then primUserHomeHomePath would answer the Squeak home as a default
> (FileDirectory default pathName). This would be sufficient to permit
> everything else to be implemented in Smalltalk, hopefully in a
> way that works well for non-Unix platforms also.

Here's the code, in case anyone wants to try it. I am not going to put
this into OSProcess, because the equivalent function already exists in the
form of "OSProcess thisOSProcess environment at: #HOME".

<CSOTD>
primUserHome
	<primitive: 'primitiveUserHome' module: 'WhateverPluginYouPutItIn'>
	^ FileDirectory default pathName

primitiveUserHome
	"Answer the value of the $HOME environment variable."
	| sPtr getenvResult len s idx |
	self export: true.
	self var: 'getenvResult' declareC: 'char * getenvResult'.
	self var: 'sPtr' declareC: 'char *sPtr'.
	getenvResult _ self getenv: 'HOME'.	
	(getenvResult = 0) ifTrue: [^ interpreterProxy primitiveFail].
	len _ self strlen: getenvResult.
	s _ interpreterProxy
		instantiateClass: interpreterProxy classString
		indexableSize: len.
	sPtr _ interpreterProxy arrayValueOf: s.
	idx _ 0.
	[idx < len] whileTrue:
		[sPtr at: idx put: (getenvResult at: idx).
		idx _ idx + 1].
	interpreterProxy pop: 1 thenPush: s
</CSOTD>




More information about the Squeak-dev mailing list