Yes, in my todo, but changing FileReference like that will break a lot of
backwards compatibility :)

On Mon, Oct 2, 2017 at 10:22 AM, Stephane Ducasse <stepharo.s...@gmail.com>
wrote:

> Yes this is why we should continue to clean and remove cruft. Now I
> remember that guille did that for File.
>
> Stef
>
> On Mon, Oct 2, 2017 at 3:20 PM, Sven Van Caekenberghe <s...@stfx.eu>
> wrote:
> > If you do
> >
> >   (File named: '/tmp/lines.txt') readStream[Do:]
> >
> > you seem to get a binary stream (this is the new implementation I
> guess), when you go via FileReference you get a character stream (but that
> are old ones).
> >
> > I know, very confusing. We're always in the midst of transitions.
> >
> >> On 2 Oct 2017, at 15:17, Stephane Ducasse <stepharo.s...@gmail.com>
> wrote:
> >>
> >> Sven I do not see the binary stream. Is it ZnCharacterReadStream?
> >>
> >> Stef
> >>
> >> On Mon, Oct 2, 2017 at 1:22 PM, Sven Van Caekenberghe <s...@stfx.eu>
> wrote:
> >>> Hi,
> >>>
> >>>> On 2 Oct 2017, at 13:07, Dirk Olmes <d...@xanthippe.ping.de> wrote:
> >>>>
> >>>> Hi,
> >>>>
> >>>> I'm trying to get started with Pharo doing something really simple -
> at
> >>>> least that's what I thought ... I'm trying to read a text file line
> by line.
> >>>>
> >>>> If I use  File named: '/tmp/linex.txt' readStream nextLine I'll get a
> >>>> debugger telling me that BinaryFileStream does not understand
> nextLine.
> >>>>
> >>>> Now I've tried my best to find a stream that may be reading plain text
> >>>> lines but to no avail ...
> >>>>
> >>>> Help!
> >>>>
> >>>> -dirk
> >>>
> >>> $ cat > /tmp/lines.txt
> >>> one
> >>> two
> >>> three
> >>>
> >>> (FileLocator temp / 'lines.txt') contents lines.
> >>>
> >>> '/tmp/lines.txt' asFileReference contents lines.
> >>>
> >>> '/tmp/lines.txt' asFileReference readStreamDo: [ :in |
> >>>  Array streamContents: [ :out |
> >>>    [ in atEnd ] whileFalse: [ out nextPut: in nextLine ] ] ].
> >>>
> >>> (File named: '/tmp/lines.txt') readStreamDo: [ :in |
> >>>  | characterStream |
> >>>  characterStream := ZnCharacterReadStream on: in.
> >>>  Array streamContents: [ :out |
> >>>    [ characterStream atEnd ] whileFalse: [ out nextPut:
> characterStream nextLine ] ] ].
> >>>
> >>> They all return #('one' 'two' 'three').
> >>>
> >>> In the last, more complex example, you first get a binary stream (and
> a 'line' is a character based concept), so wrapping the binary stream in a
> character read stream (which does know about lines) solves the problem.
> >>>
> >>> HTH,
> >>>
> >>> Sven
> >>
> >
> >
>
>


-- 



Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - *http://www.cnrs.fr
<http://www.cnrs.fr>*


*Web:* *http://guillep.github.io* <http://guillep.github.io>

*Phone: *+33 06 52 70 66 13

Reply via email to