'From Squeak3.1alpha of 4 February 2001 [latest update: #3780] on 5 March 2001 at 1:58:44 am'! "Change Set: EHWorkarounds-ar Date: 5 March 2001 Author: Andreas Raab An assorted list of workarounds for methods using the broken EH behavior."! !ClassBuilder methodsFor: 'private' stamp: 'ar 3/5/2001 01:57'! hasPrimitiveChangeClassTo "Return true if #primitiveChangeClassTo is supported" ^(self tryPrimitiveChangeClassTo: self clone) notNil! ! !ClassBuilder methodsFor: 'private' stamp: 'ar 3/5/2001 01:56'! tryPrimitiveChangeClassTo: myClone ^nil! ! !Form methodsFor: 'resources' stamp: 'ar 3/5/2001 01:53'! readNativeResourceFrom: aStream | img | img _ [ImageReadWriter formFromStream: aStream] on: Error do:[:ex| nil]. img ifNil:[^nil]. "Forget color map if any" img _ Form extent: img extent depth: img depth bits: img bits. img displayInterpolatedOn: self. img _ nil.! ! !ResourceManager class methodsFor: 'resource caching' stamp: 'ar 3/5/2001 01:54'! cacheResource: urlString stream: aStream | fd localName file buf | HTTPClient isRunningInBrowser ifTrue:[^self]. "use browser cache" fd _ Project squeakletDirectory. localName _ fd nextNameFor: 'resource' extension:'cache'. file _ fd forceNewFileNamed: localName. buf _ String new: 10000. [aStream atEnd] whileFalse:[ buf _ aStream next: buf size into: buf. file nextPutAll: buf. ]. file close. "update cache" file _ [fd oldFileNamed: self resourceCacheName] on: FileDoesNotExistException do:[:ex| fd forceNewFileNamed: self resourceCacheName]. file setToEnd. file nextPutAll: urlString; cr. file nextPutAll: localName; cr. file close. CachedResources at: urlString put: (fd fullNameFor: localName). aStream position: 0. ! ! !ResourceManager class methodsFor: 'resource caching' stamp: 'ar 3/5/2001 01:54'! lookupCachedResource: urlString ifPresentDo: streamBlock "See if we have cached the resource described by the given url and if so, evaluate streamBlock with the cached resource." | fileName file | CachedResources ifNil:[^self]. fileName _ CachedResources at: urlString ifAbsent:[nil]. fileName ifNil:[^self]. file _ [FileStream readOnlyFileNamed: fileName] on: FileDoesNotExistException do:[:ex| nil]. file ifNil:[^self]. [streamBlock value: file] ensure:[file close]. ! ! !ResourceManager class methodsFor: 'resource caching' stamp: 'ar 3/5/2001 01:55'! reloadCachedResources "ResourceManager reloadCachedResources" "Reload cached resources from the disk" | fd files stream url localName storeBack | HTTPClient isRunningInBrowser ifTrue:[^CachedResources _ nil]. "use browser cache" CachedResources _ Dictionary new. fd _ Project squeakletDirectory. files _ fd fileNames asSet. stream _ [fd readOnlyFileNamed: self resourceCacheName] on: FileDoesNotExistException do:[:ex| fd forceNewFileNamed: self resourceCacheName]. stream size < 50000 ifTrue:[stream _ ReadStream on: stream contentsOfEntireFile]. storeBack _ false. [stream atEnd] whileFalse:[ url _ stream upTo: Character cr. localName _ stream upTo: Character cr. (files includes: localName) ifTrue:[CachedResources at: url put: (fd fullNameFor: localName)] ifFalse:[storeBack _ true]]. (stream respondsTo: #close) ifTrue:[stream close]. storeBack ifTrue:[ stream _ fd forceNewFileNamed: self resourceCacheName. CachedResources keysAndValuesDo:[:urlString :fullName| stream nextPutAll: urlString; cr. stream nextPutAll: (fd localNameFor: fullName); cr. ]. stream close. ].! ! !SecurityManager methodsFor: 'fileIn/out' stamp: 'ar 3/5/2001 01:55'! loadSecurityKeys "SecurityManager default loadSecurityKeys" "Load the keys file for the current user" | fd loc file keys | self isInRestrictedMode ifTrue:[^self]. "no point in even trying" loc _ self secureUserDirectory. "where to get it from" loc last = FileDirectory pathNameDelimiter ifFalse:[ loc _ loc copyWith: FileDirectory pathNameDelimiter. ]. fd _ FileDirectory on: loc. file _ [fd readOnlyFileNamed: keysFileName] on: FileDoesNotExistException do:[:ex| nil]. file ifNil:[^self]. "no keys file" keys _ Object readFrom: file. privateKeyPair _ keys first. trustedKeys _ keys last. file close.! ! !Utilities class methodsFor: 'miscellaneous' stamp: 'ar 3/5/2001 01:55'! timeStampForMethod: method "Answer the authoring time-stamp for the given method, retrieved from the sources or changes file. Answer the empty string if no time stamp is available." | position file preamble stamp tokens tokenCount | method fileIndex == 0 ifTrue: [^ String new]. "no source pointer for this method" position _ method filePosition. file _ SourceFiles at: method fileIndex. file ifNil: [^ String new]. "sources file not available" "file does not exist happens in secure mode" file _ [file readOnlyCopy] on: FileDoesNotExistException do:[:ex| nil]. file ifNil: [^ String new]. file position: (0 max: position - 150). "Skip back to before the preamble" [file position < (position - 1)] "then pick it up from the front" whileTrue: [preamble _ file nextChunk]. stamp _ String new. tokens _ (preamble findString: 'methodsFor:' startingAt: 1) > 0 ifTrue: [Scanner new scanTokens: preamble] ifFalse: [Array new "ie cant be back ref"]. (((tokenCount _ tokens size) between: 7 and: 8) and: [(tokens at: tokenCount - 5) = #methodsFor:]) ifTrue: [(tokens at: tokenCount - 3) = #stamp: ifTrue: ["New format gives change stamp and unified prior pointer" stamp _ tokens at: tokenCount - 2]]. ((tokenCount between: 5 and: 6) and: [(tokens at: tokenCount - 3) = #methodsFor:]) ifTrue: [(tokens at: tokenCount - 1) = #stamp: ifTrue: ["New format gives change stamp and unified prior pointer" stamp _ tokens at: tokenCount]]. file close. ^ stamp! !