document files
Ian Piumarta
Ian.Piumarta at inria.fr
Wed Sep 6 16:58:03 UTC 2000
Any chance we could schlurp this (or something similar) into
the standard 2.[89] images? (Otherwise the manual page for
Unix Squeak tells big bad ugly lies w.r.t. document files
and Squeak "scripts".)
Ian
'From Squeak2.8 of 13 June 2000 [latest update: #2359] on 27 August 2000 at 6:53:42 pm'!
"Change Set: UnixDocFile-IKP
Date: 27 August 2000
Author: Ian Piumarta
Discards the first line of a 'document' file in Unix if it begins with '#!!' before filing it in."!
!FileStream methodsFor: 'fileIn/Out' stamp: 'ikp 8/27/2000 18:51'!
discardInterpreterLine
"Skip past the first line if it begins with '#!!'. Needed to support
self-interpreting document files in Unix. ikp 8/27/2000 18:26"
(self next == $# and: [self next == $!!])
ifTrue: [self upTo: Character lf]
ifFalse: [self reset].
^self! !
!SystemDictionary methodsFor: 'snapshot and quit' stamp: 'ikp 8/27/2000 18:44'!
readDocumentFile
"Process system updates. Read a document file, if one was provided. Start application."
| fileName object |
StartupStamp _ '----STARTUP----', Time dateAndTimeNow printString, ' as ', Smalltalk imageName.
self processUpdates.
fileName _ Smalltalk getSystemAttribute: 2.
((fileName ~~ nil) and: [fileName size > 0])
ifTrue: [
(fileName asLowercase beginsWith: 'http://')
ifTrue: [
"fetch remote file"
HTTPSocket httpFileIn: fileName]
ifFalse: [
"read local file"
object _ (FileStream oldFileNamed: fileName)
discardInterpreterLine;
fileInObjectAndCode.
"if launching a .sqo document, send open to the final object"
(fileName endsWith: '.sqo') ifTrue: [object open]]]
ifFalse: [
(Preferences valueOfFlag: #startImagineeringStudio)
ifTrue: [ScriptingSystem openImagineeringStudio]].
! !
More information about the Squeak-dev
mailing list
|