Back: FileSegment-printing Up: Base classes Forward: FileStream class-file-in   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document

1.77 FileStream

Defined in namespace Smalltalk
Superclass: FileDescriptor
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).

1.77.1 FileStream class: file-in  (class)
1.77.2 FileStream class: standard streams  (class)
1.77.3 FileStream: basic  (instance)
1.77.4 FileStream: buffering  (instance)
1.77.5 FileStream: compiling  (instance)
1.77.6 FileStream: initialize-release  (instance)
1.77.7 FileStream: overriding inherited methods  (instance)
1.77.8 FileStream: testing  (instance)


1.77.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 about nested 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


1.77.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.


1.77.3 FileStream: basic

bufferStart
Private - Answer the offset from the start of the file corresponding to the beginning of the read buffer.

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

nextPut: aCharacter
Store aCharacter on the file

peek
Return the next character in the file, or nil at eof. Don't advance the file pointer.

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


1.77.4 FileStream: buffering

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

next: n bufferAll: aCollection startingAt: pos
Private - Assuming that the buffer has space for n characters, store n characters of aCollection in the buffer, starting from the pos-th.

nextAvailable: anInteger into: aCollection startingAt: pos
Read up to anInteger bytes from the stream and store them into aCollection. Return the number of bytes read.

nextAvailable: anInteger putAllOn: aStream
Copy up to anInteger bytes from the stream into aStream. Return the number of bytes read.

pendingWrite
Answer whether the output buffer is full.


1.77.5 FileStream: compiling

segmentFrom: startPos to: endPos
Answer an object that, when sent #asString, will yield the result of sending `copyFrom: startPos to: endPos' to the receiver


1.77.6 FileStream: initialize-release

initialize
Initialize the receiver's instance variables


1.77.7 FileStream: overriding inherited methods

next: n putAll: aCollection startingAt: pos
Write n values from aCollection, the first being at pos.

nextLine
Returns a collection of the same type that the stream accesses, containing the next line up to the next new-line character. Returns the entire rest of the stream's contents if no new-line character is found.

nextPutAllOn: aStream
Put all the characters of the receiver in aStream.

upTo: aCharacter
Returns a collection of the same type that the stream accesses, containing data up to aCharacter. Returns the entire rest of the stream's contents if no such character is found.


1.77.8 FileStream: testing

atEnd
Answer whether data has come to an end



Back: FileStream-overriding inherited methods Up: FileStream Forward: Float   Top: GNU Smalltalk Library Reference Contents: Table of Contents Index: Class index About: About this document


This document was generated on April, 16 2013 using texi2html