NonPositionableExternalStream.st
changeset 5407 d6729266a95b
parent 4962 0023029d2522
child 5851 6823cc642d60
equal deleted inserted replaced
5406:4a6995b61c0e 5407:d6729266a95b
     7  inclusion of the above copyright notice.   This software may not
     7  inclusion of the above copyright notice.   This software may not
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
       
    12 
       
    13 "{ Package: 'stx:libbasic' }"
    12 
    14 
    13 ExternalStream subclass:#NonPositionableExternalStream
    15 ExternalStream subclass:#NonPositionableExternalStream
    14 	instanceVariableNames:''
    16 	instanceVariableNames:''
    15 	classVariableNames:'StdInStream StdOutStream StdErrorStream'
    17 	classVariableNames:'StdInStream StdOutStream StdErrorStream'
    16 	poolDictionaries:''
    18 	poolDictionaries:''
   240     super storeOn:aStream
   242     super storeOn:aStream
   241 ! !
   243 ! !
   242 
   244 
   243 !NonPositionableExternalStream methodsFor:'private'!
   245 !NonPositionableExternalStream methodsFor:'private'!
   244 
   246 
       
   247 handleForStderr
       
   248     "{ Pragma: +optSpace }"
       
   249 
       
   250     "return a stderr handle"
       
   251 
       
   252 %{
       
   253     RETURN ( __MKOBJ(stderr) );
       
   254 %}
       
   255 !
       
   256 
       
   257 handleForStdin
       
   258     "{ Pragma: +optSpace }"
       
   259 
       
   260     "return a stdin handle"
       
   261 
       
   262 %{
       
   263     RETURN ( __MKOBJ(stdin) );
       
   264 %}
       
   265 !
       
   266 
       
   267 handleForStdout
       
   268     "{ Pragma: +optSpace }"
       
   269 
       
   270     "return a stdout handle"
       
   271 
       
   272 %{
       
   273     RETURN ( __MKOBJ(stdout) );
       
   274 %}
       
   275 !
       
   276 
   245 initializeForStderr
   277 initializeForStderr
   246     "{ Pragma: +optSpace }"
   278     "{ Pragma: +optSpace }"
   247 
   279 
   248     "setup for writing to stderr"
   280     "setup for writing to stderr"
   249 
   281 
   250     mode := #readwrite.
   282     mode := #readwrite.
   251     buffered := false.
   283     buffered := false.
   252 %{
   284     filePointer := self handleForStderr.
   253     OBJ fp;
   285     OperatingSystem isMSWINDOWSlike ifTrue:[
   254 
   286         eolMode := #crlf
   255     __INST(filePointer) = fp = __MKOBJ(stderr); __STORE(self, fp);
   287     ]
   256 #ifdef WIN32
       
   257     __INST(eolMode) = @symbol(crlf);
       
   258 #else
       
   259 # ifdef xxx__VMS__  /* XXX: to be tested */
       
   260     __INST(eolMode) = @symbol(cr);
       
   261 # endif
       
   262 #endif
       
   263 
       
   264 %}
       
   265 !
   288 !
   266 
   289 
   267 initializeForStdin
   290 initializeForStdin
   268     "{ Pragma: +optSpace }"
   291     "{ Pragma: +optSpace }"
   269 
   292 
   270     "setup for reading stdin"
   293     "setup for reading stdin"
   271 
   294 
   272     mode := #readonly.
   295     mode := #readonly.
   273     buffered := true.
   296     buffered := true.
   274 %{
   297     filePointer := self handleForStdin.
   275     OBJ fp;
       
   276 
       
   277     __INST(filePointer) = fp = __MKOBJ(stdin); __STORE(self, fp);
       
   278 %}
       
   279 !
   298 !
   280 
   299 
   281 initializeForStdout
   300 initializeForStdout
   282     "{ Pragma: +optSpace }"
   301     "{ Pragma: +optSpace }"
   283 
   302 
   284     "setup for writing to stdout"
   303     "setup for writing to stdout"
   285 
   304 
   286     mode := #readwrite.
   305     mode := #readwrite.
   287     buffered := false.
   306     buffered := false.
   288 %{
   307     filePointer := self handleForStdout.
   289     OBJ fp;
   308     OperatingSystem isMSWINDOWSlike ifTrue:[
   290 
   309         eolMode := #crlf
   291     __INST(filePointer) = fp = __MKOBJ(stdout); __STORE(self, fp);
   310     ]
   292 #ifdef WIN32
       
   293     __INST(eolMode) = @symbol(crlf);
       
   294 #else
       
   295 # ifdef xxx__VMS__   /* XXX: to be tested */
       
   296     __INST(eolMode) = @symbol(cr);
       
   297 # endif
       
   298 #endif
       
   299 %}
       
   300 !
   311 !
   301 
   312 
   302 reOpen
   313 reOpen
   303     "{ Pragma: +optSpace }"
   314     "{ Pragma: +optSpace }"
   304 
   315 
   316     ].
   327     ].
   317     ^ super reOpen
   328     ^ super reOpen
   318 ! !
   329 ! !
   319 
   330 
   320 !NonPositionableExternalStream methodsFor:'queries'!
   331 !NonPositionableExternalStream methodsFor:'queries'!
   321 
       
   322 isPositionable
       
   323     "return true, if the stream supports positioning (this one is not)"
       
   324 
       
   325     ^ false
       
   326 !
       
   327 
   332 
   328 current
   333 current
   329     "for compatibility with Transcript - allow Transcript current,
   334     "for compatibility with Transcript - allow Transcript current,
   330      even if redirected to the standardError"
   335      even if redirected to the standardError"
   331 
   336 
   332     self == Transcript ifTrue:[
   337     self == Transcript ifTrue:[
   333 	^ self
   338 	^ self
   334     ].
   339     ].
   335     ^ super current
   340     ^ super current
       
   341 !
       
   342 
       
   343 isPositionable
       
   344     "return true, if the stream supports positioning (this one is not)"
       
   345 
       
   346     ^ false
   336 ! !
   347 ! !
   337 
   348 
   338 !NonPositionableExternalStream class methodsFor:'documentation'!
   349 !NonPositionableExternalStream class methodsFor:'documentation'!
   339 
   350 
   340 version
   351 version
   341     ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.38 1999-10-27 23:58:45 stefan Exp $'
   352     ^ '$Header: /cvs/stx/stx/libbasic/NonPositionableExternalStream.st,v 1.39 2000-06-23 08:21:17 cg Exp $'
   342 ! !
   353 ! !