Back: FileSegment-equality
Up: Class reference
Forward: FileStream class-file-in
 
Top: GNU Smalltalk User's Guide
Contents: Table of Contents
Index: Class index
About: About this document

6.69 FileStream

Defined in namespace Smalltalk
Category: Streams-Files
My instances are what conventional programmers think of as files. My instance creation methods accept the name of a disk file (or any named file object, such as /dev/rmt0 on UNIX or MTA0: on VMS).

6.69.1 FileStream class: file-in  (class)
6.69.2 FileStream class: standard streams  (class)
6.69.3 FileStream: basic  (instance)
6.69.4 FileStream: buffering  (instance)
6.69.5 FileStream: filing in  (instance)
6.69.6 FileStream: overriding inherited methods  (instance)
6.69.7 FileStream: testing  (instance)


6.69.1 FileStream class: file-in

fileIn: aFileName
File in the aFileName file. During a file in operation, global variables (starting with an uppercase letter) that are not declared yet don't yield an `unknown variable' error. Instead, they are defined as nil in the `Undeclared' dictionary (a global variable residing in Smalltalk). As soon as you add the variable to a namespace (for example by creating a class) the Association will be removed from Undeclared and reused in the namespace, so that the old references will automagically point to the new value.

fileIn: aFileName ifMissing: aSymbol
Conditionally do a file in, only if the key (often a class) specified by 'aSymbol' is not present in the Smalltalk system dictionary already. During a file in operation, global variables (starting with an uppercase letter) that are not declared don't yield an `unknown variable' error. Instead, they are defined as nil in the `Undeclared' dictionary (a global variable residing in Smalltalk). As soon as you add the variable to a namespace (for example by creating a class) the Association will be removed from Undeclared and reused in the namespace, so that the old references will automagically point to the new value.

fileIn: aFileName ifTrue: aBoolean
Conditionally do a file in, only if the supplied boolean is true. During a file in operation, global variables (starting with an uppercase letter) that are not declared don't yield an `unknown variable' error. Instead, they are defined as nil in the `Undeclared' dictionary (a global variable residing in Smalltalk). As soon as you add the variable to a namespace (for example by creating a class) the Association will be removed from Undeclared and reused in the namespace, so that the old references will automagically point to the new value.

fileIn: aFileName line: lineInteger from: realFileName at: aCharPos
File in the aFileName file giving errors such as if it was loaded from the given line, file name and starting position (instead of 1).

generateMakefileOnto: aStream
Generate a make file for the file-ins since record was last set to true. Store it on aStream

initialize
Private - Initialize the receiver's class variables

record: recordFlag
Set whether Smalltalk should record information aboutnested file-ins. When recording is enabled, use #generateMakefileOnto: to automatically generate a valid makefile for the intervening file-ins.

require: assoc
Conditionally do a file in from the value of assoc, only if the key of assoc is not present in the Smalltalk system dictionary already. During a file in operation, global variables (starting with an uppercase letter) that are not declared don't yield an `unknown variable' error. Instead, they are defined as nil in the `Undeclared' dictionary (a global variable residing in Smalltalk). As soon as you add the variable to a namespace (for example by creating a class) the Association will be removed from Undeclared and reused in the namespace, so that the old references will automagically point to the new value.

verbose: verboseFlag
Set whether Smalltalk should output debugging messages when filing in


6.69.2 FileStream class: standard streams

stderr
Answer a FileStream that is attached the Smalltalk program's standard error file handle, which can be used for error messages and diagnostics issued by the program.

stdin
Answer a FileStream that is attached the Smalltalk program's standard input file handle, which is the normal source of input for the program.

stdout
Answer a FileStream that is attached the Smalltalk program's standard output file handle; this is used for normal output from the program.


6.69.3 FileStream: basic

copyFrom: from to: to
Answer the contents of the file between the two given positions

next
Return the next character in the file, or nil at eof

nextByte
Return the next byte in the file, or nil at eof

nextPut: aCharacter
Store aCharacter on the file

nextPutByte: anInteger
Store the byte, anInteger, on the file

nextPutByteArray: aByteArray
Store aByteArray on the file

position
Answer the zero-based position from the start of the file

position: n
Set the file pointer to the zero-based position n

size
Return the current size of the file, in bytes

truncate
Truncate the file at the current position


6.69.4 FileStream: buffering

basicFlush
Private - Flush the output buffer, fail if it is empty

bufferSize
Answer the file's current buffer

bufferSize: bufSize
Flush the file and set the buffer's size to bufSize

clean
Synchronize the file descriptor's state with the object's state.

fill
Private - Fill the input buffer

flush
Flush the output buffer

newBuffer
Private - Answer a String to be used as the receiver's buffer

nextHunk
Answer the next buffers worth of stuff in the Stream represented by the receiver. Do at most one actual input operation.

pendingWrite
Answer whether the output buffer is full


6.69.5 FileStream: filing in

fileIn
File in the contents of the receiver. During a file in operation, global variables (starting with an uppercase letter) that are not declared don't yield an `unknown variable' error. Instead, they are defined as nil in the `Undeclared' dictionary (a global variable residing in Smalltalk). As soon as you add the variable to a namespace (for example by creating a class) the Association will be removed from Undeclared and reused in the namespace, so that the old references will automagically point to the new value.

fileInLine: lineNum fileName: aString at: charPosInt
Private - Much like a preprocessor #line directive; it is used by the Emacs Smalltalk mode.


6.69.6 FileStream: overriding inherited methods

next: anInteger
Return the next 'anInteger' characters from the stream, as a String.

nextByteArray: anInteger
Return the next 'anInteger' bytes from the stream, as a ByteArray.

nextPutAll: aCollection
Put all the characters in aCollection in the file

nextPutAllFlush: aCollection
Put all the characters in aCollection in the file, then flush the file buffers


6.69.7 FileStream: testing

atEnd
Answer whether data has come to an end




This document was generated on May, 12 2002 using texi2html