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.18 date: 2016/06/27 15:26:27
user: stefan
file: FileText.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Claus Gittinger

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


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.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 07:05:49 GMT