@@ -37,6 +37,7 @@ Private P_BUFFERSIZE As Single '-------------------Buffer's size x10 MB (0.5 by
3737Private P_ENDSTREAMONLINEBREAK As Boolean '--------If true, each stream ends on a line break.
3838Private P_ISOPENSTREAM As Boolean '----------------Indicates if the object is linked to a file
3939Private P_LINEBREAK As String '--------------------Holds the char used to end a Stream.
40+ Private P_LINEBREAKMATCHINGBEHAVIOR As EndLineMatchingBehavior 'How to find the next line break.
4041Private P_UNIFIEDLFOUTPUT As Boolean '-------------If true, the buffer string will be returned
4142' with the LF char as Line Break.
4243Private P_STREAMLENGTH As Long '-------------------File len.
@@ -71,6 +72,10 @@ Public Enum EndLineChar
7172 CR = 1
7273 LF = 2
7374End Enum
75+ Public Enum EndLineMatchingBehavior
76+ OnlyBackwardSense = 0 'From the end to the beginning of the buffer.
77+ Bidirectional = 1 'Find the line break in both directions.
78+ End Enum
7479'////////////////////////////////////////////////////////////////////////////////////////////
7580'#
7681' PROPERTIES:
@@ -112,6 +117,12 @@ Public Property Get lineBreak() As String
112117Attribute lineBreak.VB_Description = "Returns the character used to end the last received stream. The value is vbNullString when the last stream is not forced to end on line break."
113118 lineBreak = P_LINEBREAK
114119End Property
120+ Public Property Get linebreakMatchingBehavior() As EndLineMatchingBehavior
121+ linebreakMatchingBehavior = P_LINEBREAKMATCHINGBEHAVIOR
122+ End Property
123+ Public Property Let linebreakMatchingBehavior(value As EndLineMatchingBehavior )
124+ P_LINEBREAKMATCHINGBEHAVIOR = value
125+ End Property
115126Public Property Get pointerPosition() As Long
116127Attribute pointerPosition.VB_Description = "Gets the overall pointer position over the current text file."
117128 If P_ISOPENSTREAM Then
@@ -160,21 +171,23 @@ Private Sub FindEOLcharacter()
160171 Dim EOLchr As EndLineChar
161172 Dim missingEOLchar As Boolean
162173 Dim EOStream As Boolean
163-
164- Do
165- CrCharInStream = InStrB(1 , Buffer, vbCr)
166- LfCharInStream = InStrB(1 , Buffer, vbLf)
167- missingEOLchar = (Not CrCharInStream) And (Not LfCharInStream)
168- If missingEOLchar Then
169- DoubleBufferSize
170- SeekPointer TmpInitialPos
171- Get #FileHandled, , Buffer
172- InitialPos = Seek (FileHandled)
173- BufferMark = LenB(Buffer)
174- EOStream = (P_STREAMLENGTH <= InitialPos)
175- End If
176- Loop While missingEOLchar And Not EOStream
177- P_ATENDOFSTREAM = EOStream
174+
175+ If P_LINEBREAKMATCHINGBEHAVIOR = EndLineMatchingBehavior.Bidirectional Then
176+ Do
177+ CrCharInStream = InStrB(1 , Buffer, vbCr)
178+ LfCharInStream = InStrB(1 , Buffer, vbLf)
179+ missingEOLchar = (Not CrCharInStream) And (Not LfCharInStream)
180+ If missingEOLchar Then
181+ DoubleBufferSize
182+ SeekPointer TmpInitialPos
183+ Get #FileHandled, , Buffer
184+ InitialPos = Seek (FileHandled)
185+ BufferMark = LenB(Buffer)
186+ EOStream = (P_STREAMLENGTH <= InitialPos)
187+ End If
188+ Loop While missingEOLchar And Not EOStream
189+ P_ATENDOFSTREAM = EOStream
190+ End If
178191 If Not EOStream Then
179192 If Not missingEOLchar Then
180193 Last2Chrs = MidB$(Buffer, BufferMark - 3 , 4 )
@@ -343,6 +356,7 @@ Private Sub Class_Initialize()
343356 P_BUFFERSIZE = 0.5
344357 P_BUFFERLENGTH = CLng(P_BUFFERSIZE * SizeFactor)
345358 P_ENDSTREAMONLINEBREAK = False
359+ P_LINEBREAKMATCHINGBEHAVIOR = EndLineMatchingBehavior.Bidirectional
346360 P_UNIFIEDLFOUTPUT = False
347361 Buffer = SPACE$(P_BUFFERLENGTH)
348362 NullChar = ChrW(0 )
0 commit comments