[squeak-dev] The Inbox: System-laza.423.mcz
laza at blobworks.com
Tue Feb 22 10:45:30 UTC 2011
I would like to add this to the trunk. This would allow an image running on
linux to read an envVar that points to a central directory of sources files
(see thread ).
On other platforms the environment dictionary is just empty.
This could be easily changed in the future when the VMs on all platforms
might offer a primitive to access the os envVars.
2011/2/22 <commits at source.squeak.org>
> Alexander Lazarević uploaded a new version of System to project The
> ==================== Summary ====================
> Name: System-laza.423
> Author: laza
> Time: 22 February 2011, 11:31:19.136 am
> UUID: 2c296259-64d4-499d-b4b5-9a4046d737fa
> Ancestors: System-ul.422
> Add support for accessing OS environment variables (on linux at first)
> =============== Diff against System-ul.422 ===============
> Item was added:
> + ----- Method: SmalltalkImage>>environ (in category 'os') -----
> + environ
> + "Smalltalk os environ"
> + | env c in match out name |
> + env := IdentityDictionary new.
> + self os osVersion = 'linux' ifFalse: [^env]. "Currently only
> supported on linux"
> + in := FileStream oldFileOrNoneNamed: '/proc/self/environ'.
> + in ifNil: [^env].
> + out := WriteStream on: String new.
> + match := $=.
> + [(c := in next) isNil] whileFalse: [
> + c = match
> + ifTrue: [
> + c = $= ifTrue: [name := out contents. match
> := 0 asCharacter].
> + c = 0 asCharacter ifTrue: [env at: name
> asSymbol put: out contents. match := $=].
> + out reset]
> + ifFalse: [out nextPut: c]].
> + ^env!
> Item was added:
> + ----- Method: SmalltalkImage>>getEnv: (in category 'os') -----
> + getEnv: name
> + "Smalltalk os getEnv: 'HOME'"
> + ^self os environ at: name asSymbol ifAbsent: [nil]
> + !
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Squeak-dev