Squeak Class Documentation category index | class index  
 
StandardFileStream
  category: System-Files
  superclass: FileStream
  subclasses: CrLfFileStream

Provides a simple, platform-independent, interface to a file system. This initial version ignores issues of Directories etc. The instance-variable fallbackStream at the moment holds an instance of HFSMacFileStream, to bridge us to the new world while in the old. The instance variable rwmode, inherited from class PositionableStream, here is used to hold a Boolean -- true means opened for read-write, false means opened for read-only. 2/12/96 sw

instance methods
  access
  directory
directoryUrl
file
fullName
isDirectory
localName
name
peekFor:
printOn:
reset
size

  browser requests
  defaultBrowserReadyWait
post:target:url:ifError:
post:url:ifError:
primBrowserReady
primURLPost:data:semaIndex:
primURLPost:target:data:semaIndex:
primURLRequest:semaIndex:
primURLRequest:target:semaIndex:
primURLRequestDestroy:
primURLRequestFileHandle:
primURLRequestState:
requestURL:target:
requestURL:target:ifError:
requestURLStream:
requestURLStream:ifError:
waitBrowserReadyFor:ifFail:

  dnd requests
  primDropRequestFileHandle:
primDropRequestFileName:
requestDropStream:

  finalization
  actAsExecutor
finalize

  open/close
  close
closed
ensureOpen
open
open:forWrite:
openReadOnly
reopen

  primitives
  primAtEnd:
primClose:
primCloseNoError:
primFlush:
primGetPosition:
primOpen:writable:
primRead:into:startingAt:count:
primSetPosition:to:
primSize:
primSizeNoError:
primTruncate:to:
primWrite:from:startingAt:count:

  properties-setting
  asHtml
ascii
binary
getFileType
insertLineFeeds
isBinary
isReadOnly
readOnly
readWrite
setFileTypeToObject

  read, write, position
  atEnd
basicNext
compressFile
flush
next
next:
next:into:startingAt:
next:putAll:startingAt:
nextPut:
nextPutAll:
nextWordsInto:
nextWordsPutAll:
padToEndWith:
peek
peekLast
position
position:
readInto:startingAt:count:
readOnlyCopy
setToEnd
skip:
truncate
truncate:
upTo:
upToEnd
verbatim:

  registry
  register
unregister

class methods
  browser requests
  isRunningAsBrowserPlugin
privateCheckForBrowserPrimitives

  error handling
  fileDoesNotExistUserHandling:
fileExistsUserHandling:
readOnlyFileDoesNotExistUserHandling:

  file creation
  fileNamed:
forceNewFileNamed:
isAFileNamed:
newFileNamed:
oldFileNamed:
readOnlyFileNamed:

  registry
  register:
registry
unregister:

instance methods
  access top  
 

directory

Return the directory containing this file.


 

directoryUrl


 

file

Answer the object representing the receiver's file. Need for compatibility with some calls -- check senders. 2/14/96 sw


 

fullName

Answer this file's full path name.


 

isDirectory

Answer whether the receiver represents a directory. For the post-transition case, uncertain what to do. 2/14/96 sw


 

localName


 

name

Answer this file's full path name.


 

peekFor:

Answer false and do not advance if the next element is not equal to item, or if this stream is at the end. If the next element is equal to item, then advance over it and return true


 

printOn:

Put a printed version of the receiver onto aStream. 1/31/96 sw


 

reset

Set the current character position to the beginning of the file.
1/31/96 sw: subclassResponsibility


 

size

Answer the size of the file in characters. 2/12/96 sw


  browser requests top  
 

defaultBrowserReadyWait


 

post:target:url:ifError:

Post data to the given URL. The returned file stream contains the reply of the server.
If Squeak is not running in a browser evaluate errorBlock


 

post:url:ifError:


 

primBrowserReady


 

primURLPost:data:semaIndex:


 

primURLPost:target:data:semaIndex:

Post the data (url might be 'mailto:' etc)


 

primURLRequest:semaIndex:


 

primURLRequest:target:semaIndex:

target - String (frame, also '_top', '_parent' etc)


 

primURLRequestDestroy:


 

primURLRequestFileHandle:


 

primURLRequestState:


 

requestURL:target:


 

requestURL:target:ifError:

Request to go to the target for the given URL.
If Squeak is not running in a browser evaluate errorBlock


 

requestURLStream:

FileStream requestURLStream:'http://www.squeak.org'


 

requestURLStream:ifError:

Request a FileStream for the given URL.
If Squeak is not running in a browser evaluate errorBlock


 

waitBrowserReadyFor:ifFail:


  dnd requests top  
 

primDropRequestFileHandle:

Primitive. Return the (read-only) file handle for some file that was just dropped onto Squeak.
Fail if dropIndex is out of range or the primitive is not supported.


 

primDropRequestFileName:

Primitive. Return the file name for some file that was just dropped onto Squeak.
Fail if dropIndex is out of range or the primitive is not supported.


 

requestDropStream:

Return a read-only stream for some file the user has just dropped onto Squeak.


  finalization top  
 

actAsExecutor

Prepare the receiver to act as executor for any resources associated with it


 

finalize

Finalize the resource associated with the receiver. This message should only be sent during the finalization process. There is NO garantuee that the resource associated with the receiver hasn't been free'd before so take care that you don't run into trouble - this all may happen with interrupt priority.


  open/close top  
 

close

Close this file.


 

closed

Answer true if this file is closed.


 

ensureOpen

Make sure that this file really is open.


 

open

For compatibility with a few existing things. 2/14/96 sw


 

open:forWrite:

Open the file with the given name. If writeMode is true, allow writing, otherwise open the file in read-only mode.


 

openReadOnly

Open the receiver as a read-only file. 1/31/96 sw


 

reopen

Close and reopen this file. The file position is reset to zero.


  primitives top  
 

primAtEnd:

Answer true if the file position is at the end of the file.


 

primClose:

Close this file.


 

primCloseNoError:

Close this file. Don't raise an error if the primitive fails.


 

primFlush:

Flush pending changes to the disk


 

primGetPosition:

Get this files current position.


 

primOpen:writable:

Open a file of the given name, and return the file ID obtained.
If writableFlag is true, then
if there is none with this name, then create one
else prepare to overwrite the existing from the beginning
otherwise
if the file exists, open it read-only
else return nil


 

primRead:into:startingAt:count:

Read up to count bytes of data from this file into the given string or byte array starting at the given index. Answer the number of bytes actually read.


 

primSetPosition:to:

Set this file to the given position.


 

primSize:

Answer the size of this file.


 

primSizeNoError:

Answer the size of this file. Answer nil if the primitive fails; this indicates that the file handle has become stale.


 

primTruncate:to:

Truncate this file to the given position.


 

primWrite:from:startingAt:count:

Write count bytes onto this file from the given string or byte array starting at the given index. Answer the number of bytes written.


  properties-setting top  
 

asHtml

Convert me in to an HtmlFileStream. 4/11/96 tk


 

ascii

opposite of binary


 

binary

Set this file to binary mode.


 

getFileType

On the Macintosh, get the file type and creator of this file. On other platforms, do nothing.


 

insertLineFeeds

(FileStream oldFileNamed: 'BBfix2.st') insertLineFeeds


 

isBinary

Return true if the receiver is a binary byte stream


 

isReadOnly


 

readOnly

Make this file read-only.


 

readWrite

Make this file writable.


 

setFileTypeToObject

On the Macintosh, set the file type and creator of this file to be a Squeak object file. On other platforms, do nothing. Setting the file type allows Squeak object files to be sent as email attachments and launched by double-clicking. On other platforms, similar behavior is achieved by creating the file with the '.sqo' file name extension.


  read, write, position top  
 

atEnd

Answer whether the receiver is at its end.


 

basicNext

Answer the next byte from this file, or nil if at the end of the file.


 

compressFile

Write a new file that has the data in me compressed in GZip format.


 

flush

Flush pending changes


 

next

Answer the next byte from this file, or nil if at the end of the file.


 

next:

Return a string with the next n characters of the filestream in it. 1/31/96 sw


 

next:into:startingAt:

Read n bytes into the given string.
Return aString or a partial copy if less than
n elements have been read.


 

next:putAll:startingAt:

Store the next anInteger elements from the given collection.


 

nextPut:

Write the given character to this file.


 

nextPutAll:

Write all the characters of the given string to this file.


 

nextWordsInto:

Note: The file primitives automatically adjust for word based objects.


 

nextWordsPutAll:

Write the argument a word-like object in big endian format on the receiver.
May be used to write other than plain word-like objects (such as ColorArray).


 

padToEndWith:

On the Mac, files do not truncate. One can delete the old file and write a new one, but sometime deletion fails (file still open? file stale?). This is a sad compromise. Just let the file be the same length but pad it with a harmless character.


 

peek

Answer what would be returned if the message next were sent to the receiver. If the receiver is at the end, answer nil.


 

peekLast

Return that item just put at the end of the stream


 

position

Return the receiver's current file position. 2/12/96 sw


 

position:

Set the receiver's position as indicated. 2/12/96 sw


 

readInto:startingAt:count:

Read into the given array as specified, and return the count
actually transferred. index and count are in units of bytes or
longs depending on whether the array is Bitmap, String or ByteArray


 

readOnlyCopy


 

setToEnd

Set the position of the receiver to the end of file. 1/31/96 sw


 

skip:

Set the character position to n characters from the current position.
Error if not enough characters left in the file. 1/31/96 sw


 

truncate

Truncate to zero


 

truncate:

Truncate to this position


 

upTo:

Fast version to speed up nextChunk


 

upToEnd

Answer a subcollection from the current access position through the last element of the receiver.


 

verbatim:

A version of nextPutAll that can be called knowing it won't call nextPut:


  registry top  
 

register


 

unregister


class methods
  browser requests top  
 

isRunningAsBrowserPlugin


 

privateCheckForBrowserPrimitives


  error handling top  
 

fileDoesNotExistUserHandling:


 

fileExistsUserHandling:


 

readOnlyFileDoesNotExistUserHandling:


  file creation top  
 

fileNamed:

Open a file with the given name for reading and writing. If the name has no directory part, then the file will be created in the default directory. If the file already exists, its prior contents may be modified or replaced, but the file will not be truncated on close.


 

forceNewFileNamed:

Create a new file with the given name, and answer a stream opened for writing on that file. If the file already exists, delete it without asking before creating the new file.


 

isAFileNamed:

Answer true if a file of the given name exists.


 

newFileNamed:

Create a new file with the given name, and answer a stream opened for writing on that file. If the file already exists, ask the user what to do.


 

oldFileNamed:

Open an existing file with the given name for reading and writing. If the name has no directory part, then the file will be created in the default directory. If the file already exists, its prior contents may be modified or replaced, but the file will not be truncated on close.


 

readOnlyFileNamed:

Open an existing file with the given name for reading.


  registry top  
 

register:


 

registry


 

unregister: