eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'FileText':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: FileText


Inheritance:

   Object
   |
   +--Collection
      |
      +--SequenceableCollection
         |
         +--OrderedCollection
            |
            +--StringCollection
               |
               +--FileText

Package:
stx:libbasic2
Category:
Collections-Text
Version:
rev: 1.19 date: 2021/01/20 14:31:47
user: cg
file: FileText.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


FileText represents the contents of a text-file and allows
transparent access, via #at:, as if the lineStrings were in
memory - although, only a small portion of the file is actually
present in a cache.

Only the offsets of the text-lines are stored in an internal array
to save memory space. The #at: method fetches the line from the file.
Individual textlines may be replaced by strings (via #at:put:).
The underlying file is NOT updated in this case.

Care should be taken, if the underlying file is rewritten -
you have to manually update/flush the pointers.
Never rewrite the file using the data from a FileText.
If you keep a file's contents in a FileText object and want to
rewrite that file, you MUST write to a temporary file first.
Otherwise, you will clobber the contents.

This is an EXPERIMENTAL class, use at your own risk.
(If at all, use fileText for huge readonly texts only.)

copyright

COPYRIGHT (c) 1989 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  of: aStream
return a new FileText object for the stream aStream

o  ofFile: aFileName
return a new FileText object for the named file


Instance protocol:

accessing
o  at: index
return the files line at index, as a string

o  of: aStream
setup the receiver for lines from aStream

o  size
return the number of text-lines - have to scan file the first time

enumerating
o  do: aBlock
evaluate aBlock for all lines

o  from: index1 to: index2 do: aBlock
evaluate aBlock for all lines from index1 to index2.
Must be redefined back since elements are indices into file,
not the elements themselfes

private
o  scanUpToEnd
scan myStream up to the end of file

o  scanUpToLine: index
scan myStream up to line index and save line-start-positions



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 30 Dec 2024 17:09:55 GMT