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

I represent a Stream that accesses a FilePage from a File. One use for my instance is to access larger "virtual Strings" than can be stored contiguously in main memory. I restrict the objects stored and retrieved to be Integers or Characters. An end of file pointer terminates reading; it can be extended by writing past it, or the file can be explicitly truncated.

To use the file system for most applications, you typically create a FileStream. This is done by sending a message to a FileDirectory (file:, oldFile:, newFile:, rename:newName:) which creates an instance of me. Accesses to the file are then done via my instance.

*** On DOS, files cannot be shortened! *** To overwrite a file with a shorter one, first delete the old file (FileDirectory deleteFilePath: 'Hard Disk:aFolder:dataFolder:foo') or (aFileDirectory deleteFileNamed: 'foo'). Then write your new shorter version.

instance methods
  accessing
  contents
contentsOfEntireFile
directoryEntry
mimeTypes
next
next:
nextPut:
nextPutAll:
size

  converting
  asBinaryOrTextStream

  editing
  edit
viewGZipContents

  file accessing
  file
localName
name
url

  file modes
  ascii
binary
readOnly
readWrite
text

  file open/close
  close
closed
flush
reopen

  fileIn/Out
  fileIn
fileInObjectAndCode
fileIntoNewChangeSet

  positioning
  position
position:
reset
setToEnd
skip:
truncate:

  printing
  longPrintOn:
longPrintOn:limitedTo:indent:
printOn:

  remote file compatibility
  dataIsValid

  testing
  atEnd

class methods
  browser requests
  httpPostDocument:args:
httpPostMultipart:args:
post:target:url:ifError:
post:url:ifError:
requestURL:target:
requestURLStream:
requestURLStream:ifError:

  concrete classes
  concreteStream

  dnd requests
  requestDropStream:

  instance creation
  fileNamed:
fullName:
isAFileNamed:
new
newFileNamed:
oldFileNamed:
oldFileOrNoneNamed:
readOnlyFileNamed:

instance methods
  accessing top  
 

contents

Return the contents of the receiver. Do not close or otherwise touch the receiver. Return data in whatever mode the receiver is in (e.g., binary or text).


 

contentsOfEntireFile

Read all of the contents of the receiver.


 

directoryEntry


 

mimeTypes


 

next

Primitive. Return the next object in the Stream represented by the
receiver. Fail if the collection of this stream is not an Array or a String.
Fail if the stream is positioned at its end, or if the position is out of
bounds in the collection. Optional. See Object documentation
whatIsAPrimitive.


 

next:

Answer the next anInteger elements of my collection. overriden for efficiency


 

nextPut:

1/31/96 sw: subclassResponsibility


 

nextPutAll:

1/31/96 sw: made subclass responsibility


 

size

Answer the size of the file in characters.
1/31/96 sw: made subclass responsibility


  converting top  
 

asBinaryOrTextStream

I can switch between binary and text data


  editing top  
 

edit

Create and schedule an editor on this file.


 

viewGZipContents

View the contents of a gzipped file


  file accessing top  
 

file

Answer the file for the page the receiver is streaming over.
1/31/96 sw: made subclass responsibility


 

localName


 

name

Answer the name of the file for the page the receiver is streaming over. 1/31/96 sw: made subclassResponsibility


 

url

Convert my path into a file:// type url. Use slash instead of the local delimiter (:), and convert odd characters to %32 notation.


  file modes top  
 

ascii

Set this file to ascii (text) mode.


 

binary

Set this file to binary mode.


 

readOnly

Set this file's mode to read-only.


 

readWrite

Set this file's mode to read-write.


 

text

Set this file to text (ascii) mode.


  file open/close top  
 

close

Close this file.


 

closed

Answer true if this file is closed.


 

flush

When writing, flush the current buffer out to disk.


 

reopen

Ensure that the receiver is open, re-open it if necessary.


  fileIn/Out top  
 

fileIn

Guarantee that the receiver is readOnly before fileIn for efficiency and
to eliminate remote sharing conflicts.


 

fileInObjectAndCode

Read the file directly, do not use an RWBinaryOrTextStream.


 

fileIntoNewChangeSet


  positioning top  
 

position

Answer the current character position in the file.
1/31/96 sw: subclassResponsibility


 

position:

Set the current character position in the file to pos.
1/31/96 sw: made subclassResponsibility


 

reset

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


 

setToEnd

Set the current character position to the end of the File. The same as
self position: self size. 1/31/96 sw: made subclassResponsibility


 

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: made subclassResponsibility.


 

truncate:

Truncate file to pos


  printing top  
 

longPrintOn:

Do nothing, so it will print short. Called to print the error file. If the error was in a file operation, we can't read the contents of that file. Just print its name instead.


 

longPrintOn:limitedTo:indent:

Do nothing, so it will print short. Called to print the error file. If the error was in a file operation, we can't read the contents of that file. Just print its name instead.


 

printOn:

Append to the argument, aStream, a sequence of characters that
identifies the receiver.


  remote file compatibility top  
 

dataIsValid


  testing top  
 

atEnd

Answer true if the current position is >= the end of file position.
1/31/96 sw: subclassResponsibility


class methods
  browser requests top  
 

httpPostDocument:args:


 

httpPostMultipart:args:

do multipart/form-data encoding rather than x-www-urlencoded


 

post:target:url:ifError:


 

post:url:ifError:


 

requestURL:target:

FileStream requestURL:'http://isgwww.cs.uni-magdeburg.de/~raab' target: '_blank'


 

requestURLStream:

FileStream requestURLStream:'http://isgwww.cs.uni-magdeburg.de/~raab'


 

requestURLStream:ifError:

FileStream requestURLStream:'http://isgwww.cs.uni-magdeburg.de/~raab'


  concrete classes top  
 

concreteStream

Who should we really direct class queries to?


  dnd requests top  
 

requestDropStream:

Request a read-only stream for some file that was dropped onto Squeak


  instance creation top  
 

fileNamed:


 

fullName:


 

isAFileNamed:

return whether a file exists with the given name


 

new

Answer a new instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable.


 

newFileNamed:


 

oldFileNamed:


 

oldFileOrNoneNamed:

If the file exists, answer a read-only FileStream on it. If it doesn't, answer nil.


 

readOnlyFileNamed: