[Cuis-dev] fileout. proposed 2 new methods for strict file chunks reading

Nicola Mingotti nmingotti at gmail.com
Tue Oct 19 06:32:08 PDT 2021


Hi Hernan,

In all frankness, in I would wipe out the old 'upTo' because its 
behavior is a bit "wild".

On the other side, I understand it may create problems in 
retro-compatibility, that is why for
the moment i propose to add a new method which behaves a bit better.

I hope this example explains the problem:
-------------------------------------------------------
s _ 'hello-1Ahello-2Ahel'.
'/tmp/test.txt' asFileEntry fileContents: s.

st1 _ '/tmp/test.txt' asFileEntry readStream .

st1 upTo: $A. " 'hello-1' "
st1 upTo: $A. " 'hello-2' "
st1 upTo: $A. " 'hel' "         "(*)"
------------------------------------------------------
(*) You can't establish in any way if you actually found an "A" 
terminated block or just hit the end of file
(*) If you hit the end of file you eat an incomplete record, this is 
another problem, maybe another process
was going to end writing that record but you will never know.

Maybe there is another method around that performs similarly to 
'strictUpTp', if there is I did not find it, sorry.

IMHO, In a scale of importance from 0 to 10, this method, for a 
programmer, >= 8.
I would definitely not put it into an external package, too much 
fundamental.

bye
Nicola














On 10/19/21 14:44, Hernan Wilkinson wrote:
> Hi Nicola!
>  I was wondering, why are you suggesting adding them to the base? Is 
> it not enough to implement them as an extension in your package?
>  Also, I think that any new functionality should come with its 
> corresponding tests to help the maintenance and understanding of the 
> functionality.
>
> Cheers!
> Hernan.
>
>
> On Tue, Oct 19, 2021 at 7:04 AM Nicola Mingotti via Cuis-dev 
> <cuis-dev at lists.cuis.st> wrote:
>
>     Hi Juan, guys,
>
>     I would like to add to Cuis the 2 methods i attach here. One is a
>     helper method.
>
>     -----------
>     StandardFileStream strictUpTo: delim.
>     -----------
>
>     Differently from 'upTo: delim' this method:
>     1. Does not return stuff if it does not find 'delim'.
>     2. Does not upgrade the position on the stream if does not find
>     'delim'.
>     3. If it finds 'delim' returns a chunk that includes it.
>
>     I am parsing log files at the moment, this is very much useful.
>
>     NOTE. Up to now I tested only on small files.
>
>     bye
>     Nicola
>
>
>
>
>     -- 
>     Cuis-dev mailing list
>     Cuis-dev at lists.cuis.st
>     https://lists.cuis.st/mailman/listinfo/cuis-dev
>
>
>
> -- 
> <https://10pines.com/>
>
>
>   Hernán Wilkinson
>
>
>     Software Developer & Coach
>
> Alem 896, Floor 6, Buenos Aires, Argentina
>
> +54 11 6091 3125
>
> @HernanWilkinson
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20211019/3710e55f/attachment-0001.htm>


More information about the Cuis-dev mailing list